| 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/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 10 #include "content/browser/browser_thread.h" | 11 #include "content/browser/browser_thread.h" |
| 12 #include "content/common/content_export.h" |
| 11 #include "content/common/notification_observer.h" | 13 #include "content/common/notification_observer.h" |
| 12 #include "content/common/notification_registrar.h" | 14 #include "content/common/notification_registrar.h" |
| 13 #include "webkit/appcache/appcache_policy.h" | 15 #include "webkit/appcache/appcache_policy.h" |
| 14 #include "webkit/appcache/appcache_service.h" | 16 #include "webkit/appcache/appcache_service.h" |
| 15 #include "webkit/quota/special_storage_policy.h" | 17 #include "webkit/quota/special_storage_policy.h" |
| 16 | 18 |
| 17 class FilePath; | 19 class FilePath; |
| 18 | 20 |
| 19 namespace content { | 21 namespace content { |
| 20 class ResourceContext; | 22 class ResourceContext; |
| 21 } | 23 } |
| 22 | 24 |
| 23 // An AppCacheService subclass used by the chrome. There is an instance | 25 // An AppCacheService subclass used by the chrome. There is an instance |
| 24 // associated with each BrowserContext. This derivation adds refcounting | 26 // associated with each BrowserContext. This derivation adds refcounting |
| 25 // semantics since a browser context has multiple URLRequestContexts which refer | 27 // semantics since a browser context has multiple URLRequestContexts which refer |
| 26 // to the same object, and those URLRequestContexts are refcounted independently | 28 // to the same object, and those URLRequestContexts are refcounted independently |
| 27 // of the owning browser context. | 29 // of the owning browser context. |
| 28 // | 30 // |
| 29 // All methods, except the ctor, are expected to be called on | 31 // All methods, except the ctor, are expected to be called on |
| 30 // the IO thread (unless specifically called out in doc comments). | 32 // the IO thread (unless specifically called out in doc comments). |
| 31 class ChromeAppCacheService | 33 // |
| 34 // TODO(dpranke): Fix dependencies on AppCacheService so that we don't have |
| 35 // to worry about clients calling AppCacheService methods. |
| 36 class CONTENT_EXPORT ChromeAppCacheService |
| 32 : public base::RefCountedThreadSafe<ChromeAppCacheService, | 37 : public base::RefCountedThreadSafe<ChromeAppCacheService, |
| 33 BrowserThread::DeleteOnIOThread>, | 38 BrowserThread::DeleteOnIOThread>, |
| 34 public appcache::AppCacheService, | 39 NON_EXPORTED_BASE(public appcache::AppCacheService), |
| 35 public appcache::AppCachePolicy, | 40 NON_EXPORTED_BASE(public appcache::AppCachePolicy), |
| 36 public NotificationObserver { | 41 public NotificationObserver { |
| 37 public: | 42 public: |
| 38 explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy); | 43 explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy); |
| 39 | 44 |
| 40 void InitializeOnIOThread( | 45 void InitializeOnIOThread( |
| 41 const FilePath& cache_path, // may be empty to use in-memory structures | 46 const FilePath& cache_path, // may be empty to use in-memory structures |
| 42 const content::ResourceContext* resource_context, | 47 const content::ResourceContext* resource_context, |
| 43 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); | 48 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); |
| 44 | 49 |
| 45 private: | 50 private: |
| 51 friend class base::RefCountedThreadSafe<ChromeAppCacheService, |
| 52 BrowserThread::DeleteOnIOThread>; |
| 46 friend class BrowserThread; | 53 friend class BrowserThread; |
| 47 friend class DeleteTask<ChromeAppCacheService>; | 54 friend class DeleteTask<ChromeAppCacheService>; |
| 48 | 55 |
| 49 virtual ~ChromeAppCacheService(); | 56 virtual ~ChromeAppCacheService(); |
| 50 | 57 |
| 51 // AppCachePolicy overrides | 58 // AppCachePolicy overrides |
| 52 virtual bool CanLoadAppCache(const GURL& manifest_url, | 59 virtual bool CanLoadAppCache(const GURL& manifest_url, |
| 53 const GURL& first_party); | 60 const GURL& first_party); |
| 54 virtual bool CanCreateAppCache(const GURL& manifest_url, | 61 virtual bool CanCreateAppCache(const GURL& manifest_url, |
| 55 const GURL& first_party); | 62 const GURL& first_party); |
| 56 | 63 |
| 57 // NotificationObserver override | 64 // NotificationObserver override |
| 58 virtual void Observe(int type, | 65 virtual void Observe(int type, |
| 59 const NotificationSource& source, | 66 const NotificationSource& source, |
| 60 const NotificationDetails& details); | 67 const NotificationDetails& details); |
| 61 | 68 |
| 62 const content::ResourceContext* resource_context_; | 69 const content::ResourceContext* resource_context_; |
| 63 NotificationRegistrar registrar_; | 70 NotificationRegistrar registrar_; |
| 64 FilePath cache_path_; | 71 FilePath cache_path_; |
| 65 | 72 |
| 66 DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService); | 73 DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService); |
| 67 }; | 74 }; |
| 68 | 75 |
| 69 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ | 76 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ |
| OLD | NEW |