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

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

Issue 1841553002: IndexedDB: Use url::Origin rather than GURL for representing origins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@origin-idb
Patch Set: Rebased Created 4 years, 8 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
« no previous file with comments | « no previous file | content/browser/indexed_db/indexed_db_active_blob_registry_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/location.h" 6 #include "base/location.h"
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/task_runner.h" 8 #include "base/task_runner.h"
9 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h" 9 #include "content/browser/indexed_db/indexed_db_active_blob_registry.h"
10 #include "content/browser/indexed_db/indexed_db_backing_store.h" 10 #include "content/browser/indexed_db/indexed_db_backing_store.h"
(...skipping 16 matching lines...) Expand all
27 DCHECK(KeyPrefix::IsValidDatabaseId(database_id)); 27 DCHECK(KeyPrefix::IsValidDatabaseId(database_id));
28 DCHECK(DatabaseMetaDataKey::IsValidBlobKey(blob_key)); 28 DCHECK(DatabaseMetaDataKey::IsValidBlobKey(blob_key));
29 DCHECK(!ContainsKey(deleted_dbs_, database_id)); 29 DCHECK(!ContainsKey(deleted_dbs_, database_id));
30 bool need_ref = use_tracker_.empty(); 30 bool need_ref = use_tracker_.empty();
31 SingleDBMap& single_db_map = use_tracker_[database_id]; 31 SingleDBMap& single_db_map = use_tracker_[database_id];
32 SingleDBMap::iterator iter = single_db_map.find(blob_key); 32 SingleDBMap::iterator iter = single_db_map.find(blob_key);
33 if (iter == single_db_map.end()) { 33 if (iter == single_db_map.end()) {
34 single_db_map[blob_key] = false; 34 single_db_map[blob_key] = false;
35 if (need_ref) { 35 if (need_ref) {
36 backing_store_->factory()->ReportOutstandingBlobs( 36 backing_store_->factory()->ReportOutstandingBlobs(
37 backing_store_->origin_url(), true); 37 backing_store_->origin(), true);
38 } 38 }
39 } else { 39 } else {
40 DCHECK(!need_ref); 40 DCHECK(!need_ref);
41 DCHECK(!iter->second); // You can't add a reference once it's been deleted. 41 DCHECK(!iter->second); // You can't add a reference once it's been deleted.
42 } 42 }
43 } 43 }
44 44
45 void IndexedDBActiveBlobRegistry::ReleaseBlobRef(int64_t database_id, 45 void IndexedDBActiveBlobRegistry::ReleaseBlobRef(int64_t database_id,
46 int64_t blob_key) { 46 int64_t blob_key) {
47 DCHECK(backing_store_); 47 DCHECK(backing_store_);
(...skipping 22 matching lines...) Expand all
70 use_tracker_.erase(db_pair); 70 use_tracker_.erase(db_pair);
71 if (db_marked_for_deletion) { 71 if (db_marked_for_deletion) {
72 delete_in_backend = true; 72 delete_in_backend = true;
73 blob_key = DatabaseMetaDataKey::kAllBlobsKey; 73 blob_key = DatabaseMetaDataKey::kAllBlobsKey;
74 deleted_dbs_.erase(db_to_delete); 74 deleted_dbs_.erase(db_to_delete);
75 } 75 }
76 } 76 }
77 if (delete_in_backend) 77 if (delete_in_backend)
78 backing_store_->ReportBlobUnused(database_id, blob_key); 78 backing_store_->ReportBlobUnused(database_id, blob_key);
79 if (use_tracker_.empty()) { 79 if (use_tracker_.empty()) {
80 backing_store_->factory()->ReportOutstandingBlobs( 80 backing_store_->factory()->ReportOutstandingBlobs(backing_store_->origin(),
81 backing_store_->origin_url(), false); 81 false);
82 } 82 }
83 } 83 }
84 84
85 bool IndexedDBActiveBlobRegistry::MarkDeletedCheckIfUsed(int64_t database_id, 85 bool IndexedDBActiveBlobRegistry::MarkDeletedCheckIfUsed(int64_t database_id,
86 int64_t blob_key) { 86 int64_t blob_key) {
87 DCHECK(backing_store_); 87 DCHECK(backing_store_);
88 DCHECK(backing_store_->task_runner()->RunsTasksOnCurrentThread()); 88 DCHECK(backing_store_->task_runner()->RunsTasksOnCurrentThread());
89 DCHECK(KeyPrefix::IsValidDatabaseId(database_id)); 89 DCHECK(KeyPrefix::IsValidDatabaseId(database_id));
90 AllDBsMap::iterator db_pair = use_tracker_.find(database_id); 90 AllDBsMap::iterator db_pair = use_tracker_.find(database_id);
91 if (db_pair == use_tracker_.end()) 91 if (db_pair == use_tracker_.end())
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 blob_key); 138 blob_key);
139 } 139 }
140 140
141 void IndexedDBActiveBlobRegistry::ForceShutdown() { 141 void IndexedDBActiveBlobRegistry::ForceShutdown() {
142 weak_factory_.InvalidateWeakPtrs(); 142 weak_factory_.InvalidateWeakPtrs();
143 use_tracker_.clear(); 143 use_tracker_.clear();
144 backing_store_ = NULL; 144 backing_store_ = NULL;
145 } 145 }
146 146
147 } // namespace content 147 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/indexed_db/indexed_db_active_blob_registry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698