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

Unified Diff: components/web_cache/renderer/web_cache_render_process_observer.cc

Issue 1706603004: Replace web_cache_messages.h with Mojo service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase only Created 4 years, 9 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/renderer/web_cache_render_process_observer.cc
diff --git a/components/web_cache/renderer/web_cache_render_process_observer.cc b/components/web_cache/renderer/web_cache_render_process_observer.cc
index 1d122538b2b6ba567a7f9c39c95ec7ed4fa4ce7d..f6ec4d57b20076b450566f253544685a3348e77d 100644
--- a/components/web_cache/renderer/web_cache_render_process_observer.cc
+++ b/components/web_cache/renderer/web_cache_render_process_observer.cc
@@ -6,12 +6,12 @@
#include <limits>
+#include "base/bind.h"
#include "base/numerics/safe_conversions.h"
-#include "components/web_cache/common/web_cache_messages.h"
+#include "content/public/common/service_registry.h"
+#include "content/public/renderer/render_thread.h"
#include "third_party/WebKit/public/web/WebCache.h"
-using blink::WebCache;
-
namespace web_cache {
namespace {
@@ -24,35 +24,35 @@ WebCacheRenderProcessObserver::WebCacheRenderProcessObserver()
pending_cache_min_dead_capacity_(0),
pending_cache_max_dead_capacity_(0),
pending_cache_capacity_(kUnitializedCacheCapacity) {
+ content::ServiceRegistry* service_registry =
+ content::RenderThread::Get()->GetServiceRegistry();
+ if (service_registry) {
+ service_registry->AddService(base::Bind(
+ &WebCacheRenderProcessObserver::BindRequest, base::Unretained(this)));
+ }
}
WebCacheRenderProcessObserver::~WebCacheRenderProcessObserver() {
}
+void WebCacheRenderProcessObserver::BindRequest(
+ mojo::InterfaceRequest<mojom::WebCache> web_cache_request) {
+ bindings_.AddBinding(this, std::move(web_cache_request));
+}
+
void WebCacheRenderProcessObserver::ExecutePendingClearCache() {
if (clear_cache_pending_ && webkit_initialized_) {
clear_cache_pending_ = false;
- WebCache::clear();
+ blink::WebCache::clear();
}
}
-bool WebCacheRenderProcessObserver::OnControlMessageReceived(
- const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(WebCacheRenderProcessObserver, message)
- IPC_MESSAGE_HANDLER(WebCacheMsg_SetCacheCapacities, OnSetCacheCapacities)
- IPC_MESSAGE_HANDLER(WebCacheMsg_ClearCache, OnClearCache)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
void WebCacheRenderProcessObserver::WebKitInitialized() {
webkit_initialized_ = true;
if (pending_cache_capacity_ != kUnitializedCacheCapacity) {
- WebCache::setCapacities(pending_cache_min_dead_capacity_,
- pending_cache_max_dead_capacity_,
- pending_cache_capacity_);
+ blink::WebCache::setCapacities(pending_cache_min_dead_capacity_,
+ pending_cache_max_dead_capacity_,
+ pending_cache_capacity_);
}
}
@@ -60,13 +60,14 @@ void WebCacheRenderProcessObserver::OnRenderProcessShutdown() {
webkit_initialized_ = false;
}
-void WebCacheRenderProcessObserver::OnSetCacheCapacities(
+void WebCacheRenderProcessObserver::SetCacheCapacities(
uint64_t min_dead_capacity,
uint64_t max_dead_capacity,
uint64_t capacity64) {
size_t min_dead_capacity2 = base::checked_cast<size_t>(min_dead_capacity);
size_t max_dead_capacity2 = base::checked_cast<size_t>(max_dead_capacity);
size_t capacity = base::checked_cast<size_t>(capacity64);
+
if (!webkit_initialized_) {
pending_cache_min_dead_capacity_ = min_dead_capacity2;
pending_cache_max_dead_capacity_ = max_dead_capacity2;
@@ -74,15 +75,15 @@ void WebCacheRenderProcessObserver::OnSetCacheCapacities(
return;
}
- WebCache::setCapacities(
- min_dead_capacity2, max_dead_capacity2, capacity);
+ blink::WebCache::setCapacities(min_dead_capacity2, max_dead_capacity2,
+ capacity);
}
-void WebCacheRenderProcessObserver::OnClearCache(bool on_navigation) {
+void WebCacheRenderProcessObserver::ClearCache(bool on_navigation) {
if (on_navigation || !webkit_initialized_)
clear_cache_pending_ = true;
else
- WebCache::clear();
+ blink::WebCache::clear();
}
} // namespace web_cache

Powered by Google App Engine
This is Rietveld 408576698