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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_database_helper.cc

Issue 124183002: Implement delete methods for the various CannedBrowsingDataHelpers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 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 | Annotate | Revision Log
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 "chrome/browser/browsing_data/browsing_data_database_helper.h" 5 #include "chrome/browser/browsing_data/browsing_data_database_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/browsing_data/browsing_data_helper.h" 11 #include "chrome/browser/browsing_data/browsing_data_helper.h"
13 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
14 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/storage_partition.h" 14 #include "content/public/browser/storage_partition.h"
16 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
17 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
18 #include "webkit/common/database/database_identifier.h" 17 #include "webkit/common/database/database_identifier.h"
19 18
20 using content::BrowserContext; 19 using content::BrowserContext;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 183 }
185 184
186 const std::set<CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo>& 185 const std::set<CannedBrowsingDataDatabaseHelper::PendingDatabaseInfo>&
187 CannedBrowsingDataDatabaseHelper::GetPendingDatabaseInfo() { 186 CannedBrowsingDataDatabaseHelper::GetPendingDatabaseInfo() {
188 return pending_database_info_; 187 return pending_database_info_;
189 } 188 }
190 189
191 void CannedBrowsingDataDatabaseHelper::StartFetching( 190 void CannedBrowsingDataDatabaseHelper::StartFetching(
192 const base::Callback<void(const std::list<DatabaseInfo>&)>& callback) { 191 const base::Callback<void(const std::list<DatabaseInfo>&)>& callback) {
193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
194 DCHECK(!is_fetching_); 193 DCHECK(!callback.is_null());
195 DCHECK_EQ(false, callback.is_null());
196 194
197 is_fetching_ = true; 195 std::list<DatabaseInfo> result;
198 completion_callback_ = callback;
199
200 database_info_.clear();
201 for (std::set<PendingDatabaseInfo>::const_iterator 196 for (std::set<PendingDatabaseInfo>::const_iterator
202 info = pending_database_info_.begin(); 197 info = pending_database_info_.begin();
203 info != pending_database_info_.end(); ++info) { 198 info != pending_database_info_.end(); ++info) {
204 DatabaseIdentifier identifier = 199 DatabaseIdentifier identifier =
205 DatabaseIdentifier::CreateFromOrigin(info->origin); 200 DatabaseIdentifier::CreateFromOrigin(info->origin);
206 201
207 database_info_.push_back(DatabaseInfo( 202 result.push_back(DatabaseInfo(
208 identifier, 203 identifier,
209 info->name, 204 info->name,
210 info->description, 205 info->description,
211 0, 206 0,
212 base::Time())); 207 base::Time()));
213 } 208 }
214 209
215 BrowserThread::PostTask( 210 BrowserThread::PostTask(
216 BrowserThread::UI, FROM_HERE, 211 BrowserThread::UI, FROM_HERE, base::Bind(callback, result));
217 base::Bind(&CannedBrowsingDataDatabaseHelper::NotifyInUIThread, this)); 212 }
213
214 void CannedBrowsingDataDatabaseHelper::DeleteDatabase(
215 const std::string& origin_identifier,
216 const std::string& name) {
217 GURL origin =
218 webkit_database::DatabaseIdentifier::Parse(origin_identifier).ToOrigin();
219 for (std::set<PendingDatabaseInfo>::iterator it =
220 pending_database_info_.begin();
221 it != pending_database_info_.end();
222 ++it) {
223 if (it->origin == origin && it->name == name) {
224 pending_database_info_.erase(it);
225 break;
226 }
227 }
228 BrowsingDataDatabaseHelper::DeleteDatabase(origin_identifier, name);
218 } 229 }
219 230
220 CannedBrowsingDataDatabaseHelper::~CannedBrowsingDataDatabaseHelper() {} 231 CannedBrowsingDataDatabaseHelper::~CannedBrowsingDataDatabaseHelper() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698