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

Side by Side Diff: storage/browser/database/database_quota_client.cc

Issue 1815363002: Add RetainedRef uses where needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « printing/printed_document.cc ('k') | storage/browser/fileapi/async_file_util_adapter.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 (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 "storage/browser/database/database_quota_client.h" 5 #include "storage/browser/database/database_quota_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 DCHECK(!callback.is_null()); 126 DCHECK(!callback.is_null());
127 DCHECK(db_tracker_.get()); 127 DCHECK(db_tracker_.get());
128 128
129 // All databases are in the temp namespace for now. 129 // All databases are in the temp namespace for now.
130 if (type != storage::kStorageTypeTemporary) { 130 if (type != storage::kStorageTypeTemporary) {
131 callback.Run(0); 131 callback.Run(0);
132 return; 132 return;
133 } 133 }
134 134
135 base::PostTaskAndReplyWithResult( 135 base::PostTaskAndReplyWithResult(
136 db_tracker_thread_.get(), 136 db_tracker_thread_.get(), FROM_HERE,
137 FROM_HERE, 137 base::Bind(&GetOriginUsageOnDBThread, base::RetainedRef(db_tracker_),
138 base::Bind(&GetOriginUsageOnDBThread, db_tracker_, origin_url), 138 origin_url),
139 callback); 139 callback);
140 } 140 }
141 141
142 void DatabaseQuotaClient::GetOriginsForType( 142 void DatabaseQuotaClient::GetOriginsForType(
143 storage::StorageType type, 143 storage::StorageType type,
144 const GetOriginsCallback& callback) { 144 const GetOriginsCallback& callback) {
145 DCHECK(!callback.is_null()); 145 DCHECK(!callback.is_null());
146 DCHECK(db_tracker_.get()); 146 DCHECK(db_tracker_.get());
147 147
148 // All databases are in the temp namespace for now. 148 // All databases are in the temp namespace for now.
149 if (type != storage::kStorageTypeTemporary) { 149 if (type != storage::kStorageTypeTemporary) {
150 callback.Run(std::set<GURL>()); 150 callback.Run(std::set<GURL>());
151 return; 151 return;
152 } 152 }
153 153
154 std::set<GURL>* origins_ptr = new std::set<GURL>(); 154 std::set<GURL>* origins_ptr = new std::set<GURL>();
155 db_tracker_thread_->PostTaskAndReply( 155 db_tracker_thread_->PostTaskAndReply(
156 FROM_HERE, 156 FROM_HERE,
157 base::Bind(&GetOriginsOnDBThread, 157 base::Bind(&GetOriginsOnDBThread, base::RetainedRef(db_tracker_),
158 db_tracker_,
159 base::Unretained(origins_ptr)), 158 base::Unretained(origins_ptr)),
160 base::Bind(&DidGetOrigins, 159 base::Bind(&DidGetOrigins, callback, base::Owned(origins_ptr)));
161 callback,
162 base::Owned(origins_ptr)));
163 } 160 }
164 161
165 void DatabaseQuotaClient::GetOriginsForHost( 162 void DatabaseQuotaClient::GetOriginsForHost(
166 storage::StorageType type, 163 storage::StorageType type,
167 const std::string& host, 164 const std::string& host,
168 const GetOriginsCallback& callback) { 165 const GetOriginsCallback& callback) {
169 DCHECK(!callback.is_null()); 166 DCHECK(!callback.is_null());
170 DCHECK(db_tracker_.get()); 167 DCHECK(db_tracker_.get());
171 168
172 // All databases are in the temp namespace for now. 169 // All databases are in the temp namespace for now.
173 if (type != storage::kStorageTypeTemporary) { 170 if (type != storage::kStorageTypeTemporary) {
174 callback.Run(std::set<GURL>()); 171 callback.Run(std::set<GURL>());
175 return; 172 return;
176 } 173 }
177 174
178 std::set<GURL>* origins_ptr = new std::set<GURL>(); 175 std::set<GURL>* origins_ptr = new std::set<GURL>();
179 db_tracker_thread_->PostTaskAndReply( 176 db_tracker_thread_->PostTaskAndReply(
180 FROM_HERE, 177 FROM_HERE,
181 base::Bind(&GetOriginsForHostOnDBThread, 178 base::Bind(&GetOriginsForHostOnDBThread, base::RetainedRef(db_tracker_),
182 db_tracker_, 179 base::Unretained(origins_ptr), host),
183 base::Unretained(origins_ptr), 180 base::Bind(&DidGetOrigins, callback, base::Owned(origins_ptr)));
184 host),
185 base::Bind(&DidGetOrigins,
186 callback,
187 base::Owned(origins_ptr)));
188 } 181 }
189 182
190 void DatabaseQuotaClient::DeleteOriginData(const GURL& origin, 183 void DatabaseQuotaClient::DeleteOriginData(const GURL& origin,
191 storage::StorageType type, 184 storage::StorageType type,
192 const DeletionCallback& callback) { 185 const DeletionCallback& callback) {
193 DCHECK(!callback.is_null()); 186 DCHECK(!callback.is_null());
194 DCHECK(db_tracker_.get()); 187 DCHECK(db_tracker_.get());
195 188
196 // All databases are in the temp namespace for now, so nothing to delete. 189 // All databases are in the temp namespace for now, so nothing to delete.
197 if (type != storage::kStorageTypeTemporary) { 190 if (type != storage::kStorageTypeTemporary) {
198 callback.Run(storage::kQuotaStatusOk); 191 callback.Run(storage::kQuotaStatusOk);
199 return; 192 return;
200 } 193 }
201 194
202 base::Callback<void(int)> delete_callback = 195 base::Callback<void(int)> delete_callback = base::Bind(
203 base::Bind(&DidDeleteOriginData, 196 &DidDeleteOriginData,
204 base::ThreadTaskRunnerHandle::Get(), 197 base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), callback);
205 callback);
206 198
207 PostTaskAndReplyWithResult( 199 PostTaskAndReplyWithResult(
208 db_tracker_thread_.get(), 200 db_tracker_thread_.get(),
209 FROM_HERE, 201 FROM_HERE,
210 base::Bind(&DatabaseTracker::DeleteDataForOrigin, 202 base::Bind(&DatabaseTracker::DeleteDataForOrigin,
211 db_tracker_, 203 db_tracker_,
212 storage::GetIdentifierFromOrigin(origin), 204 storage::GetIdentifierFromOrigin(origin),
213 delete_callback), 205 delete_callback),
214 delete_callback); 206 delete_callback);
215 } 207 }
216 208
217 bool DatabaseQuotaClient::DoesSupport(storage::StorageType type) const { 209 bool DatabaseQuotaClient::DoesSupport(storage::StorageType type) const {
218 return type == storage::kStorageTypeTemporary; 210 return type == storage::kStorageTypeTemporary;
219 } 211 }
220 212
221 } // namespace storage 213 } // namespace storage
OLDNEW
« no previous file with comments | « printing/printed_document.cc ('k') | storage/browser/fileapi/async_file_util_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698