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

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

Issue 2788813002: Try to flush DOMStorage too when ending the browsing session.
Patch Set: fixes Created 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_wrapper.h" 5 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 context_->task_runner()->PostShutdownBlockingTask( 241 context_->task_runner()->PostShutdownBlockingTask(
242 FROM_HERE, 242 FROM_HERE,
243 DOMStorageTaskRunner::PRIMARY_SEQUENCE, 243 DOMStorageTaskRunner::PRIMARY_SEQUENCE,
244 base::Bind(&DOMStorageContextImpl::Shutdown, context_)); 244 base::Bind(&DOMStorageContextImpl::Shutdown, context_));
245 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { 245 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
246 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); 246 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
247 } 247 }
248 248
249 } 249 }
250 250
251 void DOMStorageContextWrapper::Flush() { 251 std::vector<scoped_refptr<base::SequencedTaskRunner>>
252 DOMStorageContextWrapper::Flush() {
252 DCHECK(context_.get()); 253 DCHECK(context_.get());
254 std::vector<scoped_refptr<base::SequencedTaskRunner>> flush_runners;
255 if (mojo_state_) {
256 mojo_state_->Flush();
257 // TODO(michaeln): Add mojo impl task runners to flush_runners
Marijn Kruisselbrink 2017/04/12 21:55:58 I'm a bit confused about the implied semantics of
258 }
253 context_->task_runner()->PostShutdownBlockingTask( 259 context_->task_runner()->PostShutdownBlockingTask(
254 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, 260 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE,
255 base::Bind(&DOMStorageContextImpl::Flush, context_)); 261 base::Bind(&DOMStorageContextImpl::Flush, context_));
256 if (mojo_state_) 262 flush_runners.push_back(context_->task_runner()->GetSequencedTaskRunner(
257 mojo_state_->Flush(); 263 DOMStorageTaskRunner::PRIMARY_SEQUENCE));
264 flush_runners.push_back(context_->task_runner()->GetSequencedTaskRunner(
265 DOMStorageTaskRunner::COMMIT_SEQUENCE));
266 return flush_runners;
258 } 267 }
259 268
260 void DOMStorageContextWrapper::OpenLocalStorage( 269 void DOMStorageContextWrapper::OpenLocalStorage(
261 const url::Origin& origin, 270 const url::Origin& origin,
262 mojom::LevelDBWrapperRequest request) { 271 mojom::LevelDBWrapperRequest request) {
263 if (!mojo_state_) 272 if (!mojo_state_)
264 return; 273 return;
265 mojo_state_->OpenLocalStorage(origin, std::move(request)); 274 mojo_state_->OpenLocalStorage(origin, std::move(request));
266 } 275 }
267 276
(...skipping 25 matching lines...) Expand all
293 GetLocalStorageUsageCallback callback, 302 GetLocalStorageUsageCallback callback,
294 std::vector<LocalStorageUsageInfo> usage) { 303 std::vector<LocalStorageUsageInfo> usage) {
295 context_->task_runner()->PostShutdownBlockingTask( 304 context_->task_runner()->PostShutdownBlockingTask(
296 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, 305 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE,
297 base::Bind(&GetLocalStorageUsageHelper, base::Passed(&usage), 306 base::Bind(&GetLocalStorageUsageHelper, base::Passed(&usage),
298 base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), 307 base::RetainedRef(base::ThreadTaskRunnerHandle::Get()),
299 base::RetainedRef(context_), callback)); 308 base::RetainedRef(context_), callback));
300 } 309 }
301 310
302 } // namespace content 311 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_wrapper.h ('k') | content/browser/storage_partition_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698