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

Unified Diff: chrome/browser/in_process_webkit/indexed_db_context.cc

Issue 5359005: Moved deleting the indexed db context to the WebKitContext destructor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Niptucked. Created 10 years, 1 month 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
Index: chrome/browser/in_process_webkit/indexed_db_context.cc
diff --git a/chrome/browser/in_process_webkit/indexed_db_context.cc b/chrome/browser/in_process_webkit/indexed_db_context.cc
index 7f492ac563930143b584c4bc3142696a0ff5bfd9..7aeb1b41283b213dbefd816eb204b21fb72f9011 100644
--- a/chrome/browser/in_process_webkit/indexed_db_context.cc
+++ b/chrome/browser/in_process_webkit/indexed_db_context.cc
@@ -10,6 +10,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/in_process_webkit/webkit_context.h"
+#include "chrome/common/url_constants.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabase.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h"
@@ -21,17 +22,45 @@ using WebKit::WebIDBDatabase;
using WebKit::WebIDBFactory;
using WebKit::WebSecurityOrigin;
+namespace {
+
+void ClearLocalState(const FilePath& indexeddb_path,
+ const char* url_scheme_to_be_skipped) {
+ file_util::FileEnumerator file_enumerator(
+ indexeddb_path, false, file_util::FileEnumerator::FILES);
+ // TODO(pastarmovj): We might need to consider exchanging this loop for
+ // something more efficient in the future.
+ for (FilePath file_path = file_enumerator.Next(); !file_path.empty();
+ file_path = file_enumerator.Next()) {
+ if (file_path.Extension() != IndexedDBContext::kIndexedDBExtension)
+ continue;
+ WebSecurityOrigin origin =
+ WebSecurityOrigin::createFromDatabaseIdentifier(
+ webkit_glue::FilePathToWebString(file_path.BaseName()));
+ if (!EqualsASCII(origin.protocol(), url_scheme_to_be_skipped))
+ file_util::Delete(file_path, false);
+ }
+}
+
+} // namespace
+
const FilePath::CharType IndexedDBContext::kIndexedDBDirectory[] =
FILE_PATH_LITERAL("IndexedDB");
const FilePath::CharType IndexedDBContext::kIndexedDBExtension[] =
FILE_PATH_LITERAL(".indexeddb");
-IndexedDBContext::IndexedDBContext(WebKitContext* webkit_context)
- : webkit_context_(webkit_context) {
+IndexedDBContext::IndexedDBContext(WebKitContext* webkit_context) {
+ data_path_ = webkit_context->data_path().Append(kIndexedDBDirectory);
}
IndexedDBContext::~IndexedDBContext() {
+ // Not being on the WEBKIT thread here means we are running in a unit test
+ // where no clean up is needed.
+ if (clear_local_state_on_exit_ &&
+ BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)) {
+ ClearLocalState(data_path_, chrome::kExtensionScheme);
+ }
}
WebIDBFactory* IndexedDBContext::GetIDBFactory() {
@@ -43,29 +72,8 @@ WebIDBFactory* IndexedDBContext::GetIDBFactory() {
FilePath IndexedDBContext::GetIndexedDBFilePath(
const string16& origin_id) const {
- FilePath storage_dir = webkit_context_->data_path().Append(
- kIndexedDBDirectory);
FilePath::StringType id = webkit_glue::WebStringToFilePathString(origin_id);
- return storage_dir.Append(id.append(kIndexedDBExtension));
-}
-
-// static
-void IndexedDBContext::ClearLocalState(const FilePath& profile_path,
- const char* url_scheme_to_be_skipped) {
- file_util::FileEnumerator file_enumerator(profile_path.Append(
- kIndexedDBDirectory), false, file_util::FileEnumerator::FILES);
- // TODO(pastarmovj): We might need to consider exchanging this loop for
- // something more efficient in the future.
- for (FilePath file_path = file_enumerator.Next(); !file_path.empty();
- file_path = file_enumerator.Next()) {
- if (file_path.Extension() != IndexedDBContext::kIndexedDBExtension)
- continue;
- WebSecurityOrigin origin =
- WebSecurityOrigin::createFromDatabaseIdentifier(
- webkit_glue::FilePathToWebString(file_path.BaseName()));
- if (!EqualsASCII(origin.protocol(), url_scheme_to_be_skipped))
- file_util::Delete(file_path, false);
- }
+ return data_path_.Append(id.append(kIndexedDBExtension));
}
void IndexedDBContext::DeleteIndexedDBFile(const FilePath& file_path) {
« no previous file with comments | « chrome/browser/in_process_webkit/indexed_db_context.h ('k') | chrome/browser/in_process_webkit/webkit_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698