OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_APPCACHE_SERVICE_H_ |
6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_APPCACHE_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "webkit/browser/webkit_storage_browser_export.h" | 13 #include "content/common/content_export.h" |
14 #include "webkit/common/appcache/appcache_interfaces.h" | 14 #include "content/public/common/appcache_info.h" |
| 15 #include "net/base/completion_callback.h" |
15 | 16 |
16 namespace appcache { | 17 namespace content { |
17 | 18 |
18 class AppCacheStorage; | 19 class AppCacheStorage; |
19 | 20 |
20 // Refcounted container to avoid copying the collection in callbacks. | 21 // Refcounted container to avoid copying the collection in callbacks. |
21 struct WEBKIT_STORAGE_BROWSER_EXPORT AppCacheInfoCollection | 22 struct CONTENT_EXPORT AppCacheInfoCollection |
22 : public base::RefCountedThreadSafe<AppCacheInfoCollection> { | 23 : public base::RefCountedThreadSafe<AppCacheInfoCollection> { |
23 AppCacheInfoCollection(); | 24 AppCacheInfoCollection(); |
24 | 25 |
25 std::map<GURL, AppCacheInfoVector> infos_by_origin; | 26 std::map<GURL, AppCacheInfoVector> infos_by_origin; |
26 | 27 |
27 private: | 28 private: |
28 friend class base::RefCountedThreadSafe<AppCacheInfoCollection>; | 29 friend class base::RefCountedThreadSafe<AppCacheInfoCollection>; |
29 virtual ~AppCacheInfoCollection(); | 30 virtual ~AppCacheInfoCollection(); |
30 }; | 31 }; |
31 | 32 |
32 // Class that manages the application cache service. Sends notifications | 33 // Exposes a limited interface to the AppCacheService. |
33 // to many frontends. One instance per user-profile. Each instance has | 34 // Call these methods only on the IO thread. |
34 // exclusive access to its cache_directory on disk. | 35 class CONTENT_EXPORT AppCacheService { |
35 class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheService { | |
36 public: | 36 public: |
37 virtual ~AppCacheService() { } | |
38 | |
39 // Determines if a request for 'url' can be satisfied while offline. | 37 // Determines if a request for 'url' can be satisfied while offline. |
40 // This method always completes asynchronously. | 38 // This method always completes asynchronously. |
41 virtual void CanHandleMainResourceOffline(const GURL& url, | 39 virtual void CanHandleMainResourceOffline(const GURL& url, |
42 const GURL& first_party, | 40 const GURL& first_party, |
43 const net::CompletionCallback& | 41 const net::CompletionCallback& |
44 callback) = 0; | 42 callback) = 0; |
45 | 43 |
46 // Populates 'collection' with info about all of the appcaches stored | 44 // Populates 'collection' with info about all of the appcaches stored |
47 // within the service, 'callback' is invoked upon completion. The service | 45 // within the service, 'callback' is invoked upon completion. The service |
48 // acquires a reference to the 'collection' until until completion. | 46 // acquires a reference to the 'collection' until until completion. |
49 // This method always completes asynchronously. | 47 // This method always completes asynchronously. |
50 virtual void GetAllAppCacheInfo(AppCacheInfoCollection* collection, | 48 virtual void GetAllAppCacheInfo(AppCacheInfoCollection* collection, |
51 const net::CompletionCallback& callback) = 0; | 49 const net::CompletionCallback& callback) = 0; |
52 | 50 |
53 // Deletes the group identified by 'manifest_url', 'callback' is | 51 // Deletes the group identified by 'manifest_url', 'callback' is |
54 // invoked upon completion. Upon completion, the cache group and | 52 // invoked upon completion. Upon completion, the cache group and |
55 // any resources within the group are no longer loadable and all | 53 // any resources within the group are no longer loadable and all |
56 // subresource loads for pages associated with a deleted group | 54 // subresource loads for pages associated with a deleted group |
57 // will fail. This method always completes asynchronously. | 55 // will fail. This method always completes asynchronously. |
58 virtual void DeleteAppCacheGroup(const GURL& manifest_url, | 56 virtual void DeleteAppCacheGroup(const GURL& manifest_url, |
59 const net::CompletionCallback& callback) = 0; | 57 const net::CompletionCallback& callback) = 0; |
| 58 |
| 59 protected: |
| 60 virtual ~AppCacheService() {} |
60 }; | 61 }; |
61 | 62 |
62 } // namespace appcache | 63 } // namespace content |
63 | 64 |
64 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_H_ | 65 #endif // CONTENT_PUBLIC_BROWSER_APPCACHE_SERVICE_H_ |
OLD | NEW |