OLD | NEW |
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const DOMStorageContext::GetAllStorageFilesCallback& callback) { | 60 const DOMStorageContext::GetAllStorageFilesCallback& callback) { |
61 std::vector<DomStorageContext::UsageInfo> infos; | 61 std::vector<DomStorageContext::UsageInfo> infos; |
62 // TODO(michaeln): Actually include the file info too when the | 62 // TODO(michaeln): Actually include the file info too when the |
63 // content layer api is fixed. | 63 // content layer api is fixed. |
64 const bool kDontIncludeFileInfo = false; | 64 const bool kDontIncludeFileInfo = false; |
65 context->GetUsageInfo(&infos, kDontIncludeFileInfo); | 65 context->GetUsageInfo(&infos, kDontIncludeFileInfo); |
66 | 66 |
67 std::vector<FilePath> paths; | 67 std::vector<FilePath> paths; |
68 for (size_t i = 0; i < infos.size(); ++i) { | 68 for (size_t i = 0; i < infos.size(); ++i) { |
69 paths.push_back( | 69 paths.push_back( |
70 OriginToFullFilePath(context->directory(), infos[i].origin)); | 70 OriginToFullFilePath(context->localstorage_directory(), |
| 71 infos[i].origin)); |
71 } | 72 } |
72 | 73 |
73 reply_loop->PostTask( | 74 reply_loop->PostTask( |
74 FROM_HERE, | 75 FROM_HERE, |
75 base::Bind(&InvokeAllStorageFilesCallbackHelper, | 76 base::Bind(&InvokeAllStorageFilesCallbackHelper, |
76 callback, paths)); | 77 callback, paths)); |
77 } | 78 } |
78 | 79 |
79 } // namespace | 80 } // namespace |
80 | 81 |
81 DOMStorageContextImpl::DOMStorageContextImpl( | 82 DOMStorageContextImpl::DOMStorageContextImpl( |
82 const FilePath& data_path, | 83 const FilePath& data_path, |
83 quota::SpecialStoragePolicy* special_storage_policy) { | 84 quota::SpecialStoragePolicy* special_storage_policy) { |
84 base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool(); | 85 base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool(); |
| 86 // TODO(marja): Pass a nonempty session storage directory when session storage |
| 87 // is backed on disk. |
85 context_ = new dom_storage::DomStorageContext( | 88 context_ = new dom_storage::DomStorageContext( |
86 data_path.empty() ? | 89 data_path.empty() ? |
87 data_path : data_path.AppendASCII(kLocalStorageDirectory), | 90 data_path : data_path.AppendASCII(kLocalStorageDirectory), |
| 91 FilePath(), // Empty session storage directory. |
88 special_storage_policy, | 92 special_storage_policy, |
89 new DomStorageWorkerPoolTaskRunner( | 93 new DomStorageWorkerPoolTaskRunner( |
90 worker_pool, | 94 worker_pool, |
91 worker_pool->GetNamedSequenceToken("dom_storage_primary"), | 95 worker_pool->GetNamedSequenceToken("dom_storage_primary"), |
92 worker_pool->GetNamedSequenceToken("dom_storage_commit"), | 96 worker_pool->GetNamedSequenceToken("dom_storage_commit"), |
93 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 97 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
94 } | 98 } |
95 | 99 |
96 DOMStorageContextImpl::~DOMStorageContextImpl() { | 100 DOMStorageContextImpl::~DOMStorageContextImpl() { |
97 } | 101 } |
98 | 102 |
99 void DOMStorageContextImpl::GetAllStorageFiles( | 103 void DOMStorageContextImpl::GetAllStorageFiles( |
100 const GetAllStorageFilesCallback& callback) { | 104 const GetAllStorageFilesCallback& callback) { |
101 DCHECK(context_); | 105 DCHECK(context_); |
102 context_->task_runner()->PostShutdownBlockingTask( | 106 context_->task_runner()->PostShutdownBlockingTask( |
103 FROM_HERE, | 107 FROM_HERE, |
104 DomStorageTaskRunner::PRIMARY_SEQUENCE, | 108 DomStorageTaskRunner::PRIMARY_SEQUENCE, |
105 base::Bind(&GetAllStorageFilesHelper, | 109 base::Bind(&GetAllStorageFilesHelper, |
106 base::MessageLoopProxy::current(), | 110 base::MessageLoopProxy::current(), |
107 context_, callback)); | 111 context_, callback)); |
108 } | 112 } |
109 | 113 |
110 FilePath DOMStorageContextImpl::GetFilePath(const string16& origin_id) const { | 114 FilePath DOMStorageContextImpl::GetFilePath(const string16& origin_id) const { |
111 DCHECK(context_); | 115 DCHECK(context_); |
112 return OriginToFullFilePath(context_->directory(), OriginIdToGURL(origin_id)); | 116 return OriginToFullFilePath(context_->localstorage_directory(), |
| 117 OriginIdToGURL(origin_id)); |
113 } | 118 } |
114 | 119 |
115 void DOMStorageContextImpl::DeleteForOrigin(const string16& origin_id) { | 120 void DOMStorageContextImpl::DeleteForOrigin(const string16& origin_id) { |
116 DCHECK(context_); | 121 DCHECK(context_); |
117 context_->task_runner()->PostShutdownBlockingTask( | 122 context_->task_runner()->PostShutdownBlockingTask( |
118 FROM_HERE, | 123 FROM_HERE, |
119 DomStorageTaskRunner::PRIMARY_SEQUENCE, | 124 DomStorageTaskRunner::PRIMARY_SEQUENCE, |
120 base::Bind(&DomStorageContext::DeleteOrigin, context_, | 125 base::Bind(&DomStorageContext::DeleteOrigin, context_, |
121 OriginIdToGURL(origin_id))); | 126 OriginIdToGURL(origin_id))); |
122 } | 127 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 DCHECK(context_); | 182 DCHECK(context_); |
178 int64 clone_id = context_->AllocateSessionId(); | 183 int64 clone_id = context_->AllocateSessionId(); |
179 context_->task_runner()->PostTask( | 184 context_->task_runner()->PostTask( |
180 FROM_HERE, | 185 FROM_HERE, |
181 base::Bind(&DomStorageContext::CloneSessionNamespace, context_, | 186 base::Bind(&DomStorageContext::CloneSessionNamespace, context_, |
182 existing_namespace_id, clone_id)); | 187 existing_namespace_id, clone_id)); |
183 return clone_id; | 188 return clone_id; |
184 } | 189 } |
185 | 190 |
186 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND | 191 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND |
OLD | NEW |