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

Unified Diff: components/web_cache/browser/web_cache_manager.cc

Issue 1706603004: Replace web_cache_messages.h with Mojo service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/web_cache/browser/web_cache_manager.cc
diff --git a/components/web_cache/browser/web_cache_manager.cc b/components/web_cache/browser/web_cache_manager.cc
index 66076e904d6cb7361cc182a92573303b134ac28c..a7e7dd925f6c94a0df2fcd3179d669f9406a4d9c 100644
--- a/components/web_cache/browser/web_cache_manager.cc
+++ b/components/web_cache/browser/web_cache_manager.cc
@@ -19,10 +19,10 @@
#include "base/time/time.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
-#include "components/web_cache/common/web_cache_messages.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/common/service_registry.h"
using base::Time;
using base::TimeDelta;
@@ -90,6 +90,18 @@ void WebCacheManager::Add(int renderer_id) {
memset(stats, 0, sizeof(*stats));
stats->access = Time::Now();
+ WebCacheServicePtr* service_ptr = web_cache_services_[renderer_id];
+ if (service_ptr)
+ delete service_ptr;
+ service_ptr = new WebCacheServicePtr();
+ web_cache_services_[renderer_id] = service_ptr;
+
+ content::RenderProcessHost* host =
+ content::RenderProcessHost::FromID(renderer_id);
+ DCHECK(host);
+ host->GetServiceRegistry()->ConnectToRemoteService(
+ mojo::GetProxy(service_ptr));
+
// Revise our allocation strategy to account for this new renderer.
ReviseAllocationStrategyLater();
}
@@ -100,6 +112,11 @@ void WebCacheManager::Remove(int renderer_id) {
inactive_renderers_.erase(renderer_id);
stats_.erase(renderer_id);
+ WebCacheServicePtr* service_ptr = web_cache_services_[renderer_id];
+ if (service_ptr)
+ delete service_ptr;
+ web_cache_services_.erase(renderer_id);
+
// Reallocate the resources used by this renderer
ReviseAllocationStrategyLater();
}
@@ -329,9 +346,10 @@ void WebCacheManager::EnactStrategy(const AllocationStrategy& strategy) {
max_dead_capacity);
}
- host->Send(new WebCacheMsg_SetCacheCapacities(min_dead_capacity,
- max_dead_capacity,
- capacity));
+ WebCacheServicePtr* service_ptr = web_cache_services_[allocation->first];
+ DCHECK(service_ptr->get());
+ (*service_ptr)
+ ->SetCacheCapacities(min_dead_capacity, max_dead_capacity, capacity);
}
++allocation;
}
@@ -350,8 +368,11 @@ void WebCacheManager::ClearRendererCache(
for (; iter != renderers.end(); ++iter) {
content::RenderProcessHost* host =
content::RenderProcessHost::FromID(*iter);
- if (host)
- host->Send(new WebCacheMsg_ClearCache(occasion == ON_NAVIGATION));
+ if (host) {
+ WebCacheServicePtr* service_ptr = web_cache_services_[*iter];
+ DCHECK(service_ptr->get());
+ (*service_ptr)->ClearCache(occasion == ON_NAVIGATION);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698