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