Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: content/browser/cache_storage/cache_storage_manager.h

Issue 1297093002: Cache Storage API: Hook up to chrome://settings/cookies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_
6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ 6 #define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "content/browser/cache_storage/cache_storage.h" 15 #include "content/browser/cache_storage/cache_storage.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/public/browser/cache_storage_context.h"
18 #include "content/public/browser/cache_storage_usage_info.h"
17 #include "net/url_request/url_request_context_getter.h" 19 #include "net/url_request/url_request_context_getter.h"
18 #include "storage/browser/quota/quota_client.h" 20 #include "storage/browser/quota/quota_client.h"
19 #include "url/gurl.h" 21 #include "url/gurl.h"
20 22
21 namespace base { 23 namespace base {
22 class SequencedTaskRunner; 24 class SequencedTaskRunner;
23 } 25 }
24 26
25 namespace storage { 27 namespace storage {
26 class BlobStorageContext; 28 class BlobStorageContext;
(...skipping 11 matching lines...) Expand all
38 class CONTENT_EXPORT CacheStorageManager { 40 class CONTENT_EXPORT CacheStorageManager {
39 public: 41 public:
40 static scoped_ptr<CacheStorageManager> Create( 42 static scoped_ptr<CacheStorageManager> Create(
41 const base::FilePath& path, 43 const base::FilePath& path,
42 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, 44 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner,
43 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy); 45 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy);
44 46
45 static scoped_ptr<CacheStorageManager> Create( 47 static scoped_ptr<CacheStorageManager> Create(
46 CacheStorageManager* old_manager); 48 CacheStorageManager* old_manager);
47 49
50 // Map a database identifier (computed from an origin) to the path.
51 static base::FilePath ConstructOriginPath(const base::FilePath& root_path,
52 const GURL& origin);
53
48 virtual ~CacheStorageManager(); 54 virtual ~CacheStorageManager();
49 55
50 // Methods to support the CacheStorage spec. These methods call the 56 // Methods to support the CacheStorage spec. These methods call the
51 // corresponding CacheStorage method on the appropriate thread. 57 // corresponding CacheStorage method on the appropriate thread.
52 void OpenCache(const GURL& origin, 58 void OpenCache(const GURL& origin,
53 const std::string& cache_name, 59 const std::string& cache_name,
54 const CacheStorage::CacheAndErrorCallback& callback); 60 const CacheStorage::CacheAndErrorCallback& callback);
55 void HasCache(const GURL& origin, 61 void HasCache(const GURL& origin,
56 const std::string& cache_name, 62 const std::string& cache_name,
57 const CacheStorage::BoolAndErrorCallback& callback); 63 const CacheStorage::BoolAndErrorCallback& callback);
(...skipping 14 matching lines...) Expand all
72 // above. 78 // above.
73 void SetBlobParametersForCache( 79 void SetBlobParametersForCache(
74 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, 80 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
75 base::WeakPtr<storage::BlobStorageContext> blob_storage_context); 81 base::WeakPtr<storage::BlobStorageContext> blob_storage_context);
76 82
77 base::WeakPtr<CacheStorageManager> AsWeakPtr() { 83 base::WeakPtr<CacheStorageManager> AsWeakPtr() {
78 return weak_ptr_factory_.GetWeakPtr(); 84 return weak_ptr_factory_.GetWeakPtr();
79 } 85 }
80 86
81 private: 87 private:
82 friend class CacheStorageQuotaClient; 88 friend class CacheStorageContextImpl;
83 friend class CacheStorageManagerTest; 89 friend class CacheStorageManagerTest;
84 friend class CacheStorageMigrationTest; 90 friend class CacheStorageMigrationTest;
91 friend class CacheStorageQuotaClient;
85 92
86 typedef std::map<GURL, CacheStorage*> CacheStorageMap; 93 typedef std::map<GURL, CacheStorage*> CacheStorageMap;
87 94
88 CacheStorageManager( 95 CacheStorageManager(
89 const base::FilePath& path, 96 const base::FilePath& path,
90 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner, 97 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner,
91 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy); 98 const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy);
92 99
93 // The returned CacheStorage* is owned by this manager. 100 // The returned CacheStorage* is owned by this manager.
94 CacheStorage* FindOrCreateCacheStorage(const GURL& origin); 101 CacheStorage* FindOrCreateCacheStorage(const GURL& origin);
95 102
96 // QuotaClient support 103 // QuotaClient and Browsing Data Deletion support
104 void GetAllOriginsUsage(
105 const CacheStorageContext::GetUsageInfoCallback& callback);
97 void GetOriginUsage(const GURL& origin_url, 106 void GetOriginUsage(const GURL& origin_url,
98 const storage::QuotaClient::GetUsageCallback& callback); 107 const storage::QuotaClient::GetUsageCallback& callback);
99 void GetOrigins(const storage::QuotaClient::GetOriginsCallback& callback); 108 void GetOrigins(const storage::QuotaClient::GetOriginsCallback& callback);
100 void GetOriginsForHost( 109 void GetOriginsForHost(
101 const std::string& host, 110 const std::string& host,
102 const storage::QuotaClient::GetOriginsCallback& callback); 111 const storage::QuotaClient::GetOriginsCallback& callback);
103 void DeleteOriginData(const GURL& origin, 112 void DeleteOriginData(const GURL& origin,
104 const storage::QuotaClient::DeletionCallback& callback); 113 const storage::QuotaClient::DeletionCallback& callback);
114 void DeleteOriginData(const GURL& origin);
105 static void DeleteOriginDidClose( 115 static void DeleteOriginDidClose(
106 const GURL& origin, 116 const GURL& origin,
107 const storage::QuotaClient::DeletionCallback& callback, 117 const storage::QuotaClient::DeletionCallback& callback,
108 scoped_ptr<CacheStorage> cache_storage, 118 scoped_ptr<CacheStorage> cache_storage,
109 base::WeakPtr<CacheStorageManager> cache_manager); 119 base::WeakPtr<CacheStorageManager> cache_manager);
110 120
111 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter() 121 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter()
112 const { 122 const {
113 return request_context_getter_; 123 return request_context_getter_;
114 } 124 }
115 base::WeakPtr<storage::BlobStorageContext> blob_storage_context() const { 125 base::WeakPtr<storage::BlobStorageContext> blob_storage_context() const {
116 return blob_context_; 126 return blob_context_;
117 } 127 }
118 base::FilePath root_path() const { return root_path_; } 128 base::FilePath root_path() const { return root_path_; }
119 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner() const { 129 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner() const {
120 return cache_task_runner_; 130 return cache_task_runner_;
121 } 131 }
122 132
123 bool IsMemoryBacked() const { return root_path_.empty(); } 133 bool IsMemoryBacked() const { return root_path_.empty(); }
124 134
125 // Map a origin to the path. Exposed for testing. 135 // Map a origin to the path. Exposed for testing.
126 static base::FilePath ConstructLegacyOriginPath( 136 static base::FilePath ConstructLegacyOriginPath(
127 const base::FilePath& root_path, 137 const base::FilePath& root_path,
128 const GURL& origin); 138 const GURL& origin);
129 // Map a database identifier (computed from an origin) to the path. Exposed
130 // for testing.
131 static base::FilePath ConstructOriginPath(const base::FilePath& root_path,
132 const GURL& origin);
133 139
134 // Migrate from old origin-based path to storage identifier-based path. 140 // Migrate from old origin-based path to storage identifier-based path.
135 // TODO(jsbell); Remove method and all calls after a few releases. 141 // TODO(jsbell); Remove method and all calls after a few releases.
136 void MigrateOrigin(const GURL& origin); 142 void MigrateOrigin(const GURL& origin);
137 static void MigrateOriginOnTaskRunner(const base::FilePath& old_path, 143 static void MigrateOriginOnTaskRunner(const base::FilePath& old_path,
138 const base::FilePath& new_path); 144 const base::FilePath& new_path);
139 145
140 base::FilePath root_path_; 146 base::FilePath root_path_;
141 scoped_refptr<base::SequencedTaskRunner> cache_task_runner_; 147 scoped_refptr<base::SequencedTaskRunner> cache_task_runner_;
142 148
143 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; 149 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_;
144 150
145 // The map owns the CacheStorages and the CacheStorages are only accessed on 151 // The map owns the CacheStorages and the CacheStorages are only accessed on
146 // |cache_task_runner_|. 152 // |cache_task_runner_|.
147 CacheStorageMap cache_storage_map_; 153 CacheStorageMap cache_storage_map_;
148 154
149 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 155 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
150 base::WeakPtr<storage::BlobStorageContext> blob_context_; 156 base::WeakPtr<storage::BlobStorageContext> blob_context_;
151 157
152 base::WeakPtrFactory<CacheStorageManager> weak_ptr_factory_; 158 base::WeakPtrFactory<CacheStorageManager> weak_ptr_factory_;
153 DISALLOW_COPY_AND_ASSIGN(CacheStorageManager); 159 DISALLOW_COPY_AND_ASSIGN(CacheStorageManager);
154 }; 160 };
155 161
156 } // namespace content 162 } // namespace content
157 163
158 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_ 164 #endif // CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698