OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/database_impl.h" | 5 #include "content/browser/indexed_db/database_impl.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/sequenced_task_runner.h" | |
9 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
10 #include "content/browser/bad_message.h" | 11 #include "content/browser/bad_message.h" |
11 #include "content/browser/child_process_security_policy_impl.h" | 12 #include "content/browser/child_process_security_policy_impl.h" |
12 #include "content/browser/indexed_db/indexed_db_connection.h" | 13 #include "content/browser/indexed_db/indexed_db_connection.h" |
13 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 14 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
14 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 15 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
15 #include "content/browser/indexed_db/indexed_db_transaction.h" | 16 #include "content/browser/indexed_db/indexed_db_transaction.h" |
16 #include "content/browser/indexed_db/indexed_db_value.h" | 17 #include "content/browser/indexed_db/indexed_db_value.h" |
17 #include "storage/browser/blob/blob_storage_context.h" | 18 #include "storage/browser/blob/blob_storage_context.h" |
18 #include "storage/browser/quota/quota_manager_proxy.h" | 19 #include "storage/browser/quota/quota_manager_proxy.h" |
19 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h" | 20 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h" |
20 | 21 |
21 using std::swap; | 22 using std::swap; |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 class IndexedDBDatabaseError; | 25 class IndexedDBDatabaseError; |
25 | 26 |
26 namespace { | 27 namespace { |
27 const char kInvalidBlobUuid[] = "Blob does not exist"; | 28 const char kInvalidBlobUuid[] = "Blob does not exist"; |
28 const char kInvalidBlobFilePath[] = "Blob file path is invalid"; | 29 const char kInvalidBlobFilePath[] = "Blob file path is invalid"; |
29 } // namespace | 30 } // namespace |
30 | 31 |
32 // Expect to be created on IO thread, and called/destroyed on IDB thread. | |
jsbell
2017/04/11 16:58:03
Can you use DCHECK_CURRENTLY_ON and DCHECK(idb_run
dmurph
2017/04/11 19:32:49
Done.
| |
31 class DatabaseImpl::IDBThreadHelper { | 33 class DatabaseImpl::IDBThreadHelper { |
32 public: | 34 public: |
33 IDBThreadHelper(std::unique_ptr<IndexedDBConnection> connection, | 35 IDBThreadHelper(std::unique_ptr<IndexedDBConnection> connection, |
34 const url::Origin& origin, | 36 const url::Origin& origin, |
35 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host); | 37 scoped_refptr<IndexedDBContextImpl> indexed_db_context); |
36 ~IDBThreadHelper(); | 38 ~IDBThreadHelper(); |
37 | 39 |
40 void ConnectionOpened(); | |
41 | |
38 void CreateObjectStore(int64_t transaction_id, | 42 void CreateObjectStore(int64_t transaction_id, |
39 int64_t object_store_id, | 43 int64_t object_store_id, |
40 const base::string16& name, | 44 const base::string16& name, |
41 const IndexedDBKeyPath& key_path, | 45 const IndexedDBKeyPath& key_path, |
42 bool auto_increment); | 46 bool auto_increment); |
43 void DeleteObjectStore(int64_t transaction_id, int64_t object_store_id); | 47 void DeleteObjectStore(int64_t transaction_id, int64_t object_store_id); |
44 void RenameObjectStore(int64_t transaction_id, | 48 void RenameObjectStore(int64_t transaction_id, |
45 int64_t object_store_id, | 49 int64_t object_store_id, |
46 const base::string16& new_name); | 50 const base::string16& new_name); |
47 void CreateTransaction(int64_t transaction_id, | 51 void CreateTransaction(int64_t transaction_id, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 void AbortWithError(int64_t transaction_id, | 127 void AbortWithError(int64_t transaction_id, |
124 const IndexedDBDatabaseError& error); | 128 const IndexedDBDatabaseError& error); |
125 void Commit(int64_t transaction_id); | 129 void Commit(int64_t transaction_id); |
126 void OnGotUsageAndQuotaForCommit(int64_t transaction_id, | 130 void OnGotUsageAndQuotaForCommit(int64_t transaction_id, |
127 storage::QuotaStatusCode status, | 131 storage::QuotaStatusCode status, |
128 int64_t usage, | 132 int64_t usage, |
129 int64_t quota); | 133 int64_t quota); |
130 void AckReceivedBlobs(const std::vector<std::string>& uuids); | 134 void AckReceivedBlobs(const std::vector<std::string>& uuids); |
131 | 135 |
132 private: | 136 private: |
133 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; | 137 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
134 std::unique_ptr<IndexedDBConnection> connection_; | 138 std::unique_ptr<IndexedDBConnection> connection_; |
135 const url::Origin origin_; | 139 const url::Origin origin_; |
136 base::WeakPtrFactory<IDBThreadHelper> weak_factory_; | 140 base::WeakPtrFactory<IDBThreadHelper> weak_factory_; |
137 }; | 141 }; |
138 | 142 |
139 DatabaseImpl::DatabaseImpl( | 143 DatabaseImpl::DatabaseImpl(std::unique_ptr<IndexedDBConnection> connection, |
140 std::unique_ptr<IndexedDBConnection> connection, | 144 const url::Origin& origin, |
141 const url::Origin& origin, | 145 IndexedDBDispatcherHost* dispatcher_host, |
142 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host) | 146 scoped_refptr<base::SequencedTaskRunner> idb_runner) |
143 : dispatcher_host_(dispatcher_host), | 147 : dispatcher_host_(dispatcher_host), |
144 origin_(origin), | 148 origin_(origin), |
145 idb_runner_(base::ThreadTaskRunnerHandle::Get()) { | 149 idb_runner_(std::move(idb_runner)) { |
150 DCHECK(connection); | |
146 helper_ = new IDBThreadHelper(std::move(connection), origin, | 151 helper_ = new IDBThreadHelper(std::move(connection), origin, |
147 std::move(dispatcher_host)); | 152 dispatcher_host->context()); |
153 idb_runner_->PostTask(FROM_HERE, | |
154 base::Bind(&IDBThreadHelper::ConnectionOpened, | |
155 base::Unretained(helper_))); | |
148 } | 156 } |
149 | 157 |
150 DatabaseImpl::~DatabaseImpl() { | 158 DatabaseImpl::~DatabaseImpl() { |
151 idb_runner_->DeleteSoon(FROM_HERE, helper_); | 159 idb_runner_->DeleteSoon(FROM_HERE, helper_); |
152 } | 160 } |
153 | 161 |
154 void DatabaseImpl::CreateObjectStore(int64_t transaction_id, | 162 void DatabaseImpl::CreateObjectStore(int64_t transaction_id, |
155 int64_t object_store_id, | 163 int64_t object_store_id, |
156 const base::string16& name, | 164 const base::string16& name, |
157 const IndexedDBKeyPath& key_path, | 165 const IndexedDBKeyPath& key_path, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 base::Unretained(helper_), observers)); | 227 base::Unretained(helper_), observers)); |
220 } | 228 } |
221 | 229 |
222 void DatabaseImpl::Get( | 230 void DatabaseImpl::Get( |
223 int64_t transaction_id, | 231 int64_t transaction_id, |
224 int64_t object_store_id, | 232 int64_t object_store_id, |
225 int64_t index_id, | 233 int64_t index_id, |
226 const IndexedDBKeyRange& key_range, | 234 const IndexedDBKeyRange& key_range, |
227 bool key_only, | 235 bool key_only, |
228 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { | 236 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { |
229 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 237 scoped_refptr<IndexedDBCallbacks> callbacks( |
230 dispatcher_host_.get(), origin_, std::move(callbacks_info))); | 238 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, |
239 std::move(callbacks_info), idb_runner_)); | |
231 idb_runner_->PostTask( | 240 idb_runner_->PostTask( |
232 FROM_HERE, base::Bind(&IDBThreadHelper::Get, base::Unretained(helper_), | 241 FROM_HERE, base::Bind(&IDBThreadHelper::Get, base::Unretained(helper_), |
233 transaction_id, object_store_id, index_id, | 242 transaction_id, object_store_id, index_id, |
234 key_range, key_only, base::Passed(&callbacks))); | 243 key_range, key_only, base::Passed(&callbacks))); |
235 } | 244 } |
236 | 245 |
237 void DatabaseImpl::GetAll( | 246 void DatabaseImpl::GetAll( |
238 int64_t transaction_id, | 247 int64_t transaction_id, |
239 int64_t object_store_id, | 248 int64_t object_store_id, |
240 int64_t index_id, | 249 int64_t index_id, |
241 const IndexedDBKeyRange& key_range, | 250 const IndexedDBKeyRange& key_range, |
242 bool key_only, | 251 bool key_only, |
243 int64_t max_count, | 252 int64_t max_count, |
244 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { | 253 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { |
245 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 254 scoped_refptr<IndexedDBCallbacks> callbacks( |
246 dispatcher_host_.get(), origin_, std::move(callbacks_info))); | 255 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, |
256 std::move(callbacks_info), idb_runner_)); | |
247 idb_runner_->PostTask( | 257 idb_runner_->PostTask( |
248 FROM_HERE, | 258 FROM_HERE, |
249 base::Bind(&IDBThreadHelper::GetAll, base::Unretained(helper_), | 259 base::Bind(&IDBThreadHelper::GetAll, base::Unretained(helper_), |
250 transaction_id, object_store_id, index_id, key_range, key_only, | 260 transaction_id, object_store_id, index_id, key_range, key_only, |
251 max_count, base::Passed(&callbacks))); | 261 max_count, base::Passed(&callbacks))); |
252 } | 262 } |
253 | 263 |
254 void DatabaseImpl::Put( | 264 void DatabaseImpl::Put( |
255 int64_t transaction_id, | 265 int64_t transaction_id, |
256 int64_t object_store_id, | 266 int64_t object_store_id, |
257 ::indexed_db::mojom::ValuePtr value, | 267 ::indexed_db::mojom::ValuePtr value, |
258 const IndexedDBKey& key, | 268 const IndexedDBKey& key, |
259 blink::WebIDBPutMode mode, | 269 blink::WebIDBPutMode mode, |
260 const std::vector<IndexedDBIndexKeys>& index_keys, | 270 const std::vector<IndexedDBIndexKeys>& index_keys, |
261 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { | 271 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { |
262 ChildProcessSecurityPolicyImpl* policy = | 272 ChildProcessSecurityPolicyImpl* policy = |
263 ChildProcessSecurityPolicyImpl::GetInstance(); | 273 ChildProcessSecurityPolicyImpl::GetInstance(); |
264 | 274 |
265 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 275 scoped_refptr<IndexedDBCallbacks> callbacks( |
266 dispatcher_host_.get(), origin_, std::move(callbacks_info))); | 276 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, |
277 std::move(callbacks_info), idb_runner_)); | |
267 | 278 |
268 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles( | 279 std::vector<std::unique_ptr<storage::BlobDataHandle>> handles( |
269 value->blob_or_file_info.size()); | 280 value->blob_or_file_info.size()); |
270 std::vector<IndexedDBBlobInfo> blob_info(value->blob_or_file_info.size()); | 281 std::vector<IndexedDBBlobInfo> blob_info(value->blob_or_file_info.size()); |
271 for (size_t i = 0; i < value->blob_or_file_info.size(); ++i) { | 282 for (size_t i = 0; i < value->blob_or_file_info.size(); ++i) { |
272 ::indexed_db::mojom::BlobInfoPtr& info = value->blob_or_file_info[i]; | 283 ::indexed_db::mojom::BlobInfoPtr& info = value->blob_or_file_info[i]; |
273 | 284 |
274 std::unique_ptr<storage::BlobDataHandle> handle = | 285 std::unique_ptr<storage::BlobDataHandle> handle = |
275 dispatcher_host_->blob_storage_context()->GetBlobDataFromUUID( | 286 dispatcher_host_->blob_storage_context()->GetBlobDataFromUUID( |
276 info->uuid); | 287 info->uuid); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 | 355 |
345 void DatabaseImpl::OpenCursor( | 356 void DatabaseImpl::OpenCursor( |
346 int64_t transaction_id, | 357 int64_t transaction_id, |
347 int64_t object_store_id, | 358 int64_t object_store_id, |
348 int64_t index_id, | 359 int64_t index_id, |
349 const IndexedDBKeyRange& key_range, | 360 const IndexedDBKeyRange& key_range, |
350 blink::WebIDBCursorDirection direction, | 361 blink::WebIDBCursorDirection direction, |
351 bool key_only, | 362 bool key_only, |
352 blink::WebIDBTaskType task_type, | 363 blink::WebIDBTaskType task_type, |
353 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { | 364 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { |
354 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 365 scoped_refptr<IndexedDBCallbacks> callbacks( |
355 dispatcher_host_.get(), origin_, std::move(callbacks_info))); | 366 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, |
367 std::move(callbacks_info), idb_runner_)); | |
356 idb_runner_->PostTask( | 368 idb_runner_->PostTask( |
357 FROM_HERE, | 369 FROM_HERE, |
358 base::Bind(&IDBThreadHelper::OpenCursor, base::Unretained(helper_), | 370 base::Bind(&IDBThreadHelper::OpenCursor, base::Unretained(helper_), |
359 transaction_id, object_store_id, index_id, key_range, | 371 transaction_id, object_store_id, index_id, key_range, |
360 direction, key_only, task_type, base::Passed(&callbacks))); | 372 direction, key_only, task_type, base::Passed(&callbacks))); |
361 } | 373 } |
362 | 374 |
363 void DatabaseImpl::Count( | 375 void DatabaseImpl::Count( |
364 int64_t transaction_id, | 376 int64_t transaction_id, |
365 int64_t object_store_id, | 377 int64_t object_store_id, |
366 int64_t index_id, | 378 int64_t index_id, |
367 const IndexedDBKeyRange& key_range, | 379 const IndexedDBKeyRange& key_range, |
368 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { | 380 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { |
369 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 381 scoped_refptr<IndexedDBCallbacks> callbacks( |
370 dispatcher_host_.get(), origin_, std::move(callbacks_info))); | 382 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, |
383 std::move(callbacks_info), idb_runner_)); | |
371 idb_runner_->PostTask( | 384 idb_runner_->PostTask( |
372 FROM_HERE, base::Bind(&IDBThreadHelper::Count, base::Unretained(helper_), | 385 FROM_HERE, base::Bind(&IDBThreadHelper::Count, base::Unretained(helper_), |
373 transaction_id, object_store_id, index_id, | 386 transaction_id, object_store_id, index_id, |
374 key_range, base::Passed(&callbacks))); | 387 key_range, base::Passed(&callbacks))); |
375 } | 388 } |
376 | 389 |
377 void DatabaseImpl::DeleteRange( | 390 void DatabaseImpl::DeleteRange( |
378 int64_t transaction_id, | 391 int64_t transaction_id, |
379 int64_t object_store_id, | 392 int64_t object_store_id, |
380 const IndexedDBKeyRange& key_range, | 393 const IndexedDBKeyRange& key_range, |
381 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { | 394 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { |
382 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 395 scoped_refptr<IndexedDBCallbacks> callbacks( |
383 dispatcher_host_.get(), origin_, std::move(callbacks_info))); | 396 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, |
397 std::move(callbacks_info), idb_runner_)); | |
384 idb_runner_->PostTask( | 398 idb_runner_->PostTask( |
385 FROM_HERE, | 399 FROM_HERE, |
386 base::Bind(&IDBThreadHelper::DeleteRange, base::Unretained(helper_), | 400 base::Bind(&IDBThreadHelper::DeleteRange, base::Unretained(helper_), |
387 transaction_id, object_store_id, key_range, | 401 transaction_id, object_store_id, key_range, |
388 base::Passed(&callbacks))); | 402 base::Passed(&callbacks))); |
389 } | 403 } |
390 | 404 |
391 void DatabaseImpl::Clear( | 405 void DatabaseImpl::Clear( |
392 int64_t transaction_id, | 406 int64_t transaction_id, |
393 int64_t object_store_id, | 407 int64_t object_store_id, |
394 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { | 408 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) { |
395 scoped_refptr<IndexedDBCallbacks> callbacks(new IndexedDBCallbacks( | 409 scoped_refptr<IndexedDBCallbacks> callbacks( |
396 dispatcher_host_.get(), origin_, std::move(callbacks_info))); | 410 new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_, |
411 std::move(callbacks_info), idb_runner_)); | |
397 idb_runner_->PostTask( | 412 idb_runner_->PostTask( |
398 FROM_HERE, | 413 FROM_HERE, |
399 base::Bind(&IDBThreadHelper::Clear, base::Unretained(helper_), | 414 base::Bind(&IDBThreadHelper::Clear, base::Unretained(helper_), |
400 transaction_id, object_store_id, base::Passed(&callbacks))); | 415 transaction_id, object_store_id, base::Passed(&callbacks))); |
401 } | 416 } |
402 | 417 |
403 void DatabaseImpl::CreateIndex(int64_t transaction_id, | 418 void DatabaseImpl::CreateIndex(int64_t transaction_id, |
404 int64_t object_store_id, | 419 int64_t object_store_id, |
405 int64_t index_id, | 420 int64_t index_id, |
406 const base::string16& name, | 421 const base::string16& name, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 } | 461 } |
447 | 462 |
448 void DatabaseImpl::AckReceivedBlobs(const std::vector<std::string>& uuids) { | 463 void DatabaseImpl::AckReceivedBlobs(const std::vector<std::string>& uuids) { |
449 for (const auto& uuid : uuids) | 464 for (const auto& uuid : uuids) |
450 dispatcher_host_->DropBlobData(uuid); | 465 dispatcher_host_->DropBlobData(uuid); |
451 } | 466 } |
452 | 467 |
453 DatabaseImpl::IDBThreadHelper::IDBThreadHelper( | 468 DatabaseImpl::IDBThreadHelper::IDBThreadHelper( |
454 std::unique_ptr<IndexedDBConnection> connection, | 469 std::unique_ptr<IndexedDBConnection> connection, |
455 const url::Origin& origin, | 470 const url::Origin& origin, |
456 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host) | 471 scoped_refptr<IndexedDBContextImpl> indexed_db_context) |
457 : dispatcher_host_(std::move(dispatcher_host)), | 472 : indexed_db_context_(indexed_db_context), |
458 connection_(std::move(connection)), | 473 connection_(std::move(connection)), |
459 origin_(origin), | 474 origin_(origin), |
460 weak_factory_(this) { | 475 weak_factory_(this) {} |
461 dispatcher_host_->context()->ConnectionOpened(origin_, connection.get()); | |
462 } | |
463 | 476 |
464 DatabaseImpl::IDBThreadHelper::~IDBThreadHelper() { | 477 DatabaseImpl::IDBThreadHelper::~IDBThreadHelper() { |
465 if (connection_->IsConnected()) | 478 if (connection_->IsConnected()) |
466 connection_->Close(); | 479 connection_->Close(); |
467 dispatcher_host_->context()->ConnectionClosed(origin_, connection_.get()); | 480 indexed_db_context_->ConnectionClosed(origin_, connection_.get()); |
481 } | |
482 | |
483 void DatabaseImpl::IDBThreadHelper::ConnectionOpened() { | |
484 indexed_db_context_->ConnectionOpened(origin_, connection_.get()); | |
468 } | 485 } |
469 | 486 |
470 void DatabaseImpl::IDBThreadHelper::CreateObjectStore( | 487 void DatabaseImpl::IDBThreadHelper::CreateObjectStore( |
471 int64_t transaction_id, | 488 int64_t transaction_id, |
472 int64_t object_store_id, | 489 int64_t object_store_id, |
473 const base::string16& name, | 490 const base::string16& name, |
474 const IndexedDBKeyPath& key_path, | 491 const IndexedDBKeyPath& key_path, |
475 bool auto_increment) { | 492 bool auto_increment) { |
476 if (!connection_->IsConnected()) | 493 if (!connection_->IsConnected()) |
477 return; | 494 return; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
834 connection_->GetTransaction(transaction_id); | 851 connection_->GetTransaction(transaction_id); |
835 if (!transaction) | 852 if (!transaction) |
836 return; | 853 return; |
837 | 854 |
838 // Always allow empty or delete-only transactions. | 855 // Always allow empty or delete-only transactions. |
839 if (transaction->size() == 0) { | 856 if (transaction->size() == 0) { |
840 connection_->database()->Commit(transaction); | 857 connection_->database()->Commit(transaction); |
841 return; | 858 return; |
842 } | 859 } |
843 | 860 |
844 dispatcher_host_->context()->quota_manager_proxy()->GetUsageAndQuota( | 861 indexed_db_context_->quota_manager_proxy()->GetUsageAndQuota( |
845 dispatcher_host_->context()->TaskRunner(), origin_.GetURL(), | 862 indexed_db_context_->TaskRunner(), origin_.GetURL(), |
846 storage::kStorageTypeTemporary, | 863 storage::kStorageTypeTemporary, |
847 base::Bind(&IDBThreadHelper::OnGotUsageAndQuotaForCommit, | 864 base::Bind(&IDBThreadHelper::OnGotUsageAndQuotaForCommit, |
848 weak_factory_.GetWeakPtr(), transaction_id)); | 865 weak_factory_.GetWeakPtr(), transaction_id)); |
849 } | 866 } |
850 | 867 |
851 void DatabaseImpl::IDBThreadHelper::OnGotUsageAndQuotaForCommit( | 868 void DatabaseImpl::IDBThreadHelper::OnGotUsageAndQuotaForCommit( |
852 int64_t transaction_id, | 869 int64_t transaction_id, |
853 storage::QuotaStatusCode status, | 870 storage::QuotaStatusCode status, |
854 int64_t usage, | 871 int64_t usage, |
855 int64_t quota) { | 872 int64_t quota) { |
(...skipping 10 matching lines...) Expand all Loading... | |
866 usage + transaction->size() <= quota) { | 883 usage + transaction->size() <= quota) { |
867 connection_->database()->Commit(transaction); | 884 connection_->database()->Commit(transaction); |
868 } else { | 885 } else { |
869 connection_->AbortTransaction( | 886 connection_->AbortTransaction( |
870 transaction, | 887 transaction, |
871 IndexedDBDatabaseError(blink::kWebIDBDatabaseExceptionQuotaError)); | 888 IndexedDBDatabaseError(blink::kWebIDBDatabaseExceptionQuotaError)); |
872 } | 889 } |
873 } | 890 } |
874 | 891 |
875 } // namespace content | 892 } // namespace content |
OLD | NEW |