Chromium Code Reviews| 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..23f41bb5c118f510fbb5983b800bc1340060bce7 100644 |
| --- a/components/web_cache/renderer/web_cache_render_process_observer.cc |
| +++ b/components/web_cache/renderer/web_cache_render_process_observer.cc |
| @@ -6,8 +6,10 @@ |
| #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; |
| @@ -24,11 +26,22 @@ 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) { |
|
Sam McNally
2016/02/23 02:37:33
Is this necessary?
leonhsl(Using Gerrit)
2016/02/23 07:58:49
Uh, I saw other calling codes(e.g. ChromeRenderPro
|
| + service_registry->AddService<WebCacheService>(base::Bind( |
|
Sam McNally
2016/02/23 02:37:33
Omit the template parameter. The compiler can dedu
leonhsl(Using Gerrit)
2016/02/23 07:58:49
Done.
|
| + &WebCacheRenderProcessObserver::BindRequest, base::Unretained(this))); |
| + } |
| } |
| WebCacheRenderProcessObserver::~WebCacheRenderProcessObserver() { |
| } |
| +void WebCacheRenderProcessObserver::BindRequest( |
| + mojo::InterfaceRequest<WebCacheService> web_cache_request) { |
| + bindings_.AddBinding(this, std::move(web_cache_request)); |
| +} |
| + |
| void WebCacheRenderProcessObserver::ExecutePendingClearCache() { |
| if (clear_cache_pending_ && webkit_initialized_) { |
| clear_cache_pending_ = false; |
| @@ -36,17 +49,6 @@ void WebCacheRenderProcessObserver::ExecutePendingClearCache() { |
| } |
| } |
| -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) { |
| @@ -60,13 +62,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; |
| @@ -78,7 +81,7 @@ void WebCacheRenderProcessObserver::OnSetCacheCapacities( |
| 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 |