OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ |
6 #define CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ | 6 #define CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
11 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
| 11 #include "content/common/notification_observer.h" |
12 #include "content/common/notification_registrar.h" | 12 #include "content/common/notification_registrar.h" |
13 #include "webkit/appcache/appcache_policy.h" | 13 #include "webkit/appcache/appcache_policy.h" |
14 #include "webkit/appcache/appcache_service.h" | 14 #include "webkit/appcache/appcache_service.h" |
15 #include "webkit/quota/special_storage_policy.h" | 15 #include "webkit/quota/special_storage_policy.h" |
16 | 16 |
17 class FilePath; | 17 class FilePath; |
18 | 18 |
| 19 namespace content { |
| 20 class ResourceContext; |
| 21 } |
| 22 |
19 // An AppCacheService subclass used by the chrome. There is an instance | 23 // An AppCacheService subclass used by the chrome. There is an instance |
20 // associated with each Profile. This derivation adds refcounting semantics | 24 // associated with each Profile. This derivation adds refcounting semantics |
21 // since a profile has multiple URLRequestContexts which refer to the same | 25 // since a profile has multiple URLRequestContexts which refer to the same |
22 // object, and those URLRequestContexts are refcounted independently of the | 26 // object, and those URLRequestContexts are refcounted independently of the |
23 // owning profile. | 27 // owning profile. |
24 // | 28 // |
25 // All methods, except the ctor, are expected to be called on | 29 // All methods, except the ctor, are expected to be called on |
26 // the IO thread (unless specifically called out in doc comments). | 30 // the IO thread (unless specifically called out in doc comments). |
27 class ChromeAppCacheService | 31 class ChromeAppCacheService |
28 : public base::RefCountedThreadSafe<ChromeAppCacheService, | 32 : public base::RefCountedThreadSafe<ChromeAppCacheService, |
29 BrowserThread::DeleteOnIOThread>, | 33 BrowserThread::DeleteOnIOThread>, |
30 public appcache::AppCacheService, | 34 public appcache::AppCacheService, |
31 public appcache::AppCachePolicy, | 35 public appcache::AppCachePolicy, |
32 public NotificationObserver { | 36 public NotificationObserver { |
33 public: | 37 public: |
34 ChromeAppCacheService(); | 38 ChromeAppCacheService(); |
35 | 39 |
36 void InitializeOnIOThread( | 40 void InitializeOnIOThread( |
37 const FilePath& cache_path, // may be empty to use in-memory structures | 41 const FilePath& cache_path, // may be empty to use in-memory structures |
38 scoped_refptr<HostContentSettingsMap> content_settings_map, | 42 const content::ResourceContext* resource_context, |
39 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, | 43 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, |
40 bool clear_local_state_on_exit); | 44 bool clear_local_state_on_exit); |
41 | 45 |
42 void SetClearLocalStateOnExit(bool clear_local_state); | 46 void SetClearLocalStateOnExit(bool clear_local_state); |
43 | 47 |
44 private: | 48 private: |
45 friend class BrowserThread; | 49 friend class BrowserThread; |
46 friend class DeleteTask<ChromeAppCacheService>; | 50 friend class DeleteTask<ChromeAppCacheService>; |
47 | 51 |
48 virtual ~ChromeAppCacheService(); | 52 virtual ~ChromeAppCacheService(); |
49 | 53 |
50 // AppCachePolicy overrides | 54 // AppCachePolicy overrides |
51 virtual bool CanLoadAppCache(const GURL& manifest_url); | 55 virtual bool CanLoadAppCache(const GURL& manifest_url); |
52 virtual int CanCreateAppCache(const GURL& manifest_url, | 56 virtual int CanCreateAppCache(const GURL& manifest_url, |
53 net::CompletionCallback* callback); | 57 net::CompletionCallback* callback); |
54 | 58 |
55 // NotificationObserver override | 59 // NotificationObserver override |
56 virtual void Observe(NotificationType type, | 60 virtual void Observe(NotificationType type, |
57 const NotificationSource& source, | 61 const NotificationSource& source, |
58 const NotificationDetails& details); | 62 const NotificationDetails& details); |
59 | 63 |
60 scoped_refptr<HostContentSettingsMap> host_contents_settings_map_; | 64 const content::ResourceContext* resource_context_; |
61 NotificationRegistrar registrar_; | 65 NotificationRegistrar registrar_; |
62 bool clear_local_state_on_exit_; | 66 bool clear_local_state_on_exit_; |
63 FilePath cache_path_; | 67 FilePath cache_path_; |
64 | 68 |
65 DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService); | 69 DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService); |
66 }; | 70 }; |
67 | 71 |
68 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ | 72 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ |
OLD | NEW |