OLD | NEW |
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 "webkit/browser/database/database_quota_client.h" | 5 #include "webkit/browser/database/database_quota_client.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 iter != origin_identifiers.end(); ++iter) { | 59 iter != origin_identifiers.end(); ++iter) { |
60 GURL origin = webkit_base::GetOriginURLFromIdentifier(*iter); | 60 GURL origin = webkit_base::GetOriginURLFromIdentifier(*iter); |
61 if (host == net::GetHostOrSpecFromURL(origin)) | 61 if (host == net::GetHostOrSpecFromURL(origin)) |
62 origins_ptr->insert(origin); | 62 origins_ptr->insert(origin); |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 void DidGetOrigins( | 67 void DidGetOrigins( |
68 const QuotaClient::GetOriginsCallback& callback, | 68 const QuotaClient::GetOriginsCallback& callback, |
69 std::set<GURL>* origins_ptr, | 69 std::set<GURL>* origins_ptr) { |
70 quota::StorageType type) { | 70 callback.Run(*origins_ptr); |
71 callback.Run(*origins_ptr, type); | |
72 } | 71 } |
73 | 72 |
74 void DidDeleteOriginData( | 73 void DidDeleteOriginData( |
75 base::SingleThreadTaskRunner* original_task_runner, | 74 base::SingleThreadTaskRunner* original_task_runner, |
76 const QuotaClient::DeletionCallback& callback, | 75 const QuotaClient::DeletionCallback& callback, |
77 int result) { | 76 int result) { |
78 if (result == net::ERR_IO_PENDING) { | 77 if (result == net::ERR_IO_PENDING) { |
79 // The callback will be invoked via | 78 // The callback will be invoked via |
80 // DatabaseTracker::ScheduleDatabasesForDeletion. | 79 // DatabaseTracker::ScheduleDatabasesForDeletion. |
81 return; | 80 return; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 143 } |
145 | 144 |
146 void DatabaseQuotaClient::GetOriginsForType( | 145 void DatabaseQuotaClient::GetOriginsForType( |
147 quota::StorageType type, | 146 quota::StorageType type, |
148 const GetOriginsCallback& callback) { | 147 const GetOriginsCallback& callback) { |
149 DCHECK(!callback.is_null()); | 148 DCHECK(!callback.is_null()); |
150 DCHECK(db_tracker_.get()); | 149 DCHECK(db_tracker_.get()); |
151 | 150 |
152 // All databases are in the temp namespace for now. | 151 // All databases are in the temp namespace for now. |
153 if (type != quota::kStorageTypeTemporary) { | 152 if (type != quota::kStorageTypeTemporary) { |
154 callback.Run(std::set<GURL>(), type); | 153 callback.Run(std::set<GURL>()); |
155 return; | 154 return; |
156 } | 155 } |
157 | 156 |
158 std::set<GURL>* origins_ptr = new std::set<GURL>(); | 157 std::set<GURL>* origins_ptr = new std::set<GURL>(); |
159 db_tracker_thread_->PostTaskAndReply( | 158 db_tracker_thread_->PostTaskAndReply( |
160 FROM_HERE, | 159 FROM_HERE, |
161 base::Bind(&GetOriginsOnDBThread, | 160 base::Bind(&GetOriginsOnDBThread, |
162 db_tracker_, | 161 db_tracker_, |
163 base::Unretained(origins_ptr)), | 162 base::Unretained(origins_ptr)), |
164 base::Bind(&DidGetOrigins, | 163 base::Bind(&DidGetOrigins, |
165 callback, | 164 callback, |
166 base::Owned(origins_ptr), | 165 base::Owned(origins_ptr))); |
167 type)); | |
168 } | 166 } |
169 | 167 |
170 void DatabaseQuotaClient::GetOriginsForHost( | 168 void DatabaseQuotaClient::GetOriginsForHost( |
171 quota::StorageType type, | 169 quota::StorageType type, |
172 const std::string& host, | 170 const std::string& host, |
173 const GetOriginsCallback& callback) { | 171 const GetOriginsCallback& callback) { |
174 DCHECK(!callback.is_null()); | 172 DCHECK(!callback.is_null()); |
175 DCHECK(db_tracker_.get()); | 173 DCHECK(db_tracker_.get()); |
176 | 174 |
177 // All databases are in the temp namespace for now. | 175 // All databases are in the temp namespace for now. |
178 if (type != quota::kStorageTypeTemporary) { | 176 if (type != quota::kStorageTypeTemporary) { |
179 callback.Run(std::set<GURL>(), type); | 177 callback.Run(std::set<GURL>()); |
180 return; | 178 return; |
181 } | 179 } |
182 | 180 |
183 std::set<GURL>* origins_ptr = new std::set<GURL>(); | 181 std::set<GURL>* origins_ptr = new std::set<GURL>(); |
184 db_tracker_thread_->PostTaskAndReply( | 182 db_tracker_thread_->PostTaskAndReply( |
185 FROM_HERE, | 183 FROM_HERE, |
186 base::Bind(&GetOriginsForHostOnDBThread, | 184 base::Bind(&GetOriginsForHostOnDBThread, |
187 db_tracker_, | 185 db_tracker_, |
188 base::Unretained(origins_ptr), | 186 base::Unretained(origins_ptr), |
189 host), | 187 host), |
190 base::Bind(&DidGetOrigins, | 188 base::Bind(&DidGetOrigins, |
191 callback, | 189 callback, |
192 base::Owned(origins_ptr), | 190 base::Owned(origins_ptr))); |
193 type)); | |
194 } | 191 } |
195 | 192 |
196 void DatabaseQuotaClient::DeleteOriginData( | 193 void DatabaseQuotaClient::DeleteOriginData( |
197 const GURL& origin, | 194 const GURL& origin, |
198 quota::StorageType type, | 195 quota::StorageType type, |
199 const DeletionCallback& callback) { | 196 const DeletionCallback& callback) { |
200 DCHECK(!callback.is_null()); | 197 DCHECK(!callback.is_null()); |
201 DCHECK(db_tracker_.get()); | 198 DCHECK(db_tracker_.get()); |
202 | 199 |
203 // All databases are in the temp namespace for now, so nothing to delete. | 200 // All databases are in the temp namespace for now, so nothing to delete. |
(...skipping 11 matching lines...) Expand all Loading... |
215 db_tracker_thread_, | 212 db_tracker_thread_, |
216 FROM_HERE, | 213 FROM_HERE, |
217 base::Bind(&DatabaseTracker::DeleteDataForOrigin, | 214 base::Bind(&DatabaseTracker::DeleteDataForOrigin, |
218 db_tracker_, | 215 db_tracker_, |
219 webkit_base::GetOriginIdentifierFromURL(origin), | 216 webkit_base::GetOriginIdentifierFromURL(origin), |
220 delete_callback), | 217 delete_callback), |
221 delete_callback); | 218 delete_callback); |
222 } | 219 } |
223 | 220 |
224 } // namespace webkit_database | 221 } // namespace webkit_database |
OLD | NEW |