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

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

Issue 9999021: Don't hardcode the "Local Storage" directory name in DomStorageContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased better. Created 8 years, 8 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_context.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.h" 5 #include "content/browser/dom_storage/dom_storage_context_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 const DOMStorageContext::GetAllStorageFilesCallback& callback) { 58 const DOMStorageContext::GetAllStorageFilesCallback& callback) {
59 std::vector<DomStorageContext::UsageInfo> infos; 59 std::vector<DomStorageContext::UsageInfo> infos;
60 // TODO(michaeln): Actually include the file info too when the 60 // TODO(michaeln): Actually include the file info too when the
61 // content layer api is fixed. 61 // content layer api is fixed.
62 const bool kDontIncludeFileInfo = false; 62 const bool kDontIncludeFileInfo = false;
63 context->GetUsageInfo(&infos, kDontIncludeFileInfo); 63 context->GetUsageInfo(&infos, kDontIncludeFileInfo);
64 64
65 std::vector<FilePath> paths; 65 std::vector<FilePath> paths;
66 for (size_t i = 0; i < infos.size(); ++i) { 66 for (size_t i = 0; i < infos.size(); ++i) {
67 paths.push_back( 67 paths.push_back(
68 OriginToFullFilePath(context->directory(), infos[i].origin)); 68 OriginToFullFilePath(context->localstorage_directory(),
69 infos[i].origin));
69 } 70 }
70 71
71 reply_loop->PostTask( 72 reply_loop->PostTask(
72 FROM_HERE, 73 FROM_HERE,
73 base::Bind(&InvokeAllStorageFilesCallbackHelper, 74 base::Bind(&InvokeAllStorageFilesCallbackHelper,
74 callback, paths)); 75 callback, paths));
75 } 76 }
76 77
77 } // namespace 78 } // namespace
78 79
79 DOMStorageContextImpl::DOMStorageContextImpl( 80 DOMStorageContextImpl::DOMStorageContextImpl(
80 const FilePath& data_path, 81 const FilePath& data_path,
81 quota::SpecialStoragePolicy* special_storage_policy) { 82 quota::SpecialStoragePolicy* special_storage_policy) {
82 base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool(); 83 base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool();
84 // TODO(marja): Pass a nonempty session storage directory when session storage
85 // is backed on disk.
83 context_ = new dom_storage::DomStorageContext( 86 context_ = new dom_storage::DomStorageContext(
84 data_path.empty() ? 87 data_path.empty() ?
85 data_path : data_path.AppendASCII(kLocalStorageDirectory), 88 data_path : data_path.AppendASCII(kLocalStorageDirectory),
89 FilePath(), // Empty session storage directory.
86 special_storage_policy, 90 special_storage_policy,
87 new DomStorageWorkerPoolTaskRunner( 91 new DomStorageWorkerPoolTaskRunner(
88 worker_pool, 92 worker_pool,
89 worker_pool->GetNamedSequenceToken("dom_storage_primary"), 93 worker_pool->GetNamedSequenceToken("dom_storage_primary"),
90 worker_pool->GetNamedSequenceToken("dom_storage_commit"), 94 worker_pool->GetNamedSequenceToken("dom_storage_commit"),
91 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); 95 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
92 } 96 }
93 97
94 DOMStorageContextImpl::~DOMStorageContextImpl() { 98 DOMStorageContextImpl::~DOMStorageContextImpl() {
95 } 99 }
96 100
97 void DOMStorageContextImpl::GetAllStorageFiles( 101 void DOMStorageContextImpl::GetAllStorageFiles(
98 const GetAllStorageFilesCallback& callback) { 102 const GetAllStorageFilesCallback& callback) {
99 DCHECK(context_); 103 DCHECK(context_);
100 context_->task_runner()->PostShutdownBlockingTask( 104 context_->task_runner()->PostShutdownBlockingTask(
101 FROM_HERE, 105 FROM_HERE,
102 DomStorageTaskRunner::PRIMARY_SEQUENCE, 106 DomStorageTaskRunner::PRIMARY_SEQUENCE,
103 base::Bind(&GetAllStorageFilesHelper, 107 base::Bind(&GetAllStorageFilesHelper,
104 base::MessageLoopProxy::current(), 108 base::MessageLoopProxy::current(),
105 context_, callback)); 109 context_, callback));
106 } 110 }
107 111
108 FilePath DOMStorageContextImpl::GetFilePath(const string16& origin_id) const { 112 FilePath DOMStorageContextImpl::GetFilePath(const string16& origin_id) const {
109 DCHECK(context_); 113 DCHECK(context_);
110 return OriginToFullFilePath(context_->directory(), OriginIdToGURL(origin_id)); 114 return OriginToFullFilePath(context_->localstorage_directory(),
115 OriginIdToGURL(origin_id));
111 } 116 }
112 117
113 void DOMStorageContextImpl::DeleteForOrigin(const string16& origin_id) { 118 void DOMStorageContextImpl::DeleteForOrigin(const string16& origin_id) {
114 DCHECK(context_); 119 DCHECK(context_);
115 context_->task_runner()->PostShutdownBlockingTask( 120 context_->task_runner()->PostShutdownBlockingTask(
116 FROM_HERE, 121 FROM_HERE,
117 DomStorageTaskRunner::PRIMARY_SEQUENCE, 122 DomStorageTaskRunner::PRIMARY_SEQUENCE,
118 base::Bind(&DomStorageContext::DeleteOrigin, context_, 123 base::Bind(&DomStorageContext::DeleteOrigin, context_,
119 OriginIdToGURL(origin_id))); 124 OriginIdToGURL(origin_id)));
120 } 125 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 int64 DOMStorageContextImpl::LeakyCloneSessionStorage( 178 int64 DOMStorageContextImpl::LeakyCloneSessionStorage(
174 int64 existing_namespace_id) { 179 int64 existing_namespace_id) {
175 DCHECK(context_); 180 DCHECK(context_);
176 int64 clone_id = context_->AllocateSessionId(); 181 int64 clone_id = context_->AllocateSessionId();
177 context_->task_runner()->PostTask( 182 context_->task_runner()->PostTask(
178 FROM_HERE, 183 FROM_HERE,
179 base::Bind(&DomStorageContext::CloneSessionNamespace, context_, 184 base::Bind(&DomStorageContext::CloneSessionNamespace, context_,
180 existing_namespace_id, clone_id)); 185 existing_namespace_id, clone_id));
181 return clone_id; 186 return clone_id;
182 } 187 }
OLDNEW
« no previous file with comments | « no previous file | webkit/dom_storage/dom_storage_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698