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 #include "content/browser/in_process_webkit/indexed_db_context.h" | 5 #include "content/browser/in_process_webkit/indexed_db_context.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/task.h" | 12 #include "base/task.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "content/browser/browser_thread.h" | 14 #include "content/browser/browser_thread.h" |
15 #include "content/browser/in_process_webkit/indexed_db_quota_client.h" | 15 #include "content/browser/in_process_webkit/indexed_db_quota_client.h" |
16 #include "content/browser/in_process_webkit/webkit_context.h" | 16 #include "content/browser/in_process_webkit/webkit_context.h" |
17 #include "content/common/content_switches.h" | 17 #include "content/common/content_switches.h" |
18 #include "googleurl/src/gurl.h" | |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
24 #include "webkit/database/database_util.h" | 23 #include "webkit/database/database_util.h" |
25 #include "webkit/glue/webkit_glue.h" | 24 #include "webkit/glue/webkit_glue.h" |
26 #include "webkit/quota/quota_manager.h" | 25 #include "webkit/quota/quota_manager.h" |
27 #include "webkit/quota/special_storage_policy.h" | 26 #include "webkit/quota/special_storage_policy.h" |
28 | 27 |
29 using webkit_database::DatabaseUtil; | 28 using webkit_database::DatabaseUtil; |
30 using WebKit::WebIDBDatabase; | 29 using WebKit::WebIDBDatabase; |
31 using WebKit::WebIDBFactory; | 30 using WebKit::WebIDBFactory; |
32 using WebKit::WebSecurityOrigin; | 31 using WebKit::WebSecurityOrigin; |
33 | 32 |
34 namespace { | 33 namespace { |
35 | 34 |
35 void GetAllOriginsAndPaths( | |
36 const FilePath& indexeddb_path, | |
37 std::vector<GURL>* origins, | |
38 std::vector<FilePath>* file_paths) { | |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | |
40 if (indexeddb_path.empty()) | |
41 return; | |
42 file_util::FileEnumerator file_enumerator(indexeddb_path, | |
43 false, file_util::FileEnumerator::DIRECTORIES); | |
44 for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); | |
45 file_path = file_enumerator.Next()) { | |
46 if (file_path.Extension() == IndexedDBContext::kIndexedDBExtension) { | |
47 WebKit::WebString origin_id_webstring = | |
dgrogan
2011/08/24 22:20:37
We have to use the intermediate WebString because
michaeln
2011/08/25 01:20:04
I just moved this enum loop from the old instance
| |
48 webkit_glue::FilePathToWebString(file_path.BaseName()); | |
49 origins->push_back( | |
50 DatabaseUtil::GetOriginFromIdentifier(origin_id_webstring)); | |
51 if (file_paths) | |
52 file_paths->push_back(file_path); | |
53 } | |
54 } | |
55 } | |
56 | |
36 void ClearLocalState( | 57 void ClearLocalState( |
37 const FilePath& indexeddb_path, | 58 const FilePath& indexeddb_path, |
38 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) { | 59 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) { |
39 file_util::FileEnumerator file_enumerator( | 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
40 indexeddb_path, false, file_util::FileEnumerator::FILES); | 61 std::vector<GURL> origins; |
41 // TODO(pastarmovj): We might need to consider exchanging this loop for | 62 std::vector<FilePath> file_paths; |
42 // something more efficient in the future. | 63 GetAllOriginsAndPaths(indexeddb_path, &origins, &file_paths); |
43 for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); | 64 DCHECK_EQ(origins.size(), file_paths.size()); |
44 file_path = file_enumerator.Next()) { | 65 std::vector<FilePath>::const_iterator file_path_iter = file_paths.begin(); |
45 if (file_path.Extension() != IndexedDBContext::kIndexedDBExtension) | 66 for (std::vector<GURL>::const_iterator iter = origins.begin(); |
67 iter != origins.end(); ++iter, ++file_path_iter) { | |
68 if (special_storage_policy->IsStorageProtected(*iter)) | |
46 continue; | 69 continue; |
47 WebSecurityOrigin origin = | 70 file_util::Delete(*file_path_iter, true); |
48 WebSecurityOrigin::createFromDatabaseIdentifier( | |
49 webkit_glue::FilePathToWebString(file_path.BaseName())); | |
50 if (special_storage_policy->IsStorageProtected(GURL(origin.toString()))) | |
51 continue; | |
52 file_util::Delete(file_path, false); | |
53 } | 71 } |
54 } | 72 } |
55 | 73 |
56 } // namespace | 74 } // namespace |
57 | 75 |
58 const FilePath::CharType IndexedDBContext::kIndexedDBDirectory[] = | 76 const FilePath::CharType IndexedDBContext::kIndexedDBDirectory[] = |
59 FILE_PATH_LITERAL("IndexedDB"); | 77 FILE_PATH_LITERAL("IndexedDB"); |
60 | 78 |
61 const FilePath::CharType IndexedDBContext::kIndexedDBExtension[] = | 79 const FilePath::CharType IndexedDBContext::kIndexedDBExtension[] = |
62 FILE_PATH_LITERAL(".leveldb"); | 80 FILE_PATH_LITERAL(".leveldb"); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 }; | 115 }; |
98 | 116 |
99 IndexedDBContext::IndexedDBContext( | 117 IndexedDBContext::IndexedDBContext( |
100 WebKitContext* webkit_context, | 118 WebKitContext* webkit_context, |
101 quota::SpecialStoragePolicy* special_storage_policy, | 119 quota::SpecialStoragePolicy* special_storage_policy, |
102 quota::QuotaManagerProxy* quota_manager_proxy, | 120 quota::QuotaManagerProxy* quota_manager_proxy, |
103 base::MessageLoopProxy* webkit_thread_loop) | 121 base::MessageLoopProxy* webkit_thread_loop) |
104 : clear_local_state_on_exit_(false), | 122 : clear_local_state_on_exit_(false), |
105 special_storage_policy_(special_storage_policy), | 123 special_storage_policy_(special_storage_policy), |
106 quota_manager_proxy_(quota_manager_proxy) { | 124 quota_manager_proxy_(quota_manager_proxy) { |
107 data_path_ = webkit_context->data_path().Append(kIndexedDBDirectory); | 125 if (!webkit_context->is_incognito()) |
126 data_path_ = webkit_context->data_path().Append(kIndexedDBDirectory); | |
108 if (quota_manager_proxy && | 127 if (quota_manager_proxy && |
109 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { | 128 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { |
110 quota_manager_proxy->RegisterClient( | 129 quota_manager_proxy->RegisterClient( |
111 new IndexedDBQuotaClient(webkit_thread_loop, this)); | 130 new IndexedDBQuotaClient(webkit_thread_loop, this)); |
112 } | 131 } |
113 } | 132 } |
114 | 133 |
115 IndexedDBContext::~IndexedDBContext() { | 134 IndexedDBContext::~IndexedDBContext() { |
116 WebKit::WebIDBFactory* factory = idb_factory_.release(); | 135 WebKit::WebIDBFactory* factory = idb_factory_.release(); |
117 if (factory) | 136 if (factory) |
118 BrowserThread::DeleteSoon(BrowserThread::WEBKIT, FROM_HERE, factory); | 137 BrowserThread::DeleteSoon(BrowserThread::WEBKIT, FROM_HERE, factory); |
119 | 138 |
120 if (clear_local_state_on_exit_) { | 139 if (clear_local_state_on_exit_ && !data_path_.empty()) { |
121 // No WEBKIT thread here means we are running in a unit test where no clean | 140 // No WEBKIT thread here means we are running in a unit test where no clean |
122 // up is needed. | 141 // up is needed. |
123 BrowserThread::PostTask(BrowserThread::WEBKIT, FROM_HERE, | 142 BrowserThread::PostTask(BrowserThread::WEBKIT, FROM_HERE, |
124 NewRunnableFunction(&ClearLocalState, data_path_, | 143 NewRunnableFunction(&ClearLocalState, data_path_, |
125 special_storage_policy_)); | 144 special_storage_policy_)); |
126 } | 145 } |
127 } | 146 } |
128 | 147 |
129 WebIDBFactory* IndexedDBContext::GetIDBFactory() { | 148 WebIDBFactory* IndexedDBContext::GetIDBFactory() { |
130 if (!idb_factory_.get()) | 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
150 if (!idb_factory_.get()) { | |
151 GetOriginSet(); // Prime our cache of origins with existing databases. | |
131 idb_factory_.reset(WebIDBFactory::create()); | 152 idb_factory_.reset(WebIDBFactory::create()); |
153 } | |
132 DCHECK(idb_factory_.get()); | 154 DCHECK(idb_factory_.get()); |
133 return idb_factory_.get(); | 155 return idb_factory_.get(); |
134 } | 156 } |
135 | 157 |
136 FilePath IndexedDBContext::GetIndexedDBFilePath( | |
137 const string16& origin_id) const { | |
138 FilePath::StringType id = | |
139 webkit_glue::WebStringToFilePathString(origin_id).append( | |
140 FILE_PATH_LITERAL(".indexeddb")); | |
141 return data_path_.Append(id.append(kIndexedDBExtension)); | |
142 } | |
143 | |
144 // Note: This is not called in response to a UI action in Content Settings. Only | 158 // Note: This is not called in response to a UI action in Content Settings. Only |
dgrogan
2011/08/24 22:20:37
I think you can delete this comment now.
michaeln
2011/08/25 01:20:04
Done.
| |
145 // extension data deleter and quota manager currently call this. | 159 // extension data deleter and quota manager currently call this. |
146 void IndexedDBContext::DeleteIndexedDBForOrigin(const GURL& origin_url) { | 160 void IndexedDBContext::DeleteIndexedDBForOrigin(const GURL& origin_url) { |
147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
162 if (data_path_.empty() || !IsInOriginSet(origin_url)) | |
163 return; | |
148 string16 origin_id = DatabaseUtil::GetOriginIdentifier(origin_url); | 164 string16 origin_id = DatabaseUtil::GetOriginIdentifier(origin_url); |
149 FilePath idb_directory = GetIndexedDBFilePath(origin_id); | 165 FilePath idb_directory = GetIndexedDBFilePath(origin_id); |
150 if (idb_directory.BaseName().value().substr(0, strlen("chrome-extension")) == | 166 if (idb_directory.BaseName().value().substr(0, strlen("chrome-extension")) == |
151 FILE_PATH_LITERAL("chrome-extension") || | 167 FILE_PATH_LITERAL("chrome-extension") || |
152 connection_count_.find(origin_url) == connection_count_.end()) { | 168 connection_count_.find(origin_url) == connection_count_.end()) { |
153 EnsureDiskUsageCacheInitialized(origin_url); | 169 EnsureDiskUsageCacheInitialized(origin_url); |
154 file_util::Delete(idb_directory, true /*recursive*/); | 170 bool deleted = file_util::Delete(idb_directory, true /*recursive*/); |
155 QueryDiskAndUpdateQuotaUsage(origin_url); | 171 QueryDiskAndUpdateQuotaUsage(origin_url); |
172 if (deleted) { | |
173 RemoveFromOriginSet(origin_url); | |
174 origin_size_map_.erase(origin_url); | |
175 space_available_map_.erase(origin_url); | |
176 } | |
156 } | 177 } |
157 } | 178 } |
158 | 179 |
159 bool IndexedDBContext::IsUnlimitedStorageGranted( | 180 bool IndexedDBContext::IsUnlimitedStorageGranted( |
160 const GURL& origin) const { | 181 const GURL& origin) const { |
161 return special_storage_policy_->IsStorageUnlimited(origin); | 182 return special_storage_policy_->IsStorageUnlimited(origin); |
162 } | 183 } |
163 | 184 |
164 // TODO(dgrogan): Merge this code with the similar loop in | 185 void IndexedDBContext::GetAllOrigins(std::vector<GURL>* origins) { |
165 // BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread. | |
166 void IndexedDBContext::GetAllOriginIdentifiers( | |
167 std::vector<string16>* origin_ids) { | |
168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
169 file_util::FileEnumerator file_enumerator(data_path_, | 187 std::set<GURL>* origins_set = GetOriginSet(); |
170 false, file_util::FileEnumerator::DIRECTORIES); | 188 for (std::set<GURL>::const_iterator iter = origins_set->begin(); |
171 for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); | 189 iter != origins_set->end(); ++iter) { |
172 file_path = file_enumerator.Next()) { | 190 origins->push_back(*iter); |
173 if (file_path.Extension() == IndexedDBContext::kIndexedDBExtension) { | |
174 WebKit::WebString origin_id_webstring = | |
175 webkit_glue::FilePathToWebString(file_path.BaseName()); | |
176 origin_ids->push_back(origin_id_webstring); | |
177 } | |
178 } | 191 } |
179 } | 192 } |
180 | 193 |
181 int64 IndexedDBContext::GetOriginDiskUsage(const GURL& origin_url) { | 194 int64 IndexedDBContext::GetOriginDiskUsage(const GURL& origin_url) { |
182 return ResetDiskUsageCache(origin_url); | 195 if (data_path_.empty() || !IsInOriginSet(origin_url)) |
196 return 0; | |
197 EnsureDiskUsageCacheInitialized(origin_url); | |
198 return origin_size_map_[origin_url]; | |
199 } | |
200 | |
201 base::Time IndexedDBContext::GetOriginLastModified(const GURL& origin_url) { | |
202 if (data_path_.empty() || !IsInOriginSet(origin_url)) | |
203 return base::Time(); | |
204 string16 origin_id = DatabaseUtil::GetOriginIdentifier(origin_url); | |
205 FilePath idb_directory = GetIndexedDBFilePath(origin_id); | |
206 base::PlatformFileInfo file_info; | |
207 if (!file_util::GetFileInfo(idb_directory, &file_info)) | |
208 return base::Time(); | |
209 return file_info.last_modified; | |
183 } | 210 } |
184 | 211 |
185 void IndexedDBContext::ConnectionOpened(const GURL& origin_url) { | 212 void IndexedDBContext::ConnectionOpened(const GURL& origin_url) { |
186 if (quota_manager_proxy()) { | 213 if (quota_manager_proxy()) { |
187 quota_manager_proxy()->NotifyStorageAccessed( | 214 quota_manager_proxy()->NotifyStorageAccessed( |
188 quota::QuotaClient::kIndexedDatabase, origin_url, | 215 quota::QuotaClient::kIndexedDatabase, origin_url, |
189 quota::kStorageTypeTemporary); | 216 quota::kStorageTypeTemporary); |
190 } | 217 } |
191 connection_count_[origin_url]++; | 218 connection_count_[origin_url]++; |
219 if (AddToOriginSet(origin_url)) | |
220 QueryDiskAndUpdateQuotaUsage(origin_url); | |
221 else | |
222 EnsureDiskUsageCacheInitialized(origin_url); | |
192 QueryAvailableQuota(origin_url); | 223 QueryAvailableQuota(origin_url); |
193 EnsureDiskUsageCacheInitialized(origin_url); | |
194 } | 224 } |
195 | 225 |
196 void IndexedDBContext::ConnectionClosed(const GURL& origin_url) { | 226 void IndexedDBContext::ConnectionClosed(const GURL& origin_url) { |
197 DCHECK(connection_count_[origin_url] > 0); | 227 DCHECK(connection_count_[origin_url] > 0); |
198 if (quota_manager_proxy()) { | 228 if (quota_manager_proxy()) { |
199 quota_manager_proxy()->NotifyStorageAccessed( | 229 quota_manager_proxy()->NotifyStorageAccessed( |
200 quota::QuotaClient::kIndexedDatabase, origin_url, | 230 quota::QuotaClient::kIndexedDatabase, origin_url, |
201 quota::kStorageTypeTemporary); | 231 quota::kStorageTypeTemporary); |
202 } | 232 } |
203 connection_count_[origin_url]--; | 233 connection_count_[origin_url]--; |
204 if (connection_count_[origin_url] == 0) { | 234 if (connection_count_[origin_url] == 0) { |
205 QueryDiskAndUpdateQuotaUsage(origin_url); | 235 QueryDiskAndUpdateQuotaUsage(origin_url); |
206 connection_count_.erase(origin_url); | 236 connection_count_.erase(origin_url); |
207 } | 237 } |
208 } | 238 } |
209 | 239 |
210 void IndexedDBContext::TransactionComplete(const GURL& origin_url) { | 240 void IndexedDBContext::TransactionComplete(const GURL& origin_url) { |
211 DCHECK(connection_count_[origin_url] > 0); | 241 DCHECK(connection_count_[origin_url] > 0); |
212 QueryDiskAndUpdateQuotaUsage(origin_url); | 242 QueryDiskAndUpdateQuotaUsage(origin_url); |
213 QueryAvailableQuota(origin_url); | 243 QueryAvailableQuota(origin_url); |
214 } | 244 } |
215 | 245 |
246 FilePath IndexedDBContext::GetIndexedDBFilePath( | |
247 const string16& origin_id) const { | |
248 if (data_path_.empty()) | |
249 return FilePath(); | |
250 FilePath::StringType id = | |
251 webkit_glue::WebStringToFilePathString(origin_id).append( | |
252 FILE_PATH_LITERAL(".indexeddb")); | |
dgrogan
2011/08/24 22:20:37
While you're thinking about indexeddb clean up stu
michaeln
2011/08/25 01:20:04
Are you suggesting we change how the files are nam
dgrogan
2011/08/25 01:45:26
Just an option. But you're right, that'd be way o
| |
253 return data_path_.Append(id.append(kIndexedDBExtension)); | |
254 } | |
255 | |
216 bool IndexedDBContext::WouldBeOverQuota(const GURL& origin_url, | 256 bool IndexedDBContext::WouldBeOverQuota(const GURL& origin_url, |
217 int64 additional_bytes) { | 257 int64 additional_bytes) { |
218 if (space_available_map_.find(origin_url) == space_available_map_.end()) { | 258 if (space_available_map_.find(origin_url) == space_available_map_.end()) { |
219 // We haven't heard back from the QuotaManager yet, just let it through. | 259 // We haven't heard back from the QuotaManager yet, just let it through. |
220 return false; | 260 return false; |
221 } | 261 } |
222 bool over_quota = additional_bytes > space_available_map_[origin_url]; | 262 bool over_quota = additional_bytes > space_available_map_[origin_url]; |
223 return over_quota; | 263 return over_quota; |
224 } | 264 } |
225 | 265 |
226 bool IndexedDBContext::IsOverQuota(const GURL& origin_url) { | 266 bool IndexedDBContext::IsOverQuota(const GURL& origin_url) { |
227 const int kOneAdditionalByte = 1; | 267 const int kOneAdditionalByte = 1; |
228 return WouldBeOverQuota(origin_url, kOneAdditionalByte); | 268 return WouldBeOverQuota(origin_url, kOneAdditionalByte); |
229 } | 269 } |
230 | 270 |
231 quota::QuotaManagerProxy* IndexedDBContext::quota_manager_proxy() { | 271 quota::QuotaManagerProxy* IndexedDBContext::quota_manager_proxy() { |
232 return quota_manager_proxy_; | 272 return quota_manager_proxy_; |
233 } | 273 } |
234 | 274 |
235 int64 IndexedDBContext::ReadUsageFromDisk(const GURL& origin_url) const { | 275 int64 IndexedDBContext::ReadUsageFromDisk(const GURL& origin_url) const { |
236 string16 origin_id = DatabaseUtil::GetOriginIdentifier(origin_url); | 276 string16 origin_id = DatabaseUtil::GetOriginIdentifier(origin_url); |
237 FilePath file_path = GetIndexedDBFilePath(origin_id); | 277 FilePath file_path = GetIndexedDBFilePath(origin_id); |
238 return file_util::ComputeDirectorySize(file_path); | 278 return file_path.empty() ? 0 : file_util::ComputeDirectorySize(file_path); |
239 } | 279 } |
240 | 280 |
241 void IndexedDBContext::EnsureDiskUsageCacheInitialized(const GURL& origin_url) { | 281 void IndexedDBContext::EnsureDiskUsageCacheInitialized(const GURL& origin_url) { |
242 if (origin_size_map_.find(origin_url) == origin_size_map_.end()) | 282 if (origin_size_map_.find(origin_url) == origin_size_map_.end()) |
243 ResetDiskUsageCache(origin_url); | 283 origin_size_map_[origin_url] = ReadUsageFromDisk(origin_url); |
244 } | 284 } |
245 | 285 |
246 void IndexedDBContext::QueryDiskAndUpdateQuotaUsage(const GURL& origin_url) { | 286 void IndexedDBContext::QueryDiskAndUpdateQuotaUsage(const GURL& origin_url) { |
247 int64 former_disk_usage = origin_size_map_[origin_url]; | 287 int64 former_disk_usage = origin_size_map_[origin_url]; |
248 int64 current_disk_usage = ReadUsageFromDisk(origin_url); | 288 int64 current_disk_usage = ReadUsageFromDisk(origin_url); |
249 int64 difference = current_disk_usage - former_disk_usage; | 289 int64 difference = current_disk_usage - former_disk_usage; |
250 if (difference) { | 290 if (difference) { |
251 origin_size_map_[origin_url] = current_disk_usage; | 291 origin_size_map_[origin_url] = current_disk_usage; |
252 // quota_manager_proxy() is NULL in unit tests. | 292 // quota_manager_proxy() is NULL in unit tests. |
253 if (quota_manager_proxy()) | 293 if (quota_manager_proxy()) |
(...skipping 24 matching lines...) Expand all Loading... | |
278 if (!quota_manager_proxy()->quota_manager()) | 318 if (!quota_manager_proxy()->quota_manager()) |
279 return; | 319 return; |
280 IndexedDBGetUsageAndQuotaCallback* callback = | 320 IndexedDBGetUsageAndQuotaCallback* callback = |
281 new IndexedDBGetUsageAndQuotaCallback(this, origin_url); | 321 new IndexedDBGetUsageAndQuotaCallback(this, origin_url); |
282 quota_manager_proxy()->quota_manager()->GetUsageAndQuota( | 322 quota_manager_proxy()->quota_manager()->GetUsageAndQuota( |
283 origin_url, | 323 origin_url, |
284 quota::kStorageTypeTemporary, | 324 quota::kStorageTypeTemporary, |
285 callback); | 325 callback); |
286 } | 326 } |
287 | 327 |
288 int64 IndexedDBContext::ResetDiskUsageCache(const GURL& origin_url) { | 328 std::set<GURL>* IndexedDBContext::GetOriginSet() { |
289 origin_size_map_[origin_url] = ReadUsageFromDisk(origin_url); | 329 if (!origin_set_.get()) { |
290 return origin_size_map_[origin_url]; | 330 origin_set_.reset(new std::set<GURL>); |
331 std::vector<GURL> origins; | |
332 GetAllOriginsAndPaths(data_path_, &origins, NULL); | |
333 for (std::vector<GURL>::const_iterator iter = origins.begin(); | |
334 iter != origins.end(); ++iter) { | |
335 origin_set_->insert(*iter); | |
336 } | |
337 } | |
338 return origin_set_.get(); | |
291 } | 339 } |
340 | |
341 void IndexedDBContext::ResetCaches() { | |
342 origin_set_.reset(); | |
343 origin_size_map_.clear(); | |
344 space_available_map_.clear(); | |
345 } | |
OLD | NEW |