|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef nsIOfflineStorage_h__ |
|
8 #define nsIOfflineStorage_h__ |
|
9 |
|
10 #include "nsIFileStorage.h" |
|
11 |
|
12 #include "mozilla/dom/quota/PersistenceType.h" |
|
13 |
|
14 #define NS_OFFLINESTORAGE_IID \ |
|
15 {0xec7e878d, 0xc8c1, 0x402e, \ |
|
16 { 0xa2, 0xc4, 0xf6, 0x82, 0x29, 0x4e, 0x3c, 0xb1 } } |
|
17 |
|
18 class nsPIDOMWindow; |
|
19 |
|
20 namespace mozilla { |
|
21 namespace dom { |
|
22 namespace quota { |
|
23 class Client; |
|
24 } |
|
25 } |
|
26 } |
|
27 |
|
28 class nsIOfflineStorage : public nsIFileStorage |
|
29 { |
|
30 public: |
|
31 typedef mozilla::dom::quota::Client Client; |
|
32 typedef mozilla::dom::quota::PersistenceType PersistenceType; |
|
33 |
|
34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_OFFLINESTORAGE_IID) |
|
35 |
|
36 NS_IMETHOD_(Client*) |
|
37 GetClient() = 0; |
|
38 |
|
39 NS_IMETHOD_(bool) |
|
40 IsOwned(nsPIDOMWindow* aOwner) = 0; |
|
41 |
|
42 NS_IMETHOD_(PersistenceType) |
|
43 Type() |
|
44 { |
|
45 return mPersistenceType; |
|
46 } |
|
47 |
|
48 NS_IMETHOD_(const nsACString&) |
|
49 Group() |
|
50 { |
|
51 return mGroup; |
|
52 } |
|
53 |
|
54 NS_IMETHOD_(const nsACString&) |
|
55 Origin() = 0; |
|
56 |
|
57 // Implementation of this method should close the storage (without aborting |
|
58 // running operations nor discarding pending operations). |
|
59 NS_IMETHOD_(nsresult) |
|
60 Close() = 0; |
|
61 |
|
62 // Whether or not the storage has had Close called on it. |
|
63 NS_IMETHOD_(bool) |
|
64 IsClosed() = 0; |
|
65 |
|
66 // Implementation of this method should close the storage, all running |
|
67 // operations should be aborted and pending operations should be discarded. |
|
68 NS_IMETHOD_(void) |
|
69 Invalidate() = 0; |
|
70 |
|
71 protected: |
|
72 nsIOfflineStorage() |
|
73 : mPersistenceType(mozilla::dom::quota::PERSISTENCE_TYPE_INVALID) |
|
74 { } |
|
75 |
|
76 virtual ~nsIOfflineStorage() |
|
77 { } |
|
78 |
|
79 PersistenceType mPersistenceType; |
|
80 nsCString mGroup; |
|
81 }; |
|
82 |
|
83 NS_DEFINE_STATIC_IID_ACCESSOR(nsIOfflineStorage, NS_OFFLINESTORAGE_IID) |
|
84 |
|
85 #define NS_DECL_NSIOFFLINESTORAGE \ |
|
86 NS_IMETHOD_(Client*) \ |
|
87 GetClient() MOZ_OVERRIDE; \ |
|
88 \ |
|
89 NS_IMETHOD_(bool) \ |
|
90 IsOwned(nsPIDOMWindow* aOwner) MOZ_OVERRIDE; \ |
|
91 \ |
|
92 NS_IMETHOD_(const nsACString&) \ |
|
93 Origin() MOZ_OVERRIDE; \ |
|
94 \ |
|
95 NS_IMETHOD_(nsresult) \ |
|
96 Close() MOZ_OVERRIDE; \ |
|
97 \ |
|
98 NS_IMETHOD_(bool) \ |
|
99 IsClosed() MOZ_OVERRIDE; \ |
|
100 \ |
|
101 NS_IMETHOD_(void) \ |
|
102 Invalidate() MOZ_OVERRIDE; |
|
103 |
|
104 #endif // nsIOfflineStorage_h__ |