| 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/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // semantics since a browser context has multiple URLRequestContexts which refer | 28 // semantics since a browser context has multiple URLRequestContexts which refer |
| 29 // to the same object, and those URLRequestContexts are refcounted independently | 29 // to the same object, and those URLRequestContexts are refcounted independently |
| 30 // of the owning browser context. | 30 // of the owning browser context. |
| 31 // | 31 // |
| 32 // All methods, except the ctor, are expected to be called on | 32 // All methods, except the ctor, are expected to be called on |
| 33 // the IO thread (unless specifically called out in doc comments). | 33 // the IO thread (unless specifically called out in doc comments). |
| 34 // | 34 // |
| 35 // TODO(dpranke): Fix dependencies on AppCacheService so that we don't have | 35 // TODO(dpranke): Fix dependencies on AppCacheService so that we don't have |
| 36 // to worry about clients calling AppCacheService methods. | 36 // to worry about clients calling AppCacheService methods. |
| 37 class CONTENT_EXPORT ChromeAppCacheService | 37 class CONTENT_EXPORT ChromeAppCacheService |
| 38 : public base::RefCountedThreadSafe< | 38 : public base::RefCountedThreadSafe<ChromeAppCacheService, |
| 39 ChromeAppCacheService, ChromeAppCacheServiceDeleter>, | 39 ChromeAppCacheServiceDeleter>, |
| 40 NON_EXPORTED_BASE(public appcache::AppCacheService), | 40 NON_EXPORTED_BASE(public appcache::AppCacheService), |
| 41 NON_EXPORTED_BASE(public appcache::AppCachePolicy) { | 41 NON_EXPORTED_BASE(public appcache::AppCachePolicy) { |
| 42 public: | 42 public: |
| 43 explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy); | 43 explicit ChromeAppCacheService(quota::QuotaManagerProxy* proxy); |
| 44 virtual ~ChromeAppCacheService(); | |
| 45 | 44 |
| 46 void InitializeOnIOThread( | 45 void InitializeOnIOThread( |
| 47 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 |
| 48 content::ResourceContext* resource_context, | 47 content::ResourceContext* resource_context, |
| 49 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); | 48 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); |
| 50 | 49 |
| 51 private: | |
| 52 friend struct ChromeAppCacheServiceDeleter; | |
| 53 | |
| 54 void DeleteOnCorrectThread() const; | |
| 55 | |
| 56 // AppCachePolicy overrides | 50 // AppCachePolicy overrides |
| 57 virtual bool CanLoadAppCache(const GURL& manifest_url, | 51 virtual bool CanLoadAppCache(const GURL& manifest_url, |
| 58 const GURL& first_party) OVERRIDE; | 52 const GURL& first_party) OVERRIDE; |
| 59 virtual bool CanCreateAppCache(const GURL& manifest_url, | 53 virtual bool CanCreateAppCache(const GURL& manifest_url, |
| 60 const GURL& first_party) OVERRIDE; | 54 const GURL& first_party) OVERRIDE; |
| 61 | 55 |
| 56 protected: |
| 57 virtual ~ChromeAppCacheService(); |
| 58 |
| 59 private: |
| 60 friend class base::DeleteHelper<ChromeAppCacheService>; |
| 61 friend class base::RefCountedThreadSafe<ChromeAppCacheService, |
| 62 ChromeAppCacheServiceDeleter>; |
| 63 friend struct ChromeAppCacheServiceDeleter; |
| 64 |
| 65 void DeleteOnCorrectThread() const; |
| 66 |
| 62 content::ResourceContext* resource_context_; | 67 content::ResourceContext* resource_context_; |
| 63 FilePath cache_path_; | 68 FilePath cache_path_; |
| 64 | 69 |
| 65 DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService); | 70 DISALLOW_COPY_AND_ASSIGN(ChromeAppCacheService); |
| 66 }; | 71 }; |
| 67 | 72 |
| 68 struct ChromeAppCacheServiceDeleter { | 73 struct ChromeAppCacheServiceDeleter { |
| 69 static void Destruct(const ChromeAppCacheService* service) { | 74 static void Destruct(const ChromeAppCacheService* service) { |
| 70 service->DeleteOnCorrectThread(); | 75 service->DeleteOnCorrectThread(); |
| 71 } | 76 } |
| 72 }; | 77 }; |
| 73 | 78 |
| 74 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ | 79 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ |
| OLD | NEW |