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

Side by Side Diff: chrome/browser/in_process_webkit/dom_storage_context.cc

Issue 546081: Adds local storage nodes to cookie tree model and cookies view. ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "chrome/browser/in_process_webkit/dom_storage_context.h" 5 #include "chrome/browser/in_process_webkit/dom_storage_context.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "chrome/browser/chrome_thread.h" 9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/in_process_webkit/dom_storage_area.h" 10 #include "chrome/browser/in_process_webkit/dom_storage_area.h"
11 #include "chrome/browser/in_process_webkit/dom_storage_namespace.h" 11 #include "chrome/browser/in_process_webkit/dom_storage_namespace.h"
12 #include "chrome/browser/in_process_webkit/webkit_context.h" 12 #include "chrome/browser/in_process_webkit/webkit_context.h"
13 #include "chrome/common/dom_storage_common.h" 13 #include "chrome/common/dom_storage_common.h"
14 #include "webkit/glue/glue_util.h"
14 15
15 static const char* kLocalStorageDirectory = "Local Storage"; 16 const FilePath::CharType DOMStorageContext::kLocalStorageDirectory[] =
17 FILE_PATH_LITERAL("Local Storage");
18
19 const FilePath::CharType DOMStorageContext::kLocalStorageExtension[] =
20 FILE_PATH_LITERAL(".localstorage");
21
22 static const FilePath::CharType kLocalStorageOldPath[] =
23 FILE_PATH_LITERAL("localStorage");
16 24
17 // TODO(jorlow): Remove after Chrome 4 ships. 25 // TODO(jorlow): Remove after Chrome 4 ships.
18 static void MigrateLocalStorageDirectory(const FilePath& data_path) { 26 static void MigrateLocalStorageDirectory(const FilePath& data_path) {
19 FilePath new_path = data_path.AppendASCII(kLocalStorageDirectory); 27 FilePath new_path = data_path.Append(
20 FilePath old_path = data_path.AppendASCII("localStorage"); 28 DOMStorageContext::kLocalStorageDirectory);
29 FilePath old_path = data_path.Append(kLocalStorageOldPath);
21 if (!file_util::DirectoryExists(new_path) && 30 if (!file_util::DirectoryExists(new_path) &&
22 file_util::DirectoryExists(old_path)) { 31 file_util::DirectoryExists(old_path)) {
23 file_util::Move(old_path, new_path); 32 file_util::Move(old_path, new_path);
24 } 33 }
25 } 34 }
26 35
27 DOMStorageContext::DOMStorageContext(WebKitContext* webkit_context) 36 DOMStorageContext::DOMStorageContext(WebKitContext* webkit_context)
28 : last_storage_area_id_(0), 37 : last_storage_area_id_(0),
29 last_session_storage_namespace_id_on_ui_thread_(kLocalStorageNamespaceId), 38 last_session_storage_namespace_id_on_ui_thread_(kLocalStorageNamespaceId),
30 last_session_storage_namespace_id_on_io_thread_(kLocalStorageNamespaceId), 39 last_session_storage_namespace_id_on_io_thread_(kLocalStorageNamespaceId),
(...skipping 21 matching lines...) Expand all
52 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); 61 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
53 DOMStorageNamespace* storage_namespace = GetStorageNamespace( 62 DOMStorageNamespace* storage_namespace = GetStorageNamespace(
54 kLocalStorageNamespaceId); 63 kLocalStorageNamespaceId);
55 if (storage_namespace) 64 if (storage_namespace)
56 return storage_namespace; 65 return storage_namespace;
57 66
58 FilePath data_path = webkit_context_->data_path(); 67 FilePath data_path = webkit_context_->data_path();
59 FilePath dir_path; 68 FilePath dir_path;
60 if (!data_path.empty()) { 69 if (!data_path.empty()) {
61 MigrateLocalStorageDirectory(data_path); 70 MigrateLocalStorageDirectory(data_path);
62 dir_path = data_path.AppendASCII(kLocalStorageDirectory); 71 dir_path = data_path.Append(kLocalStorageDirectory);
63 } 72 }
64 return DOMStorageNamespace::CreateLocalStorageNamespace(this, dir_path); 73 return DOMStorageNamespace::CreateLocalStorageNamespace(this, dir_path);
65 } 74 }
66 75
67 DOMStorageNamespace* DOMStorageContext::NewSessionStorage() { 76 DOMStorageNamespace* DOMStorageContext::NewSessionStorage() {
68 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); 77 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
69 return DOMStorageNamespace::CreateSessionStorageNamespace(this); 78 return DOMStorageNamespace::CreateSessionStorageNamespace(this);
70 } 79 }
71 80
72 int64 DOMStorageContext::AllocateStorageAreaId() { 81 int64 DOMStorageContext::AllocateStorageAreaId() {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if (local_storage) 177 if (local_storage)
169 local_storage->PurgeMemory(); 178 local_storage->PurgeMemory();
170 } 179 }
171 180
172 void DOMStorageContext::DeleteDataModifiedSince(const base::Time& cutoff) { 181 void DOMStorageContext::DeleteDataModifiedSince(const base::Time& cutoff) {
173 // Make sure that we don't delete a database that's currently being accessed 182 // Make sure that we don't delete a database that's currently being accessed
174 // by unloading all of the databases temporarily. 183 // by unloading all of the databases temporarily.
175 PurgeMemory(); 184 PurgeMemory();
176 185
177 file_util::FileEnumerator file_enumerator( 186 file_util::FileEnumerator file_enumerator(
178 webkit_context_->data_path().AppendASCII(kLocalStorageDirectory), false, 187 webkit_context_->data_path().Append(kLocalStorageDirectory), false,
179 file_util::FileEnumerator::FILES); 188 file_util::FileEnumerator::FILES);
180 for (FilePath path = file_enumerator.Next(); !path.value().empty(); 189 for (FilePath path = file_enumerator.Next(); !path.value().empty();
181 path = file_enumerator.Next()) { 190 path = file_enumerator.Next()) {
182 file_util::FileEnumerator::FindInfo find_info; 191 file_util::FileEnumerator::FindInfo find_info;
183 file_enumerator.GetFindInfo(&find_info); 192 file_enumerator.GetFindInfo(&find_info);
184 if (file_util::HasFileBeenModifiedSince(find_info, cutoff)) 193 if (file_util::HasFileBeenModifiedSince(find_info, cutoff))
185 file_util::Delete(path, false); 194 file_util::Delete(path, false);
186 } 195 }
187 } 196 }
188 197
198 void DOMStorageContext::DeleteLocalStorageFile(const FilePath& file_path) {
199 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
200
201 // Make sure that we don't delete a database that's currently being accessed
202 // by unloading all of the databases temporarily.
203 // TODO(bulach): both this method and DeleteDataModifiedSince could purge
204 // only the memory used by the specific file instead of all memory at once.
205 // See http://code.google.com/p/chromium/issues/detail?id=32000
206 PurgeMemory();
207 file_util::Delete(file_path, false);
208 }
209
210 void DOMStorageContext::DeleteAllLocalStorageFiles() {
211 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
212
213 // Make sure that we don't delete a database that's currently being accessed
214 // by unloading all of the databases temporarily.
215 PurgeMemory();
216
217 file_util::FileEnumerator file_enumerator(
218 webkit_context_->data_path().Append(kLocalStorageDirectory), false,
219 file_util::FileEnumerator::FILES);
220 for (FilePath file_path = file_enumerator.Next(); !file_path.empty();
221 file_path = file_enumerator.Next()) {
222 if (file_path.Extension() == kLocalStorageExtension)
223 file_util::Delete(file_path, false);
224 }
225 }
226
189 void DOMStorageContext::CompleteCloningSessionStorage( 227 void DOMStorageContext::CompleteCloningSessionStorage(
190 DOMStorageContext* context, int64 existing_id, int64 clone_id) { 228 DOMStorageContext* context, int64 existing_id, int64 clone_id) {
191 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); 229 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
192 DOMStorageNamespace* existing_namespace = 230 DOMStorageNamespace* existing_namespace =
193 context->GetStorageNamespace(existing_id); 231 context->GetStorageNamespace(existing_id);
194 // If nothing exists, then there's nothing to clone. 232 // If nothing exists, then there's nothing to clone.
195 if (existing_namespace) 233 if (existing_namespace)
196 existing_namespace->Copy(clone_id); 234 existing_namespace->Copy(clone_id);
197 } 235 }
OLDNEW
« no previous file with comments | « chrome/browser/in_process_webkit/dom_storage_context.h ('k') | chrome/browser/views/options/cookies_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698