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.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 Loading... |
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 Loading... |
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 |
OLD | NEW |