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

Side by Side Diff: content/browser/dom_storage/dom_storage_context_impl_new.cc

Issue 9817011: DomStorage data deletion and memory purging. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | webkit/dom_storage/dom_storage_area.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/dom_storage/dom_storage_context_impl_new.h" 5 #include "content/browser/dom_storage/dom_storage_context_impl_new.h"
6 6
7 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND 7 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 27 matching lines...) Expand all
38 return DatabaseUtil::GetOriginFromIdentifier(origin_id); 38 return DatabaseUtil::GetOriginFromIdentifier(origin_id);
39 } 39 }
40 40
41 FilePath OriginToFullFilePath(const FilePath& directory, 41 FilePath OriginToFullFilePath(const FilePath& directory,
42 const GURL& origin) { 42 const GURL& origin) {
43 return directory.Append(DomStorageArea::DatabaseFileNameFromOrigin(origin)); 43 return directory.Append(DomStorageArea::DatabaseFileNameFromOrigin(origin));
44 } 44 }
45 45
46 GURL FilePathToOrigin(const FilePath& path) { 46 GURL FilePathToOrigin(const FilePath& path) {
47 DCHECK(path.MatchesExtension(DomStorageArea::kDatabaseFileExtension)); 47 DCHECK(path.MatchesExtension(DomStorageArea::kDatabaseFileExtension));
48 return OriginIdToGURL( 48 return DomStorageArea::OriginFromDatabaseFileName(path);
49 webkit_glue::FilePathToWebString(path.BaseName().RemoveExtension()));
50 } 49 }
51 50
52 void InvokeAllStorageFilesCallbackHelper( 51 void InvokeAllStorageFilesCallbackHelper(
53 const DOMStorageContext::GetAllStorageFilesCallback& callback, 52 const DOMStorageContext::GetAllStorageFilesCallback& callback,
54 const std::vector<FilePath>& file_paths) { 53 const std::vector<FilePath>& file_paths) {
55 callback.Run(file_paths); 54 callback.Run(file_paths);
56 } 55 }
57 56
58 void GetAllStorageFilesHelper( 57 void GetAllStorageFilesHelper(
59 base::MessageLoopProxy* reply_loop, 58 base::MessageLoopProxy* reply_loop,
60 DomStorageContext* context, 59 DomStorageContext* context,
61 const DOMStorageContext::GetAllStorageFilesCallback& callback) { 60 const DOMStorageContext::GetAllStorageFilesCallback& callback) {
62 std::vector<DomStorageContext::UsageInfo> infos; 61 std::vector<DomStorageContext::UsageInfo> infos;
63 context->GetUsageInfo(&infos); 62 // TODO(michaeln): Actually include the file info too when the
63 // content layer api is fixed.
64 const bool kDontIncludeFileInfo = false;
65 context->GetUsageInfo(&infos, kDontIncludeFileInfo);
64 66
65 std::vector<FilePath> paths; 67 std::vector<FilePath> paths;
66 for (size_t i = 0; i < infos.size(); ++i) { 68 for (size_t i = 0; i < infos.size(); ++i) {
67 paths.push_back( 69 paths.push_back(
68 OriginToFullFilePath(context->directory(), infos[i].origin)); 70 OriginToFullFilePath(context->directory(), infos[i].origin));
69 } 71 }
70 72
71 reply_loop->PostTask( 73 reply_loop->PostTask(
72 FROM_HERE, 74 FROM_HERE,
73 base::Bind(&InvokeAllStorageFilesCallbackHelper, 75 base::Bind(&InvokeAllStorageFilesCallbackHelper,
74 callback, paths)); 76 callback, paths));
75 } 77 }
76 78
77 } 79 } // namespace
78 80
79 DOMStorageContextImpl::DOMStorageContextImpl( 81 DOMStorageContextImpl::DOMStorageContextImpl(
80 const FilePath& data_path, 82 const FilePath& data_path,
81 quota::SpecialStoragePolicy* special_storage_policy) { 83 quota::SpecialStoragePolicy* special_storage_policy) {
82 base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool(); 84 base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool();
83 context_ = new dom_storage::DomStorageContext( 85 context_ = new dom_storage::DomStorageContext(
84 data_path.empty() ? 86 data_path.empty() ?
85 data_path : data_path.AppendASCII(kLocalStorageDirectory), 87 data_path : data_path.AppendASCII(kLocalStorageDirectory),
86 special_storage_policy, 88 special_storage_policy,
87 new DomStorageWorkerPoolTaskRunner( 89 new DomStorageWorkerPoolTaskRunner(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 DCHECK(context_); 177 DCHECK(context_);
176 int64 clone_id = context_->AllocateSessionId(); 178 int64 clone_id = context_->AllocateSessionId();
177 context_->task_runner()->PostTask( 179 context_->task_runner()->PostTask(
178 FROM_HERE, 180 FROM_HERE,
179 base::Bind(&DomStorageContext::CloneSessionNamespace, context_, 181 base::Bind(&DomStorageContext::CloneSessionNamespace, context_,
180 existing_namespace_id, clone_id)); 182 existing_namespace_id, clone_id));
181 return clone_id; 183 return clone_id;
182 } 184 }
183 185
184 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND 186 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND
OLDNEW
« no previous file with comments | « no previous file | webkit/dom_storage/dom_storage_area.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698