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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_context.cc

Issue 7470008: Improve IndexedDB's quota support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: style problems Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/in_process_webkit/indexed_db_context.h" 5 #include "content/browser/in_process_webkit/indexed_db_context.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 FilePath IndexedDBContext::GetIndexedDBFilePath( 95 FilePath IndexedDBContext::GetIndexedDBFilePath(
96 const string16& origin_id) const { 96 const string16& origin_id) const {
97 FilePath::StringType id = 97 FilePath::StringType id =
98 webkit_glue::WebStringToFilePathString(origin_id).append( 98 webkit_glue::WebStringToFilePathString(origin_id).append(
99 FILE_PATH_LITERAL(".indexeddb")); 99 FILE_PATH_LITERAL(".indexeddb"));
100 return data_path_.Append(id.append(kIndexedDBExtension)); 100 return data_path_.Append(id.append(kIndexedDBExtension));
101 } 101 }
102 102
103 void IndexedDBContext::DeleteIndexedDBFile(const FilePath& file_path) { 103 void IndexedDBContext::DeleteIndexedDBFile(const FilePath& file_path) {
104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
105 // TODO(pastarmovj): Close all database connections that use that file. 105 // TODO(pastarmovj): Close all database connections that use that file.
michaeln 2011/07/27 01:31:35 I see there is a close() method on WebIDBDatabase
dgrogan 2011/07/27 22:56:01 Yes, that's how they will be closed, but more work
106 file_util::Delete(file_path, false); 106 file_util::Delete(file_path, true /*recursive*/);
107 } 107 }
108 108
109 void IndexedDBContext::DeleteIndexedDBForOrigin(const string16& origin_id) { 109 void IndexedDBContext::DeleteIndexedDBForOrigin(const string16& origin_id) {
110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
111 // TODO(pastarmovj): Remove this check once we are safe to delete any time. 111 // TODO(pastarmovj): Remove this check once we are safe to delete any time.
112 FilePath idb_file = GetIndexedDBFilePath(origin_id); 112 FilePath idb_file = GetIndexedDBFilePath(origin_id);
113 DCHECK_EQ(idb_file.BaseName().value().substr(0, strlen("chrome-extension")), 113 DCHECK_EQ(idb_file.BaseName().value().substr(0, strlen("chrome-extension")),
114 FILE_PATH_LITERAL("chrome-extension")); 114 FILE_PATH_LITERAL("chrome-extension"));
115 DeleteIndexedDBFile(GetIndexedDBFilePath(origin_id)); 115 DeleteIndexedDBFile(GetIndexedDBFilePath(origin_id));
116 } 116 }
117 117
118 // TODO(dgrogan): Once we can delete IndexedDB directories out from underneath
119 // open webkit instances, merge this and DeleteIndexedDBForOrigin.
120 void IndexedDBContext::EvictOrigin(const string16& origin_id) {
michaeln 2011/07/27 01:31:35 This and the method above are functionally equival
dgrogan 2011/07/29 18:14:04 Correct.
121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
122 FilePath idb_directory = GetIndexedDBFilePath(origin_id);
123 DeleteIndexedDBFile(idb_directory);
124 }
125
118 bool IndexedDBContext::IsUnlimitedStorageGranted( 126 bool IndexedDBContext::IsUnlimitedStorageGranted(
119 const GURL& origin) const { 127 const GURL& origin) const {
120 return special_storage_policy_->IsStorageUnlimited(origin); 128 return special_storage_policy_->IsStorageUnlimited(origin);
121 } 129 }
122 130
123 // TODO(dgrogan): Merge this code with the similar loop in 131 // TODO(dgrogan): Merge this code with the similar loop in
124 // BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread. 132 // BrowsingDataIndexedDBHelperImpl::FetchIndexedDBInfoInWebKitThread.
125 void IndexedDBContext::GetAllOriginIdentifiers( 133 void IndexedDBContext::GetAllOriginIdentifiers(
126 std::vector<string16>* origin_ids) { 134 std::vector<string16>* origin_ids) {
127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
128 file_util::FileEnumerator file_enumerator(data_path_, 136 file_util::FileEnumerator file_enumerator(data_path_,
129 false, file_util::FileEnumerator::DIRECTORIES); 137 false, file_util::FileEnumerator::DIRECTORIES);
130 for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); 138 for (FilePath file_path = file_enumerator.Next(); !file_path.empty();
131 file_path = file_enumerator.Next()) { 139 file_path = file_enumerator.Next()) {
132 if (file_path.Extension() == IndexedDBContext::kIndexedDBExtension) { 140 if (file_path.Extension() == IndexedDBContext::kIndexedDBExtension) {
133 WebKit::WebString origin_id_webstring = 141 WebKit::WebString origin_id_webstring =
134 webkit_glue::FilePathToWebString(file_path.BaseName()); 142 webkit_glue::FilePathToWebString(file_path.BaseName());
135 origin_ids->push_back(origin_id_webstring); 143 origin_ids->push_back(origin_id_webstring);
136 } 144 }
137 } 145 }
138 } 146 }
139 147
140 quota::QuotaManagerProxy* IndexedDBContext::quota_manager_proxy() { 148 quota::QuotaManagerProxy* IndexedDBContext::quota_manager_proxy() {
141 return quota_manager_proxy_; 149 return quota_manager_proxy_;
142 } 150 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698