| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_WEB_CACHE_RENDERER_WEB_CACHE_RENDER_PROCESS_OBSERVER_H_ | 5 #ifndef COMPONENTS_WEB_CACHE_RENDERER_WEB_CACHE_RENDER_PROCESS_OBSERVER_H_ |
| 6 #define COMPONENTS_WEB_CACHE_RENDERER_WEB_CACHE_RENDER_PROCESS_OBSERVER_H_ | 6 #define COMPONENTS_WEB_CACHE_RENDERER_WEB_CACHE_RENDER_PROCESS_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/web_cache/public/interfaces/web_cache_service.mojom.h" |
| 13 #include "content/public/renderer/render_process_observer.h" | 14 #include "content/public/renderer/render_process_observer.h" |
| 15 #include "mojo/public/cpp/bindings/weak_binding_set.h" |
| 14 | 16 |
| 15 namespace web_cache { | 17 namespace web_cache { |
| 16 | 18 |
| 17 // This class filters the incoming cache related control messages. | 19 using mojom::WebCacheService; |
| 18 class WebCacheRenderProcessObserver : public content::RenderProcessObserver { | 20 |
| 21 // This class implements the Mojo interface WebCacheService. |
| 22 class WebCacheRenderProcessObserver : public WebCacheService, |
| 23 public content::RenderProcessObserver { |
| 19 public: | 24 public: |
| 20 WebCacheRenderProcessObserver(); | 25 WebCacheRenderProcessObserver(); |
| 21 ~WebCacheRenderProcessObserver() override; | 26 ~WebCacheRenderProcessObserver() override; |
| 22 | 27 |
| 28 void BindRequest(mojo::InterfaceRequest<WebCacheService> web_cache_request); |
| 29 |
| 23 // Needs to be called by RenderViews in case of navigations to execute | 30 // Needs to be called by RenderViews in case of navigations to execute |
| 24 // any 'clear cache' commands that were delayed until the next navigation. | 31 // any 'clear cache' commands that were delayed until the next navigation. |
| 25 void ExecutePendingClearCache(); | 32 void ExecutePendingClearCache(); |
| 26 | 33 |
| 27 private: | 34 private: |
| 28 // RenderProcessObserver implementation. | 35 // RenderProcessObserver implementation. |
| 29 bool OnControlMessageReceived(const IPC::Message& message) override; | |
| 30 void WebKitInitialized() override; | 36 void WebKitInitialized() override; |
| 31 void OnRenderProcessShutdown() override; | 37 void OnRenderProcessShutdown() override; |
| 32 | 38 |
| 33 // Message handlers. | 39 // WebCacheService methods: |
| 34 void OnSetCacheCapacities(uint64_t min_dead_capacity, | 40 void SetCacheCapacities(uint64_t min_dead_capacity, |
| 35 uint64_t max_dead_capacity, | 41 uint64_t max_dead_capacity, |
| 36 uint64_t capacity); | 42 uint64_t capacity) override; |
| 37 // If |on_navigation| is true, the clearing is delayed until the next | 43 // If |on_navigation| is true, the clearing is delayed until the next |
| 38 // navigation event. | 44 // navigation event. |
| 39 void OnClearCache(bool on_navigation); | 45 void ClearCache(bool on_navigation) override; |
| 40 | 46 |
| 41 // If true, the web cache shall be cleared before the next navigation event. | 47 // If true, the web cache shall be cleared before the next navigation event. |
| 42 bool clear_cache_pending_; | 48 bool clear_cache_pending_; |
| 43 bool webkit_initialized_; | 49 bool webkit_initialized_; |
| 44 size_t pending_cache_min_dead_capacity_; | 50 size_t pending_cache_min_dead_capacity_; |
| 45 size_t pending_cache_max_dead_capacity_; | 51 size_t pending_cache_max_dead_capacity_; |
| 46 size_t pending_cache_capacity_; | 52 size_t pending_cache_capacity_; |
| 47 | 53 |
| 54 mojo::WeakBindingSet<WebCacheService> bindings_; |
| 55 |
| 48 DISALLOW_COPY_AND_ASSIGN(WebCacheRenderProcessObserver); | 56 DISALLOW_COPY_AND_ASSIGN(WebCacheRenderProcessObserver); |
| 49 }; | 57 }; |
| 50 | 58 |
| 51 } // namespace web_cache | 59 } // namespace web_cache |
| 52 | 60 |
| 53 #endif // COMPONENTS_WEB_CACHE_RENDERER_WEB_CACHE_RENDER_PROCESS_OBSERVER_H_ | 61 #endif // COMPONENTS_WEB_CACHE_RENDERER_WEB_CACHE_RENDER_PROCESS_OBSERVER_H_ |
| 54 | 62 |
| OLD | NEW |