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

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

Issue 2941353002: Indexed DB: Use BindOnce / OnceCallback / OnceClosure where applicable (Closed)
Patch Set: Created 3 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
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_quota_client.h" 5 #include "content/browser/indexed_db/indexed_db_quota_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 111
112 // No task runner means unit test; no cleanup necessary. 112 // No task runner means unit test; no cleanup necessary.
113 if (!indexed_db_context_->TaskRunner()) { 113 if (!indexed_db_context_->TaskRunner()) {
114 callback.Run(std::set<GURL>()); 114 callback.Run(std::set<GURL>());
115 return; 115 return;
116 } 116 }
117 117
118 std::set<GURL>* origins_to_return = new std::set<GURL>(); 118 std::set<GURL>* origins_to_return = new std::set<GURL>();
119 indexed_db_context_->TaskRunner()->PostTaskAndReply( 119 indexed_db_context_->TaskRunner()->PostTaskAndReply(
120 FROM_HERE, base::Bind(&GetAllOriginsOnIndexedDBThread, 120 FROM_HERE,
121 base::RetainedRef(indexed_db_context_), 121 base::BindOnce(&GetAllOriginsOnIndexedDBThread,
122 base::Unretained(origins_to_return)), 122 base::RetainedRef(indexed_db_context_),
123 base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return))); 123 base::Unretained(origins_to_return)),
124 base::BindOnce(&DidGetOrigins, callback, base::Owned(origins_to_return)));
124 } 125 }
125 126
126 void IndexedDBQuotaClient::GetOriginsForHost( 127 void IndexedDBQuotaClient::GetOriginsForHost(
127 storage::StorageType type, 128 storage::StorageType type,
128 const std::string& host, 129 const std::string& host,
129 const GetOriginsCallback& callback) { 130 const GetOriginsCallback& callback) {
130 DCHECK(!callback.is_null()); 131 DCHECK(!callback.is_null());
131 DCHECK(indexed_db_context_.get()); 132 DCHECK(indexed_db_context_.get());
132 133
133 // All databases are in the temp namespace for now. 134 // All databases are in the temp namespace for now.
134 if (type != storage::kStorageTypeTemporary) { 135 if (type != storage::kStorageTypeTemporary) {
135 callback.Run(std::set<GURL>()); 136 callback.Run(std::set<GURL>());
136 return; 137 return;
137 } 138 }
138 139
139 // No task runner means unit test; no cleanup necessary. 140 // No task runner means unit test; no cleanup necessary.
140 if (!indexed_db_context_->TaskRunner()) { 141 if (!indexed_db_context_->TaskRunner()) {
141 callback.Run(std::set<GURL>()); 142 callback.Run(std::set<GURL>());
142 return; 143 return;
143 } 144 }
144 145
145 std::set<GURL>* origins_to_return = new std::set<GURL>(); 146 std::set<GURL>* origins_to_return = new std::set<GURL>();
146 indexed_db_context_->TaskRunner()->PostTaskAndReply( 147 indexed_db_context_->TaskRunner()->PostTaskAndReply(
147 FROM_HERE, base::Bind(&GetOriginsForHostOnIndexedDBThread, 148 FROM_HERE,
148 base::RetainedRef(indexed_db_context_), host, 149 base::BindOnce(&GetOriginsForHostOnIndexedDBThread,
149 base::Unretained(origins_to_return)), 150 base::RetainedRef(indexed_db_context_), host,
150 base::Bind(&DidGetOrigins, callback, base::Owned(origins_to_return))); 151 base::Unretained(origins_to_return)),
152 base::BindOnce(&DidGetOrigins, callback, base::Owned(origins_to_return)));
151 } 153 }
152 154
153 void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin, 155 void IndexedDBQuotaClient::DeleteOriginData(const GURL& origin,
154 storage::StorageType type, 156 storage::StorageType type,
155 const DeletionCallback& callback) { 157 const DeletionCallback& callback) {
156 if (type != storage::kStorageTypeTemporary) { 158 if (type != storage::kStorageTypeTemporary) {
157 callback.Run(storage::kQuotaErrorNotSupported); 159 callback.Run(storage::kQuotaErrorNotSupported);
158 return; 160 return;
159 } 161 }
160 162
161 // No task runner means unit test; no cleanup necessary. 163 // No task runner means unit test; no cleanup necessary.
162 if (!indexed_db_context_->TaskRunner()) { 164 if (!indexed_db_context_->TaskRunner()) {
163 callback.Run(storage::kQuotaStatusOk); 165 callback.Run(storage::kQuotaStatusOk);
164 return; 166 return;
165 } 167 }
166 168
167 base::PostTaskAndReplyWithResult( 169 base::PostTaskAndReplyWithResult(
168 indexed_db_context_->TaskRunner(), FROM_HERE, 170 indexed_db_context_->TaskRunner(), FROM_HERE,
169 base::Bind(&DeleteOriginDataOnIndexedDBThread, 171 base::Bind(&DeleteOriginDataOnIndexedDBThread,
170 base::RetainedRef(indexed_db_context_), origin), 172 base::RetainedRef(indexed_db_context_), origin),
171 callback); 173 callback);
172 } 174 }
173 175
174 bool IndexedDBQuotaClient::DoesSupport(storage::StorageType type) const { 176 bool IndexedDBQuotaClient::DoesSupport(storage::StorageType type) const {
175 return type == storage::kStorageTypeTemporary; 177 return type == storage::kStorageTypeTemporary;
176 } 178 }
177 179
178 } // namespace content 180 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_internals_ui.cc ('k') | content/browser/indexed_db/indexed_db_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698