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

Side by Side Diff: content/browser/indexed_db/indexed_db_context_impl.cc

Issue 17518004: Move IndexedDB from WEBKIT_DEPRECATED to dedicated thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing files Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/indexed_db/indexed_db_context_impl.h" 5 #include "content/browser/indexed_db/indexed_db_context_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_enumerator.h" 12 #include "base/files/file_enumerator.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop/message_loop_proxy.h" 14 #include "base/message_loop/message_loop_proxy.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/thread_restrictions.h"
18 #include "content/browser/browser_main_loop.h"
17 #include "content/browser/indexed_db/indexed_db_quota_client.h" 19 #include "content/browser/indexed_db/indexed_db_quota_client.h"
18 #include "content/browser/indexed_db/webidbdatabase_impl.h" 20 #include "content/browser/indexed_db/webidbdatabase_impl.h"
19 #include "content/browser/indexed_db/webidbfactory_impl.h" 21 #include "content/browser/indexed_db/webidbfactory_impl.h"
20 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/indexed_db_info.h" 23 #include "content/public/browser/indexed_db_info.h"
22 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
23 #include "third_party/WebKit/public/platform/WebString.h" 25 #include "third_party/WebKit/public/platform/WebString.h"
24 #include "webkit/base/file_path_string_conversions.h" 26 #include "webkit/base/file_path_string_conversions.h"
25 #include "webkit/browser/database/database_util.h" 27 #include "webkit/browser/database/database_util.h"
26 #include "webkit/browser/quota/quota_manager.h" 28 #include "webkit/browser/quota/quota_manager.h"
27 #include "webkit/browser/quota/special_storage_policy.h" 29 #include "webkit/browser/quota/special_storage_policy.h"
28 #include "webkit/common/database/database_identifier.h" 30 #include "webkit/common/database/database_identifier.h"
29 31
30 using webkit_database::DatabaseUtil; 32 using webkit_database::DatabaseUtil;
31 33
32 namespace content { 34 namespace content {
33 const base::FilePath::CharType IndexedDBContextImpl::kIndexedDBDirectory[] = 35 const base::FilePath::CharType IndexedDBContextImpl::kIndexedDBDirectory[] =
34 FILE_PATH_LITERAL("IndexedDB"); 36 FILE_PATH_LITERAL("IndexedDB");
35 37
36 static const base::FilePath::CharType kIndexedDBExtension[] = 38 static const base::FilePath::CharType kIndexedDBExtension[] =
37 FILE_PATH_LITERAL(".indexeddb"); 39 FILE_PATH_LITERAL(".indexeddb");
38 40
39 static const base::FilePath::CharType kLevelDBExtension[] = 41 static const base::FilePath::CharType kLevelDBExtension[] =
40 FILE_PATH_LITERAL(".leveldb"); 42 FILE_PATH_LITERAL(".leveldb");
41 43
42 namespace { 44 namespace {
43 45
46 // This may be called after the IndexedDBContext is destroyed.
44 void GetAllOriginsAndPaths(const base::FilePath& indexeddb_path, 47 void GetAllOriginsAndPaths(const base::FilePath& indexeddb_path,
45 std::vector<GURL>* origins, 48 std::vector<GURL>* origins,
46 std::vector<base::FilePath>* file_paths) { 49 std::vector<base::FilePath>* file_paths) {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 50 // TODO(jsbell): DCHECK that this is running on an IndexedDB thread,
51 // if a global handle to it is ever available.
48 if (indexeddb_path.empty()) 52 if (indexeddb_path.empty())
49 return; 53 return;
50 base::FileEnumerator file_enumerator( 54 base::FileEnumerator file_enumerator(
51 indexeddb_path, false, base::FileEnumerator::DIRECTORIES); 55 indexeddb_path, false, base::FileEnumerator::DIRECTORIES);
52 for (base::FilePath file_path = file_enumerator.Next(); !file_path.empty(); 56 for (base::FilePath file_path = file_enumerator.Next(); !file_path.empty();
53 file_path = file_enumerator.Next()) { 57 file_path = file_enumerator.Next()) {
54 if (file_path.Extension() == kLevelDBExtension && 58 if (file_path.Extension() == kLevelDBExtension &&
55 file_path.RemoveExtension().Extension() == kIndexedDBExtension) { 59 file_path.RemoveExtension().Extension() == kIndexedDBExtension) {
56 std::string origin_id = file_path.BaseName().RemoveExtension() 60 std::string origin_id = file_path.BaseName().RemoveExtension()
57 .RemoveExtension().MaybeAsASCII(); 61 .RemoveExtension().MaybeAsASCII();
58 origins->push_back(webkit_database::GetOriginFromIdentifier(origin_id)); 62 origins->push_back(webkit_database::GetOriginFromIdentifier(origin_id));
59 if (file_paths) 63 if (file_paths)
60 file_paths->push_back(file_path); 64 file_paths->push_back(file_path);
61 } 65 }
62 } 66 }
63 } 67 }
64 68
65 // Deletes session-only databases. 69 // This will be called after the IndexedDBContext is destroyed.
66 void ClearSessionOnlyOrigins( 70 void ClearSessionOnlyOrigins(
67 const base::FilePath& indexeddb_path, 71 const base::FilePath& indexeddb_path,
68 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) { 72 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) {
69 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 73 // TODO(jsbell): DCHECK that this is running on an IndexedDB thread,
74 // if a global handle to it is ever available.
70 std::vector<GURL> origins; 75 std::vector<GURL> origins;
71 std::vector<base::FilePath> file_paths; 76 std::vector<base::FilePath> file_paths;
72 GetAllOriginsAndPaths(indexeddb_path, &origins, &file_paths); 77 GetAllOriginsAndPaths(indexeddb_path, &origins, &file_paths);
73 DCHECK_EQ(origins.size(), file_paths.size()); 78 DCHECK_EQ(origins.size(), file_paths.size());
74 std::vector<base::FilePath>::const_iterator file_path_iter = 79 std::vector<base::FilePath>::const_iterator file_path_iter =
75 file_paths.begin(); 80 file_paths.begin();
76 for (std::vector<GURL>::const_iterator iter = origins.begin(); 81 for (std::vector<GURL>::const_iterator iter = origins.begin();
77 iter != origins.end(); 82 iter != origins.end();
78 ++iter, ++file_path_iter) { 83 ++iter, ++file_path_iter) {
79 if (!special_storage_policy->IsStorageSessionOnly(*iter)) 84 if (!special_storage_policy->IsStorageSessionOnly(*iter))
80 continue; 85 continue;
81 if (special_storage_policy->IsStorageProtected(*iter)) 86 if (special_storage_policy->IsStorageProtected(*iter))
82 continue; 87 continue;
83 file_util::Delete(*file_path_iter, true); 88 file_util::Delete(*file_path_iter, true);
84 } 89 }
85 } 90 }
86 91
87 } // namespace 92 } // namespace
88 93
94
89 IndexedDBContextImpl::IndexedDBContextImpl( 95 IndexedDBContextImpl::IndexedDBContextImpl(
90 const base::FilePath& data_path, 96 const base::FilePath& data_path,
91 quota::SpecialStoragePolicy* special_storage_policy, 97 quota::SpecialStoragePolicy* special_storage_policy,
92 quota::QuotaManagerProxy* quota_manager_proxy, 98 quota::QuotaManagerProxy* quota_manager_proxy,
93 base::MessageLoopProxy* webkit_thread_loop) 99 base::MessageLoop* message_loop)
94 : force_keep_session_state_(false), 100 : force_keep_session_state_(false),
95 special_storage_policy_(special_storage_policy), 101 special_storage_policy_(special_storage_policy),
96 quota_manager_proxy_(quota_manager_proxy) { 102 quota_manager_proxy_(quota_manager_proxy),
103 message_loop_(message_loop) {
97 if (!data_path.empty()) 104 if (!data_path.empty())
98 data_path_ = data_path.Append(kIndexedDBDirectory); 105 data_path_ = data_path.Append(kIndexedDBDirectory);
99 if (quota_manager_proxy && 106 if (quota_manager_proxy &&
100 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) { 107 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) {
101 quota_manager_proxy->RegisterClient( 108 quota_manager_proxy->RegisterClient(new IndexedDBQuotaClient(this));
102 new IndexedDBQuotaClient(webkit_thread_loop, this));
103 } 109 }
104 } 110 }
105 111
106 WebIDBFactoryImpl* IndexedDBContextImpl::GetIDBFactory() { 112 WebIDBFactoryImpl* IndexedDBContextImpl::GetIDBFactory() {
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 113 DCHECK(OnIndexedDBThread());
108 if (!idb_factory_) { 114 if (!idb_factory_) {
109 // Prime our cache of origins with existing databases so we can 115 // Prime our cache of origins with existing databases so we can
110 // detect when dbs are newly created. 116 // detect when dbs are newly created.
111 GetOriginSet(); 117 GetOriginSet();
112 idb_factory_.reset(new content::WebIDBFactoryImpl()); 118 idb_factory_.reset(new content::WebIDBFactoryImpl());
113 } 119 }
114 return idb_factory_.get(); 120 return idb_factory_.get();
115 } 121 }
116 122
117 std::vector<GURL> IndexedDBContextImpl::GetAllOrigins() { 123 std::vector<GURL> IndexedDBContextImpl::GetAllOrigins() {
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 124 DCHECK(OnIndexedDBThread());
119 std::vector<GURL> origins; 125 std::vector<GURL> origins;
120 std::set<GURL>* origins_set = GetOriginSet(); 126 std::set<GURL>* origins_set = GetOriginSet();
121 for (std::set<GURL>::const_iterator iter = origins_set->begin(); 127 for (std::set<GURL>::const_iterator iter = origins_set->begin();
122 iter != origins_set->end(); 128 iter != origins_set->end();
123 ++iter) { 129 ++iter) {
124 origins.push_back(*iter); 130 origins.push_back(*iter);
125 } 131 }
126 return origins; 132 return origins;
127 } 133 }
128 134
129 std::vector<IndexedDBInfo> IndexedDBContextImpl::GetAllOriginsInfo() { 135 std::vector<IndexedDBInfo> IndexedDBContextImpl::GetAllOriginsInfo() {
136 DCHECK(OnIndexedDBThread());
130 std::vector<GURL> origins = GetAllOrigins(); 137 std::vector<GURL> origins = GetAllOrigins();
131 std::vector<IndexedDBInfo> result; 138 std::vector<IndexedDBInfo> result;
132 for (std::vector<GURL>::const_iterator iter = origins.begin(); 139 for (std::vector<GURL>::const_iterator iter = origins.begin();
133 iter != origins.end(); 140 iter != origins.end();
134 ++iter) { 141 ++iter) {
135 const GURL& origin_url = *iter; 142 const GURL& origin_url = *iter;
136 143
137 base::FilePath idb_directory = GetFilePath(origin_url); 144 base::FilePath idb_directory = GetFilePath(origin_url);
138 result.push_back(IndexedDBInfo(origin_url, 145 result.push_back(IndexedDBInfo(origin_url,
139 GetOriginDiskUsage(origin_url), 146 GetOriginDiskUsage(origin_url),
140 GetOriginLastModified(origin_url), 147 GetOriginLastModified(origin_url),
141 idb_directory)); 148 idb_directory));
142 } 149 }
143 return result; 150 return result;
144 } 151 }
145 152
146 int64 IndexedDBContextImpl::GetOriginDiskUsage(const GURL& origin_url) { 153 int64 IndexedDBContextImpl::GetOriginDiskUsage(const GURL& origin_url) {
154 DCHECK(OnIndexedDBThread());
147 if (data_path_.empty() || !IsInOriginSet(origin_url)) 155 if (data_path_.empty() || !IsInOriginSet(origin_url))
148 return 0; 156 return 0;
149 EnsureDiskUsageCacheInitialized(origin_url); 157 EnsureDiskUsageCacheInitialized(origin_url);
150 return origin_size_map_[origin_url]; 158 return origin_size_map_[origin_url];
151 } 159 }
152 160
153 base::Time IndexedDBContextImpl::GetOriginLastModified(const GURL& origin_url) { 161 base::Time IndexedDBContextImpl::GetOriginLastModified(const GURL& origin_url) {
162 DCHECK(OnIndexedDBThread());
154 if (data_path_.empty() || !IsInOriginSet(origin_url)) 163 if (data_path_.empty() || !IsInOriginSet(origin_url))
155 return base::Time(); 164 return base::Time();
156 base::FilePath idb_directory = GetFilePath(origin_url); 165 base::FilePath idb_directory = GetFilePath(origin_url);
157 base::PlatformFileInfo file_info; 166 base::PlatformFileInfo file_info;
158 if (!file_util::GetFileInfo(idb_directory, &file_info)) 167 if (!file_util::GetFileInfo(idb_directory, &file_info))
159 return base::Time(); 168 return base::Time();
160 return file_info.last_modified; 169 return file_info.last_modified;
161 } 170 }
162 171
163 void IndexedDBContextImpl::DeleteForOrigin(const GURL& origin_url) { 172 void IndexedDBContextImpl::DeleteForOrigin(const GURL& origin_url) {
164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 173 DCHECK(OnIndexedDBThread());
165 ForceClose(origin_url); 174 ForceClose(origin_url);
166 if (data_path_.empty() || !IsInOriginSet(origin_url)) 175 if (data_path_.empty() || !IsInOriginSet(origin_url))
167 return; 176 return;
168 177
169 base::FilePath idb_directory = GetFilePath(origin_url); 178 base::FilePath idb_directory = GetFilePath(origin_url);
170 EnsureDiskUsageCacheInitialized(origin_url); 179 EnsureDiskUsageCacheInitialized(origin_url);
171 const bool recursive = true; 180 const bool recursive = true;
172 bool deleted = file_util::Delete(idb_directory, recursive); 181 bool deleted = file_util::Delete(idb_directory, recursive);
173 182
174 QueryDiskAndUpdateQuotaUsage(origin_url); 183 QueryDiskAndUpdateQuotaUsage(origin_url);
175 if (deleted) { 184 if (deleted) {
176 RemoveFromOriginSet(origin_url); 185 RemoveFromOriginSet(origin_url);
177 origin_size_map_.erase(origin_url); 186 origin_size_map_.erase(origin_url);
178 space_available_map_.erase(origin_url); 187 space_available_map_.erase(origin_url);
179 } 188 }
180 } 189 }
181 190
182 void IndexedDBContextImpl::ForceClose(const GURL& origin_url) { 191 void IndexedDBContextImpl::ForceClose(const GURL& origin_url) {
183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 192 DCHECK(OnIndexedDBThread());
184 if (data_path_.empty() || !IsInOriginSet(origin_url)) 193 if (data_path_.empty() || !IsInOriginSet(origin_url))
185 return; 194 return;
186 195
187 if (connections_.find(origin_url) != connections_.end()) { 196 if (connections_.find(origin_url) != connections_.end()) {
188 ConnectionSet& connections = connections_[origin_url]; 197 ConnectionSet& connections = connections_[origin_url];
189 ConnectionSet::iterator it = connections.begin(); 198 ConnectionSet::iterator it = connections.begin();
190 while (it != connections.end()) { 199 while (it != connections.end()) {
191 // Remove before closing so callbacks don't double-erase 200 // Remove before closing so callbacks don't double-erase
192 WebIDBDatabaseImpl* db = *it; 201 WebIDBDatabaseImpl* db = *it;
193 connections.erase(it++); 202 connections.erase(it++);
194 db->forceClose(); 203 db->forceClose();
195 } 204 }
196 DCHECK_EQ(connections_[origin_url].size(), 0UL); 205 DCHECK_EQ(connections_[origin_url].size(), 0UL);
197 connections_.erase(origin_url); 206 connections_.erase(origin_url);
198 } 207 }
199 } 208 }
200 209
201 base::FilePath IndexedDBContextImpl::GetFilePath(const GURL& origin_url) { 210 base::FilePath IndexedDBContextImpl::GetFilePath(const GURL& origin_url) {
202 std::string origin_id = 211 std::string origin_id =
203 webkit_database::GetIdentifierFromOrigin(origin_url); 212 webkit_database::GetIdentifierFromOrigin(origin_url);
204 return GetIndexedDBFilePath(origin_id); 213 return GetIndexedDBFilePath(origin_id);
205 } 214 }
206 215
207 base::FilePath IndexedDBContextImpl::GetFilePathForTesting( 216 base::FilePath IndexedDBContextImpl::GetFilePathForTesting(
208 const std::string& origin_id) const { 217 const std::string& origin_id) const {
209 return GetIndexedDBFilePath(origin_id); 218 return GetIndexedDBFilePath(origin_id);
210 } 219 }
211 220
221 void IndexedDBContextImpl::SetMessageLoopForTesting(
222 base::MessageLoop* message_loop) {
223 DCHECK(!message_loop_);
224 message_loop_ = message_loop;
225 }
226
212 void IndexedDBContextImpl::ConnectionOpened(const GURL& origin_url, 227 void IndexedDBContextImpl::ConnectionOpened(const GURL& origin_url,
213 WebIDBDatabaseImpl* connection) { 228 WebIDBDatabaseImpl* connection) {
229 DCHECK(OnIndexedDBThread());
214 DCHECK_EQ(connections_[origin_url].count(connection), 0UL); 230 DCHECK_EQ(connections_[origin_url].count(connection), 0UL);
215 if (quota_manager_proxy()) { 231 if (quota_manager_proxy()) {
216 quota_manager_proxy()->NotifyStorageAccessed( 232 quota_manager_proxy()->NotifyStorageAccessed(
217 quota::QuotaClient::kIndexedDatabase, 233 quota::QuotaClient::kIndexedDatabase,
218 origin_url, 234 origin_url,
219 quota::kStorageTypeTemporary); 235 quota::kStorageTypeTemporary);
220 } 236 }
221 connections_[origin_url].insert(connection); 237 connections_[origin_url].insert(connection);
222 if (AddToOriginSet(origin_url)) { 238 if (AddToOriginSet(origin_url)) {
223 // A newly created db, notify the quota system. 239 // A newly created db, notify the quota system.
224 QueryDiskAndUpdateQuotaUsage(origin_url); 240 QueryDiskAndUpdateQuotaUsage(origin_url);
225 } else { 241 } else {
226 EnsureDiskUsageCacheInitialized(origin_url); 242 EnsureDiskUsageCacheInitialized(origin_url);
227 } 243 }
228 QueryAvailableQuota(origin_url); 244 QueryAvailableQuota(origin_url);
229 } 245 }
230 246
231 void IndexedDBContextImpl::ConnectionClosed(const GURL& origin_url, 247 void IndexedDBContextImpl::ConnectionClosed(const GURL& origin_url,
232 WebIDBDatabaseImpl* connection) { 248 WebIDBDatabaseImpl* connection) {
249 DCHECK(OnIndexedDBThread());
233 // May not be in the map if connection was forced to close 250 // May not be in the map if connection was forced to close
234 if (connections_.find(origin_url) == connections_.end() || 251 if (connections_.find(origin_url) == connections_.end() ||
235 connections_[origin_url].count(connection) != 1) 252 connections_[origin_url].count(connection) != 1)
236 return; 253 return;
237 if (quota_manager_proxy()) { 254 if (quota_manager_proxy()) {
238 quota_manager_proxy()->NotifyStorageAccessed( 255 quota_manager_proxy()->NotifyStorageAccessed(
239 quota::QuotaClient::kIndexedDatabase, 256 quota::QuotaClient::kIndexedDatabase,
240 origin_url, 257 origin_url,
241 quota::kStorageTypeTemporary); 258 quota::kStorageTypeTemporary);
242 } 259 }
(...skipping 26 matching lines...) Expand all
269 return WouldBeOverQuota(origin_url, kOneAdditionalByte); 286 return WouldBeOverQuota(origin_url, kOneAdditionalByte);
270 } 287 }
271 288
272 quota::QuotaManagerProxy* IndexedDBContextImpl::quota_manager_proxy() { 289 quota::QuotaManagerProxy* IndexedDBContextImpl::quota_manager_proxy() {
273 return quota_manager_proxy_.get(); 290 return quota_manager_proxy_.get();
274 } 291 }
275 292
276 IndexedDBContextImpl::~IndexedDBContextImpl() { 293 IndexedDBContextImpl::~IndexedDBContextImpl() {
277 WebIDBFactoryImpl* factory = idb_factory_.release(); 294 WebIDBFactoryImpl* factory = idb_factory_.release();
278 if (factory) { 295 if (factory) {
279 if (!BrowserThread::DeleteSoon( 296 if (!MessageLoopProxy()->DeleteSoon(FROM_HERE, factory))
280 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, factory))
281 delete factory; 297 delete factory;
282 } 298 }
283 299
284 if (data_path_.empty()) 300 if (data_path_.empty())
285 return; 301 return;
286 302
287 if (force_keep_session_state_) 303 if (force_keep_session_state_)
288 return; 304 return;
289 305
290 bool has_session_only_databases = 306 bool has_session_only_databases =
291 special_storage_policy_.get() && 307 special_storage_policy_.get() &&
292 special_storage_policy_->HasSessionOnlyOrigins(); 308 special_storage_policy_->HasSessionOnlyOrigins();
293 309
294 // Clearning only session-only databases, and there are none. 310 // Clearning only session-only databases, and there are none.
295 if (!has_session_only_databases) 311 if (!has_session_only_databases)
296 return; 312 return;
297 313
298 // No WEBKIT thread here means we are running in a unit test where no clean 314 TaskRunner()->PostTask(
299 // up is needed.
300 BrowserThread::PostTask(
301 BrowserThread::WEBKIT_DEPRECATED,
302 FROM_HERE, 315 FROM_HERE,
303 base::Bind( 316 base::Bind(
304 &ClearSessionOnlyOrigins, data_path_, special_storage_policy_)); 317 &ClearSessionOnlyOrigins, data_path_, special_storage_policy_));
305 } 318 }
306 319
307 base::FilePath IndexedDBContextImpl::GetIndexedDBFilePath( 320 base::FilePath IndexedDBContextImpl::GetIndexedDBFilePath(
308 const std::string& origin_id) const { 321 const std::string& origin_id) const {
309 DCHECK(!data_path_.empty()); 322 DCHECK(!data_path_.empty());
310 return data_path_.AppendASCII(origin_id). 323 return data_path_.AppendASCII(origin_id).
311 AddExtension(kIndexedDBExtension). 324 AddExtension(kIndexedDBExtension).
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 quota::QuotaStatusCode status, 362 quota::QuotaStatusCode status,
350 int64 usage, 363 int64 usage,
351 int64 quota) { 364 int64 quota) {
352 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
353 DCHECK(status == quota::kQuotaStatusOk || status == quota::kQuotaErrorAbort) 366 DCHECK(status == quota::kQuotaStatusOk || status == quota::kQuotaErrorAbort)
354 << "status was " << status; 367 << "status was " << status;
355 if (status == quota::kQuotaErrorAbort) { 368 if (status == quota::kQuotaErrorAbort) {
356 // We seem to no longer care to wait around for the answer. 369 // We seem to no longer care to wait around for the answer.
357 return; 370 return;
358 } 371 }
359 BrowserThread::PostTask(BrowserThread::WEBKIT_DEPRECATED, 372 TaskRunner()->PostTask(
360 FROM_HERE, 373 FROM_HERE,
361 base::Bind(&IndexedDBContextImpl::GotUpdatedQuota, 374 base::Bind(&IndexedDBContextImpl::GotUpdatedQuota,
362 this, 375 this,
363 origin_url, 376 origin_url,
364 usage, 377 usage,
365 quota)); 378 quota));
366 } 379 }
367 380
368 void IndexedDBContextImpl::GotUpdatedQuota(const GURL& origin_url, 381 void IndexedDBContextImpl::GotUpdatedQuota(const GURL& origin_url,
369 int64 usage, 382 int64 usage,
370 int64 quota) { 383 int64 quota) {
371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 384 DCHECK(OnIndexedDBThread());
372 space_available_map_[origin_url] = quota - usage; 385 space_available_map_[origin_url] = quota - usage;
373 } 386 }
374 387
375 void IndexedDBContextImpl::QueryAvailableQuota(const GURL& origin_url) { 388 void IndexedDBContextImpl::QueryAvailableQuota(const GURL& origin_url) {
376 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 389 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
377 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 390 DCHECK(OnIndexedDBThread());
378 if (quota_manager_proxy()) { 391 if (quota_manager_proxy()) {
379 BrowserThread::PostTask( 392 BrowserThread::PostTask(
380 BrowserThread::IO, 393 BrowserThread::IO,
381 FROM_HERE, 394 FROM_HERE,
382 base::Bind( 395 base::Bind(
383 &IndexedDBContextImpl::QueryAvailableQuota, this, origin_url)); 396 &IndexedDBContextImpl::QueryAvailableQuota, this, origin_url));
384 } 397 }
385 return; 398 return;
386 } 399 }
387 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 18 matching lines...) Expand all
406 } 419 }
407 return origin_set_.get(); 420 return origin_set_.get();
408 } 421 }
409 422
410 void IndexedDBContextImpl::ResetCaches() { 423 void IndexedDBContextImpl::ResetCaches() {
411 origin_set_.reset(); 424 origin_set_.reset();
412 origin_size_map_.clear(); 425 origin_size_map_.clear();
413 space_available_map_.clear(); 426 space_available_map_.clear();
414 } 427 }
415 428
429 scoped_refptr<base::MessageLoopProxy> IndexedDBContextImpl::MessageLoopProxy() {
430 return message_loop_->message_loop_proxy();
431 }
432
433 base::TaskRunner* IndexedDBContextImpl::TaskRunner() {
434 return message_loop_->message_loop_proxy();
435 }
436
437 bool IndexedDBContextImpl::OnIndexedDBThread() const {
438 return base::MessageLoop::current() == message_loop_;
439 }
440
416 } // namespace content 441 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698