1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
// // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIOfflineCacheUpdate.idl // /// `interface nsIOfflineCacheUpdateObserver : nsISupports` /// // The actual type definition for the interface. This struct has methods // declared on it which will call through its vtable. You never want to pass // this type around by value, always pass it behind a reference. #[repr(C)] pub struct nsIOfflineCacheUpdateObserver { vtable: *const nsIOfflineCacheUpdateObserverVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, } // Implementing XpCom for an interface exposes its IID, which allows for easy // use of the `.query_interface<T>` helper method. This also defines that // method for nsIOfflineCacheUpdateObserver. unsafe impl XpCom for nsIOfflineCacheUpdateObserver { const IID: nsIID = nsID(0x47360d57, 0x8ef4, 0x4a5d, [0x88, 0x65, 0x1a, 0x27, 0xa7, 0x39, 0xad, 0x1a]); } // We need to implement the RefCounted trait so we can be used with `RefPtr`. // This trait teaches `RefPtr` how to manage our memory. unsafe impl RefCounted for nsIOfflineCacheUpdateObserver { #[inline] unsafe fn addref(&self) { self.AddRef(); } #[inline] unsafe fn release(&self) { self.Release(); } } // This trait is implemented on all types which can be coerced to from nsIOfflineCacheUpdateObserver. // It is used in the implementation of `fn coerce<T>`. We hide it from the // documentation, because it clutters it up a lot. #[doc(hidden)] pub trait nsIOfflineCacheUpdateObserverCoerce { /// Cheaply cast a value of this type from a `nsIOfflineCacheUpdateObserver`. fn coerce_from(v: &nsIOfflineCacheUpdateObserver) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIOfflineCacheUpdateObserverCoerce for nsIOfflineCacheUpdateObserver { #[inline] fn coerce_from(v: &nsIOfflineCacheUpdateObserver) -> &Self { v } } impl nsIOfflineCacheUpdateObserver { /// Cast this `nsIOfflineCacheUpdateObserver` to one of its base interfaces. #[inline] pub fn coerce<T: nsIOfflineCacheUpdateObserverCoerce>(&self) -> &T { T::coerce_from(self) } } // Every interface struct type implements `Deref` to its base interface. This // causes methods on the base interfaces to be directly avaliable on the // object. For example, you can call `.AddRef` or `.QueryInterface` directly // on any interface which inherits from `nsISupports`. impl ::std::ops::Deref for nsIOfflineCacheUpdateObserver { type Target = nsISupports; #[inline] fn deref(&self) -> &nsISupports { unsafe { ::std::mem::transmute(self) } } } // Ensure we can use .coerce() to cast to our base types as well. Any type which // our base interface can coerce from should be coercable from us as well. impl<T: nsISupportsCoerce> nsIOfflineCacheUpdateObserverCoerce for T { #[inline] fn coerce_from(v: &nsIOfflineCacheUpdateObserver) -> &Self { T::coerce_from(v) } } // This struct represents the interface's VTable. A pointer to a statically // allocated version of this struct is at the beginning of every nsIOfflineCacheUpdateObserver // object. It contains one pointer field for each method in the interface. In // the case where we can't generate a binding for a method, we include a void // pointer. #[doc(hidden)] #[repr(C)] pub struct nsIOfflineCacheUpdateObserverVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* void updateStateChanged (in nsIOfflineCacheUpdate aUpdate, in uint32_t state); */ pub UpdateStateChanged: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateObserver, aUpdate: *const nsIOfflineCacheUpdate, state: uint32_t) -> nsresult, /* void applicationCacheAvailable (in nsIApplicationCache applicationCache); */ pub ApplicationCacheAvailable: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateObserver, applicationCache: *const nsIApplicationCache) -> nsresult, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIOfflineCacheUpdateObserver { pub const STATE_ERROR: i64 = 1; pub const STATE_CHECKING: i64 = 2; pub const STATE_NOUPDATE: i64 = 3; pub const STATE_OBSOLETE: i64 = 4; pub const STATE_DOWNLOADING: i64 = 5; pub const STATE_ITEMSTARTED: i64 = 6; pub const STATE_ITEMCOMPLETED: i64 = 7; pub const STATE_ITEMPROGRESS: i64 = 8; pub const STATE_FINISHED: i64 = 10; /// ```text /// /** /// * aUpdate has changed its state. /// * /// * @param aUpdate /// * The nsIOfflineCacheUpdate being processed. /// * @param event /// * See enumeration above /// */ /// ``` /// /// `void updateStateChanged (in nsIOfflineCacheUpdate aUpdate, in uint32_t state);` #[inline] pub unsafe fn UpdateStateChanged(&self, aUpdate: *const nsIOfflineCacheUpdate, state: uint32_t) -> nsresult { ((*self.vtable).UpdateStateChanged)(self, aUpdate, state) } /// ```text /// /** /// * Informs the observer about an application being available to associate. /// * /// * @param applicationCache /// * The application cache instance that has been created or found by the /// * update to associate with /// */ /// ``` /// /// `void applicationCacheAvailable (in nsIApplicationCache applicationCache);` #[inline] pub unsafe fn ApplicationCacheAvailable(&self, applicationCache: *const nsIApplicationCache) -> nsresult { ((*self.vtable).ApplicationCacheAvailable)(self, applicationCache) } } /// `interface nsIOfflineCacheUpdate : nsISupports` /// // The actual type definition for the interface. This struct has methods // declared on it which will call through its vtable. You never want to pass // this type around by value, always pass it behind a reference. #[repr(C)] pub struct nsIOfflineCacheUpdate { vtable: *const nsIOfflineCacheUpdateVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, } // Implementing XpCom for an interface exposes its IID, which allows for easy // use of the `.query_interface<T>` helper method. This also defines that // method for nsIOfflineCacheUpdate. unsafe impl XpCom for nsIOfflineCacheUpdate { const IID: nsIID = nsID(0x6e3e26ea, 0x45b2, 0x4db7, [0x9e, 0x4a, 0x93, 0xb9, 0x65, 0x67, 0x92, 0x98]); } // We need to implement the RefCounted trait so we can be used with `RefPtr`. // This trait teaches `RefPtr` how to manage our memory. unsafe impl RefCounted for nsIOfflineCacheUpdate { #[inline] unsafe fn addref(&self) { self.AddRef(); } #[inline] unsafe fn release(&self) { self.Release(); } } // This trait is implemented on all types which can be coerced to from nsIOfflineCacheUpdate. // It is used in the implementation of `fn coerce<T>`. We hide it from the // documentation, because it clutters it up a lot. #[doc(hidden)] pub trait nsIOfflineCacheUpdateCoerce { /// Cheaply cast a value of this type from a `nsIOfflineCacheUpdate`. fn coerce_from(v: &nsIOfflineCacheUpdate) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIOfflineCacheUpdateCoerce for nsIOfflineCacheUpdate { #[inline] fn coerce_from(v: &nsIOfflineCacheUpdate) -> &Self { v } } impl nsIOfflineCacheUpdate { /// Cast this `nsIOfflineCacheUpdate` to one of its base interfaces. #[inline] pub fn coerce<T: nsIOfflineCacheUpdateCoerce>(&self) -> &T { T::coerce_from(self) } } // Every interface struct type implements `Deref` to its base interface. This // causes methods on the base interfaces to be directly avaliable on the // object. For example, you can call `.AddRef` or `.QueryInterface` directly // on any interface which inherits from `nsISupports`. impl ::std::ops::Deref for nsIOfflineCacheUpdate { type Target = nsISupports; #[inline] fn deref(&self) -> &nsISupports { unsafe { ::std::mem::transmute(self) } } } // Ensure we can use .coerce() to cast to our base types as well. Any type which // our base interface can coerce from should be coercable from us as well. impl<T: nsISupportsCoerce> nsIOfflineCacheUpdateCoerce for T { #[inline] fn coerce_from(v: &nsIOfflineCacheUpdate) -> &Self { T::coerce_from(v) } } // This struct represents the interface's VTable. A pointer to a statically // allocated version of this struct is at the beginning of every nsIOfflineCacheUpdate // object. It contains one pointer field for each method in the interface. In // the case where we can't generate a binding for a method, we include a void // pointer. #[doc(hidden)] #[repr(C)] pub struct nsIOfflineCacheUpdateVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* readonly attribute unsigned short status; */ pub GetStatus: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aStatus: *mut libc::uint16_t) -> nsresult, /* readonly attribute boolean partial; */ pub GetPartial: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aPartial: *mut bool) -> nsresult, /* readonly attribute boolean isUpgrade; */ pub GetIsUpgrade: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aIsUpgrade: *mut bool) -> nsresult, /* readonly attribute ACString updateDomain; */ pub GetUpdateDomain: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aUpdateDomain: &mut ::nsstring::nsACString) -> nsresult, /* readonly attribute nsIURI manifestURI; */ pub GetManifestURI: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aManifestURI: *mut *const nsIURI) -> nsresult, /* readonly attribute boolean succeeded; */ pub GetSucceeded: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aSucceeded: *mut bool) -> nsresult, /* void init (in nsIURI aManifestURI, in nsIURI aDocumentURI, in nsIPrincipal aLoadingPrincipal, in nsIDOMDocument aDocument, [optional] in nsIFile aCustomProfileDir); */ pub Init: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aManifestURI: *const nsIURI, aDocumentURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aDocument: *const nsIDOMDocument, aCustomProfileDir: *const nsIFile) -> nsresult, /* void initPartial (in nsIURI aManifestURI, in ACString aClientID, in nsIURI aDocumentURI, in nsIPrincipal aPrincipal); */ pub InitPartial: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aManifestURI: *const nsIURI, aClientID: &::nsstring::nsACString, aDocumentURI: *const nsIURI, aPrincipal: *const nsIPrincipal) -> nsresult, /* void initForUpdateCheck (in nsIURI aManifestURI, in nsIPrincipal aLoadingPrincipal, in nsIObserver aObserver); */ pub InitForUpdateCheck: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aManifestURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aObserver: *const nsIObserver) -> nsresult, /* void addDynamicURI (in nsIURI aURI); */ pub AddDynamicURI: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aURI: *const nsIURI) -> nsresult, /* void schedule (); */ pub Schedule: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate) -> nsresult, /* void addObserver (in nsIOfflineCacheUpdateObserver aObserver, [optional] in boolean aHoldWeak); */ pub AddObserver: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aObserver: *const nsIOfflineCacheUpdateObserver, aHoldWeak: bool) -> nsresult, /* void removeObserver (in nsIOfflineCacheUpdateObserver aObserver); */ pub RemoveObserver: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aObserver: *const nsIOfflineCacheUpdateObserver) -> nsresult, /* void cancel (); */ pub Cancel: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate) -> nsresult, /* readonly attribute uint64_t byteProgress; */ pub GetByteProgress: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdate, aByteProgress: *mut uint64_t) -> nsresult, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIOfflineCacheUpdate { /// ```text /// /** /// * An nsIOfflineCacheUpdate is used to update an application's offline /// * resources. /// * /// * It can be used to perform partial or complete updates. /// * /// * One update object will be updating at a time. The active object will /// * load its items one by one, sending itemCompleted() to any registered /// * observers. /// */ /// /** /// * Fetch the status of the running update. This will return a value /// * defined in nsIDOMOfflineResourceList. /// */ /// ``` /// /// `readonly attribute unsigned short status;` #[inline] pub unsafe fn GetStatus(&self, aStatus: *mut libc::uint16_t) -> nsresult { ((*self.vtable).GetStatus)(self, aStatus) } /// ```text /// /** /// * TRUE if the update is being used to add specific resources. /// * FALSE if the complete cache update process is happening. /// */ /// ``` /// /// `readonly attribute boolean partial;` #[inline] pub unsafe fn GetPartial(&self, aPartial: *mut bool) -> nsresult { ((*self.vtable).GetPartial)(self, aPartial) } /// ```text /// /** /// * TRUE if this is an upgrade attempt, FALSE if it is a new cache /// * attempt. /// */ /// ``` /// /// `readonly attribute boolean isUpgrade;` #[inline] pub unsafe fn GetIsUpgrade(&self, aIsUpgrade: *mut bool) -> nsresult { ((*self.vtable).GetIsUpgrade)(self, aIsUpgrade) } /// ```text /// /** /// * The domain being updated, and the domain that will own any URIs added /// * with this update. /// */ /// ``` /// /// `readonly attribute ACString updateDomain;` #[inline] pub unsafe fn GetUpdateDomain(&self, aUpdateDomain: &mut ::nsstring::nsACString) -> nsresult { ((*self.vtable).GetUpdateDomain)(self, aUpdateDomain) } /// ```text /// /** /// * The manifest for the offline application being updated. /// */ /// ``` /// /// `readonly attribute nsIURI manifestURI;` #[inline] pub unsafe fn GetManifestURI(&self, aManifestURI: *mut *const nsIURI) -> nsresult { ((*self.vtable).GetManifestURI)(self, aManifestURI) } /// ```text /// /** /// * TRUE if the cache update completed successfully. /// */ /// ``` /// /// `readonly attribute boolean succeeded;` #[inline] pub unsafe fn GetSucceeded(&self, aSucceeded: *mut bool) -> nsresult { ((*self.vtable).GetSucceeded)(self, aSucceeded) } /// ```text /// /** /// * Initialize the update. /// * /// * @param aManifestURI /// * The manifest URI to be checked. /// * @param aDocumentURI /// * The page that is requesting the update. /// * @param aLoadingPrincipal /// * The principal of the page that is requesting the update. /// */ /// ``` /// /// `void init (in nsIURI aManifestURI, in nsIURI aDocumentURI, in nsIPrincipal aLoadingPrincipal, in nsIDOMDocument aDocument, [optional] in nsIFile aCustomProfileDir);` #[inline] pub unsafe fn Init(&self, aManifestURI: *const nsIURI, aDocumentURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aDocument: *const nsIDOMDocument, aCustomProfileDir: *const nsIFile) -> nsresult { ((*self.vtable).Init)(self, aManifestURI, aDocumentURI, aLoadingPrincipal, aDocument, aCustomProfileDir) } /// ```text /// /** /// * Initialize the update for partial processing. /// * /// * @param aManifestURI /// * The manifest URI of the related cache. /// * @param aClientID /// * Client ID of the cache to store resource to. This ClientID /// * must be ID of cache in the cache group identified by /// * the manifest URI passed in the first parameter. /// * @param aDocumentURI /// * The page that is requesting the update. May be null /// * when this information is unknown. /// */ /// ``` /// /// `void initPartial (in nsIURI aManifestURI, in ACString aClientID, in nsIURI aDocumentURI, in nsIPrincipal aPrincipal);` #[inline] pub unsafe fn InitPartial(&self, aManifestURI: *const nsIURI, aClientID: &::nsstring::nsACString, aDocumentURI: *const nsIURI, aPrincipal: *const nsIPrincipal) -> nsresult { ((*self.vtable).InitPartial)(self, aManifestURI, aClientID, aDocumentURI, aPrincipal) } /// ```text /// /** /// * Initialize the update to only check whether there is an update /// * to the manifest available (if it has actually changed on the server). /// * /// * @param aManifestURI /// * The manifest URI of the related cache. /// * @param aObserver /// * nsIObserver implementation that receives the result. /// * When aTopic == "offline-cache-update-available" there is an update to /// * to download. Update of the app cache will lead to a new version /// * download. /// * When aTopic == "offline-cache-update-unavailable" then there is no /// * update available (the manifest has not changed on the server). /// */ /// ``` /// /// `void initForUpdateCheck (in nsIURI aManifestURI, in nsIPrincipal aLoadingPrincipal, in nsIObserver aObserver);` #[inline] pub unsafe fn InitForUpdateCheck(&self, aManifestURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aObserver: *const nsIObserver) -> nsresult { ((*self.vtable).InitForUpdateCheck)(self, aManifestURI, aLoadingPrincipal, aObserver) } /// ```text /// /** /// * Add a dynamic URI to the offline cache as part of the update. /// * /// * @param aURI /// * The URI to add. /// */ /// ``` /// /// `void addDynamicURI (in nsIURI aURI);` #[inline] pub unsafe fn AddDynamicURI(&self, aURI: *const nsIURI) -> nsresult { ((*self.vtable).AddDynamicURI)(self, aURI) } /// ```text /// /** /// * Add the update to the offline update queue. An offline-cache-update-added /// * event will be sent to the observer service. /// */ /// ``` /// /// `void schedule ();` #[inline] pub unsafe fn Schedule(&self, ) -> nsresult { ((*self.vtable).Schedule)(self, ) } /// ```text /// /** /// * Observe loads that are added to the update. /// * /// * @param aObserver /// * object that notifications will be sent to. /// * @param aHoldWeak /// * TRUE if you want the update to hold a weak reference to the /// * observer, FALSE for a strong reference. /// */ /// ``` /// /// `void addObserver (in nsIOfflineCacheUpdateObserver aObserver, [optional] in boolean aHoldWeak);` #[inline] pub unsafe fn AddObserver(&self, aObserver: *const nsIOfflineCacheUpdateObserver, aHoldWeak: bool) -> nsresult { ((*self.vtable).AddObserver)(self, aObserver, aHoldWeak) } /// ```text /// /** /// * Remove an observer from the update. /// * /// * @param aObserver /// * the observer to remove. /// */ /// ``` /// /// `void removeObserver (in nsIOfflineCacheUpdateObserver aObserver);` #[inline] pub unsafe fn RemoveObserver(&self, aObserver: *const nsIOfflineCacheUpdateObserver) -> nsresult { ((*self.vtable).RemoveObserver)(self, aObserver) } /// ```text /// /** /// * Cancel the update when still in progress. This stops all running resource /// * downloads and discards the downloaded cache version. Throws when update /// * has already finished and made the new cache version active. /// */ /// ``` /// /// `void cancel ();` #[inline] pub unsafe fn Cancel(&self, ) -> nsresult { ((*self.vtable).Cancel)(self, ) } /// ```text /// /** /// * Return the number of bytes downloaded so far /// */ /// ``` /// /// `readonly attribute uint64_t byteProgress;` #[inline] pub unsafe fn GetByteProgress(&self, aByteProgress: *mut uint64_t) -> nsresult { ((*self.vtable).GetByteProgress)(self, aByteProgress) } } /// `interface nsIOfflineCacheUpdateService : nsISupports` /// // The actual type definition for the interface. This struct has methods // declared on it which will call through its vtable. You never want to pass // this type around by value, always pass it behind a reference. #[repr(C)] pub struct nsIOfflineCacheUpdateService { vtable: *const nsIOfflineCacheUpdateServiceVTable, /// This field is a phantomdata to ensure that the VTable type and any /// struct containing it is not safe to send across threads, as XPCOM is /// generally not threadsafe. /// /// XPCOM interfaces in general are not safe to send across threads. __nosync: ::std::marker::PhantomData<::std::rc::Rc<u8>>, } // Implementing XpCom for an interface exposes its IID, which allows for easy // use of the `.query_interface<T>` helper method. This also defines that // method for nsIOfflineCacheUpdateService. unsafe impl XpCom for nsIOfflineCacheUpdateService { const IID: nsIID = nsID(0x44971e74, 0x37e4, 0x4140, [0x86, 0x77, 0xa4, 0xcf, 0x21, 0x3a, 0x3f, 0x4b]); } // We need to implement the RefCounted trait so we can be used with `RefPtr`. // This trait teaches `RefPtr` how to manage our memory. unsafe impl RefCounted for nsIOfflineCacheUpdateService { #[inline] unsafe fn addref(&self) { self.AddRef(); } #[inline] unsafe fn release(&self) { self.Release(); } } // This trait is implemented on all types which can be coerced to from nsIOfflineCacheUpdateService. // It is used in the implementation of `fn coerce<T>`. We hide it from the // documentation, because it clutters it up a lot. #[doc(hidden)] pub trait nsIOfflineCacheUpdateServiceCoerce { /// Cheaply cast a value of this type from a `nsIOfflineCacheUpdateService`. fn coerce_from(v: &nsIOfflineCacheUpdateService) -> &Self; } // The trivial implementation: We can obviously coerce ourselves to ourselves. impl nsIOfflineCacheUpdateServiceCoerce for nsIOfflineCacheUpdateService { #[inline] fn coerce_from(v: &nsIOfflineCacheUpdateService) -> &Self { v } } impl nsIOfflineCacheUpdateService { /// Cast this `nsIOfflineCacheUpdateService` to one of its base interfaces. #[inline] pub fn coerce<T: nsIOfflineCacheUpdateServiceCoerce>(&self) -> &T { T::coerce_from(self) } } // Every interface struct type implements `Deref` to its base interface. This // causes methods on the base interfaces to be directly avaliable on the // object. For example, you can call `.AddRef` or `.QueryInterface` directly // on any interface which inherits from `nsISupports`. impl ::std::ops::Deref for nsIOfflineCacheUpdateService { type Target = nsISupports; #[inline] fn deref(&self) -> &nsISupports { unsafe { ::std::mem::transmute(self) } } } // Ensure we can use .coerce() to cast to our base types as well. Any type which // our base interface can coerce from should be coercable from us as well. impl<T: nsISupportsCoerce> nsIOfflineCacheUpdateServiceCoerce for T { #[inline] fn coerce_from(v: &nsIOfflineCacheUpdateService) -> &Self { T::coerce_from(v) } } // This struct represents the interface's VTable. A pointer to a statically // allocated version of this struct is at the beginning of every nsIOfflineCacheUpdateService // object. It contains one pointer field for each method in the interface. In // the case where we can't generate a binding for a method, we include a void // pointer. #[doc(hidden)] #[repr(C)] pub struct nsIOfflineCacheUpdateServiceVTable { /// We need to include the members from the base interface's vtable at the start /// of the VTable definition. pub __base: nsISupportsVTable, /* readonly attribute unsigned long numUpdates; */ pub GetNumUpdates: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateService, aNumUpdates: *mut libc::uint32_t) -> nsresult, /* nsIOfflineCacheUpdate getUpdate (in unsigned long index); */ pub GetUpdate: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateService, index: libc::uint32_t, _retval: *mut *const nsIOfflineCacheUpdate) -> nsresult, /* nsIOfflineCacheUpdate scheduleUpdate (in nsIURI aManifestURI, in nsIURI aDocumentURI, in nsIPrincipal aLoadingPrincipal, in mozIDOMWindow aWindow); */ pub ScheduleUpdate: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateService, aManifestURI: *const nsIURI, aDocumentURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aWindow: *const mozIDOMWindow, _retval: *mut *const nsIOfflineCacheUpdate) -> nsresult, /* nsIOfflineCacheUpdate scheduleAppUpdate (in nsIURI aManifestURI, in nsIURI aDocumentURI, in nsIPrincipal aLoadingPrincipal, in nsIFile aProfileDir); */ pub ScheduleAppUpdate: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateService, aManifestURI: *const nsIURI, aDocumentURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aProfileDir: *const nsIFile, _retval: *mut *const nsIOfflineCacheUpdate) -> nsresult, /* void scheduleOnDocumentStop (in nsIURI aManifestURI, in nsIURI aDocumentURI, in nsIPrincipal aLoadingPrincipal, in nsIDOMDocument aDocument); */ pub ScheduleOnDocumentStop: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateService, aManifestURI: *const nsIURI, aDocumentURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aDocument: *const nsIDOMDocument) -> nsresult, /* void checkForUpdate (in nsIURI aManifestURI, in nsIPrincipal aLoadingPrincipal, in nsIObserver aObserver); */ pub CheckForUpdate: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateService, aManifestURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aObserver: *const nsIObserver) -> nsresult, /* boolean offlineAppAllowed (in nsIPrincipal aPrincipal, in nsIPrefBranch aPrefBranch); */ pub OfflineAppAllowed: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateService, aPrincipal: *const nsIPrincipal, aPrefBranch: *const nsIPrefBranch, _retval: *mut bool) -> nsresult, /* boolean offlineAppAllowedForURI (in nsIURI aURI, in nsIPrefBranch aPrefBranch); */ pub OfflineAppAllowedForURI: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateService, aURI: *const nsIURI, aPrefBranch: *const nsIPrefBranch, _retval: *mut bool) -> nsresult, /* void allowOfflineApp (in nsIPrincipal aPrincipal); */ pub AllowOfflineApp: unsafe extern "system" fn (this: *const nsIOfflineCacheUpdateService, aPrincipal: *const nsIPrincipal) -> nsresult, } // The implementations of the function wrappers which are exposed to rust code. // Call these methods rather than manually calling through the VTable struct. impl nsIOfflineCacheUpdateService { /// ```text /// /** /// * Constants for the offline-app permission. /// * /// * XXX: This isn't a great place for this, but it's really the only /// * private offline-app-related interface /// */ /// /** /// * Allow the domain to use offline APIs, and don't warn about excessive /// * usage. /// */ /// ``` /// pub const ALLOW_NO_WARN: i64 = 3; /// ```text /// /** /// * Access to the list of cache updates that have been scheduled. /// */ /// ``` /// /// `readonly attribute unsigned long numUpdates;` #[inline] pub unsafe fn GetNumUpdates(&self, aNumUpdates: *mut libc::uint32_t) -> nsresult { ((*self.vtable).GetNumUpdates)(self, aNumUpdates) } /// `nsIOfflineCacheUpdate getUpdate (in unsigned long index);` #[inline] pub unsafe fn GetUpdate(&self, index: libc::uint32_t, _retval: *mut *const nsIOfflineCacheUpdate) -> nsresult { ((*self.vtable).GetUpdate)(self, index, _retval) } /// ```text /// /** /// * Schedule a cache update for a given offline manifest. If an /// * existing update is scheduled or running, that update will be returned. /// * Otherwise a new update will be scheduled. /// */ /// ``` /// /// `nsIOfflineCacheUpdate scheduleUpdate (in nsIURI aManifestURI, in nsIURI aDocumentURI, in nsIPrincipal aLoadingPrincipal, in mozIDOMWindow aWindow);` #[inline] pub unsafe fn ScheduleUpdate(&self, aManifestURI: *const nsIURI, aDocumentURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aWindow: *const mozIDOMWindow, _retval: *mut *const nsIOfflineCacheUpdate) -> nsresult { ((*self.vtable).ScheduleUpdate)(self, aManifestURI, aDocumentURI, aLoadingPrincipal, aWindow, _retval) } /// ```text /// /** /// * Schedule a cache update for a given offline manifest using app cache /// * bound to the given appID+inIsolatedMozBrowser flag. If an existing update /// * is scheduled or running, that update will be returned. Otherwise a new /// * update will be scheduled. /// */ /// ``` /// /// `nsIOfflineCacheUpdate scheduleAppUpdate (in nsIURI aManifestURI, in nsIURI aDocumentURI, in nsIPrincipal aLoadingPrincipal, in nsIFile aProfileDir);` #[inline] pub unsafe fn ScheduleAppUpdate(&self, aManifestURI: *const nsIURI, aDocumentURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aProfileDir: *const nsIFile, _retval: *mut *const nsIOfflineCacheUpdate) -> nsresult { ((*self.vtable).ScheduleAppUpdate)(self, aManifestURI, aDocumentURI, aLoadingPrincipal, aProfileDir, _retval) } /// ```text /// /** /// * Schedule a cache update for a manifest when the document finishes /// * loading. /// */ /// ``` /// /// `void scheduleOnDocumentStop (in nsIURI aManifestURI, in nsIURI aDocumentURI, in nsIPrincipal aLoadingPrincipal, in nsIDOMDocument aDocument);` #[inline] pub unsafe fn ScheduleOnDocumentStop(&self, aManifestURI: *const nsIURI, aDocumentURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aDocument: *const nsIDOMDocument) -> nsresult { ((*self.vtable).ScheduleOnDocumentStop)(self, aManifestURI, aDocumentURI, aLoadingPrincipal, aDocument) } /// ```text /// /** /// * Schedule a check to see if an update is available. /// * /// * This will not update or make any changes to the appcache. /// * It only notifies the observer to indicate whether the manifest has /// * changed on the server (or not): a changed manifest means that an /// * update is available. /// * /// * For arguments see nsIOfflineCacheUpdate.initForUpdateCheck() method /// * description. /// */ /// ``` /// /// `void checkForUpdate (in nsIURI aManifestURI, in nsIPrincipal aLoadingPrincipal, in nsIObserver aObserver);` #[inline] pub unsafe fn CheckForUpdate(&self, aManifestURI: *const nsIURI, aLoadingPrincipal: *const nsIPrincipal, aObserver: *const nsIObserver) -> nsresult { ((*self.vtable).CheckForUpdate)(self, aManifestURI, aLoadingPrincipal, aObserver) } /// ```text /// /** /// * Checks whether a principal should have access to the offline /// * cache. /// * @param aPrincipal /// * The principal to check. /// * @param aPrefBranch /// * The pref branch to use to check the /// * offline-apps.allow_by_default pref. If not specified, /// * the pref service will be used. /// */ /// ``` /// /// `boolean offlineAppAllowed (in nsIPrincipal aPrincipal, in nsIPrefBranch aPrefBranch);` #[inline] pub unsafe fn OfflineAppAllowed(&self, aPrincipal: *const nsIPrincipal, aPrefBranch: *const nsIPrefBranch, _retval: *mut bool) -> nsresult { ((*self.vtable).OfflineAppAllowed)(self, aPrincipal, aPrefBranch, _retval) } /// ```text /// /** /// * Checks whether a document at the given URI should have access /// * to the offline cache. /// * @param aURI /// * The URI to check /// * @param aPrefBranch /// * The pref branch to use to check the /// * offline-apps.allow_by_default pref. If not specified, /// * the pref service will be used. /// */ /// ``` /// /// `boolean offlineAppAllowedForURI (in nsIURI aURI, in nsIPrefBranch aPrefBranch);` #[inline] pub unsafe fn OfflineAppAllowedForURI(&self, aURI: *const nsIURI, aPrefBranch: *const nsIPrefBranch, _retval: *mut bool) -> nsresult { ((*self.vtable).OfflineAppAllowedForURI)(self, aURI, aPrefBranch, _retval) } /// ```text /// /** /// * Sets the "offline-app" permission for the principal. /// * In the single process model calls directly on permission manager. /// * In the multi process model dispatches to the parent process. /// */ /// ``` /// /// `void allowOfflineApp (in nsIPrincipal aPrincipal);` #[inline] pub unsafe fn AllowOfflineApp(&self, aPrincipal: *const nsIPrincipal) -> nsresult { ((*self.vtable).AllowOfflineApp)(self, aPrincipal) } }