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

Unified Diff: webkit/database/database_tracker.cc

Issue 560024: Reland 37913. Clear local state on exit. (Closed)
Patch Set: Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/database/database_tracker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/database/database_tracker.cc
diff --git a/webkit/database/database_tracker.cc b/webkit/database/database_tracker.cc
index 01c3052dcc32c4f10512ef346d4999a5b7b4fc9b..489122e4cd46ad77d2935d1059a0e96941661895 100644
--- a/webkit/database/database_tracker.cc
+++ b/webkit/database/database_tracker.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,8 +14,11 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/string_util.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "webkit/database/databases_table.h"
#include "webkit/database/quota_table.h"
+#include "webkit/glue/webkit_glue.h"
namespace webkit_database {
@@ -331,4 +334,45 @@ int64 DatabaseTracker::UpdateCachedDatabaseFileSize(
return new_size;
}
+// static
+void DatabaseTracker::ClearLocalState(const FilePath& profile_path,
+ const char* url_scheme_to_be_skipped) {
+ FilePath db_dir = profile_path.Append(FilePath(kDatabaseDirectoryName));
+ FilePath db_tracker = db_dir.Append(FilePath(kTrackerDatabaseFileName));
+ if (file_util::DirectoryExists(db_dir) &&
+ file_util::PathExists(db_tracker)) {
+ scoped_ptr<sql::Connection> db_(new sql::Connection);
+ if (!db_->Open(db_tracker) ||
+ !db_->DoesTableExist("Databases")) {
+ db_->Close();
+ file_util::Delete(db_dir, true);
+ return;
+ } else {
+ sql::Statement delete_statement(db_->GetCachedStatement(
+ SQL_FROM_HERE, "DELETE FROM Databases WHERE origin NOT LIKE ?"));
+ std::string filter(url_scheme_to_be_skipped);
+ filter += "_%";
+ delete_statement.BindString(0, filter);
+ if (!delete_statement.Run()) {
+ db_->Close();
+ file_util::Delete(db_dir, true);
+ return;
+ }
+ }
+ }
+ file_util::FileEnumerator file_enumerator(db_dir, false,
+ file_util::FileEnumerator::DIRECTORIES);
+ for (FilePath file_path = file_enumerator.Next(); !file_path.empty();
+ file_path = file_enumerator.Next()) {
+ if (file_path.BaseName() != FilePath(kTrackerDatabaseFileName)) {
+ scoped_ptr<WebKit::WebSecurityOrigin> web_security_origin(
+ WebKit::WebSecurityOrigin::createFromDatabaseIdentifier(
+ webkit_glue::FilePathToWebString(file_path.BaseName())));
+ if (!EqualsASCII(web_security_origin->protocol(),
+ url_scheme_to_be_skipped))
+ file_util::Delete(file_path, true);
+ }
+ }
+}
+
} // namespace webkit_database
« no previous file with comments | « webkit/database/database_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698