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

Unified Diff: components/history/core/browser/history_backend.cc

Issue 2311723002: Move memory_coordinator_client and its registry to base/memory (Closed)
Patch Set: Update comments Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/history/core/browser/history_backend.cc
diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc
index ff46dd8c34b1032a78050d742cfe70eacf79389e..d92049f71f0fd19e42b304c6586d0cde80fb4702 100644
--- a/components/history/core/browser/history_backend.cc
+++ b/components/history/core/browser/history_backend.cc
@@ -41,7 +41,6 @@
#include "components/history/core/browser/page_usage_data.h"
#include "components/history/core/browser/typed_url_syncable_service.h"
#include "components/history/core/browser/url_utils.h"
-#include "components/memory_coordinator/browser/memory_coordinator.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "sql/error_delegate_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -237,11 +236,6 @@ HistoryBackend::~HistoryBackend() {
FROM_HERE, backend_destroy_task_);
}
- if (memory_coordinator::MemoryCoordinator::GetInstance()) {
- memory_coordinator::MemoryCoordinator::GetInstance()->UnregisterClient(
- this);
- }
-
#if defined(OS_ANDROID)
if (backend_client_ && !history_dir_.empty())
backend_client_->OnHistoryBackendDestroyed(this, history_dir_);
@@ -260,12 +254,8 @@ void HistoryBackend::Init(
InitImpl(history_database_params);
delegate_->DBLoaded();
typed_url_syncable_service_.reset(new TypedUrlSyncableService(this));
- if (memory_coordinator::MemoryCoordinator::GetInstance()) {
- memory_coordinator::MemoryCoordinator::GetInstance()->RegisterClient(this);
- } else {
- memory_pressure_listener_.reset(new base::MemoryPressureListener(
- base::Bind(&HistoryBackend::OnMemoryPressure, base::Unretained(this))));
- }
+ memory_pressure_listener_.reset(new base::MemoryPressureListener(
+ base::Bind(&HistoryBackend::OnMemoryPressure, base::Unretained(this))));
}
void HistoryBackend::SetOnBackendDestroyTask(base::MessageLoop* message_loop,
@@ -749,19 +739,15 @@ void HistoryBackend::InitImpl(
LOCAL_HISTOGRAM_TIMES("History.InitTime", TimeTicks::Now() - beginning_time);
}
-void HistoryBackend::TrimMemory(bool trim_aggressively) {
- if (db_)
- db_->TrimMemory(trim_aggressively);
- if (thumbnail_db_)
- thumbnail_db_->TrimMemory(trim_aggressively);
-}
-
void HistoryBackend::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
bool trim_aggressively =
memory_pressure_level ==
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL;
- TrimMemory(trim_aggressively);
+ if (db_)
+ db_->TrimMemory(trim_aggressively);
+ if (thumbnail_db_)
+ thumbnail_db_->TrimMemory(trim_aggressively);
}
void HistoryBackend::CloseAllDatabases() {
@@ -921,12 +907,6 @@ bool HistoryBackend::IsExpiredVisitTime(const base::Time& time) {
return time < expirer_.GetCurrentExpirationTime();
}
-void HistoryBackend::OnMemoryStateChange(
- memory_coordinator::MemoryState state) {
- bool trim_aggressively = state == memory_coordinator::MemoryState::SUSPENDED;
- TrimMemory(trim_aggressively);
-}
-
void HistoryBackend::SetPageTitle(const GURL& url,
const base::string16& title) {
if (!db_)
« no previous file with comments | « components/history/core/browser/history_backend.h ('k') | components/memory_coordinator/browser/memory_coordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698