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

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

Issue 1953703004: Purge browser cache for dom storage in a smarter way (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dom_storage
Patch Set: Fixes. Created 4 years, 7 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 (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 <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 void DOMStorageContextImpl::StartScavengingUnusedSessionStorage() { 390 void DOMStorageContextImpl::StartScavengingUnusedSessionStorage() {
391 if (session_storage_database_.get()) { 391 if (session_storage_database_.get()) {
392 task_runner_->PostDelayedTask( 392 task_runner_->PostDelayedTask(
393 FROM_HERE, base::Bind(&DOMStorageContextImpl::FindUnusedNamespaces, 393 FROM_HERE, base::Bind(&DOMStorageContextImpl::FindUnusedNamespaces,
394 this), 394 this),
395 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); 395 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds));
396 } 396 }
397 } 397 }
398 398
399 void DOMStorageContextImpl::OnMemoryPressure(
400 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
401 if (is_shutdown_)
402 return;
403
404 DOMStorageNamespace::PurgeOption option = DOMStorageNamespace::PURGE_UNOPENED;
405 if (memory_pressure_level ==
406 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL)
407 option = DOMStorageNamespace::PURGE_AGGRESSIVE;
408 for (const auto& it : namespaces_)
409 it.second->PurgeMemory(option);
410 }
411
399 bool DOMStorageContextImpl::OnMemoryDump( 412 bool DOMStorageContextImpl::OnMemoryDump(
400 const base::trace_event::MemoryDumpArgs& args, 413 const base::trace_event::MemoryDumpArgs& args,
401 base::trace_event::ProcessMemoryDump* pmd) { 414 base::trace_event::ProcessMemoryDump* pmd) {
402 for (const auto& it : namespaces_) { 415 for (const auto& it : namespaces_) {
403 it.second->OnMemoryDump(pmd); 416 it.second->OnMemoryDump(pmd);
404 } 417 }
405 if (session_storage_database_) 418 if (session_storage_database_)
406 session_storage_database_->OnMemoryDump(pmd); 419 session_storage_database_->OnMemoryDump(pmd);
407 return true; 420 return true;
408 } 421 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 if (!deletable_persistent_namespace_ids_.empty()) { 483 if (!deletable_persistent_namespace_ids_.empty()) {
471 task_runner_->PostDelayedTask( 484 task_runner_->PostDelayedTask(
472 FROM_HERE, base::Bind( 485 FROM_HERE, base::Bind(
473 &DOMStorageContextImpl::DeleteNextUnusedNamespace, 486 &DOMStorageContextImpl::DeleteNextUnusedNamespace,
474 this), 487 this),
475 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); 488 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds));
476 } 489 }
477 } 490 }
478 491
479 } // namespace content 492 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698