| 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 #include "components/web_cache/renderer/web_cache_render_process_observer.h" | 5 #include "components/web_cache/renderer/web_cache_render_process_observer.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/thread_task_runner_handle.h" | |
| 10 #include "base/trace_event/memory_dump_manager.h" | |
| 11 #include "components/web_cache/common/web_cache_messages.h" | 9 #include "components/web_cache/common/web_cache_messages.h" |
| 12 #include "components/web_cache/renderer/web_cache_memory_dump_provider.h" | |
| 13 #include "third_party/WebKit/public/web/WebCache.h" | 10 #include "third_party/WebKit/public/web/WebCache.h" |
| 14 | 11 |
| 15 using blink::WebCache; | 12 using blink::WebCache; |
| 16 | 13 |
| 17 namespace web_cache { | 14 namespace web_cache { |
| 18 | 15 |
| 19 namespace { | 16 namespace { |
| 20 const size_t kUnitializedCacheCapacity = UINT_MAX; | 17 const size_t kUnitializedCacheCapacity = UINT_MAX; |
| 21 } | 18 } |
| 22 | 19 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 49 return handled; | 46 return handled; |
| 50 } | 47 } |
| 51 | 48 |
| 52 void WebCacheRenderProcessObserver::WebKitInitialized() { | 49 void WebCacheRenderProcessObserver::WebKitInitialized() { |
| 53 webkit_initialized_ = true; | 50 webkit_initialized_ = true; |
| 54 if (pending_cache_capacity_ != kUnitializedCacheCapacity) { | 51 if (pending_cache_capacity_ != kUnitializedCacheCapacity) { |
| 55 WebCache::setCapacities(pending_cache_min_dead_capacity_, | 52 WebCache::setCapacities(pending_cache_min_dead_capacity_, |
| 56 pending_cache_max_dead_capacity_, | 53 pending_cache_max_dead_capacity_, |
| 57 pending_cache_capacity_); | 54 pending_cache_capacity_); |
| 58 } | 55 } |
| 59 | |
| 60 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | |
| 61 web_cache::WebCacheMemoryDumpProvider::GetInstance(), | |
| 62 base::ThreadTaskRunnerHandle::Get()); | |
| 63 } | 56 } |
| 64 | 57 |
| 65 void WebCacheRenderProcessObserver::OnRenderProcessShutdown() { | 58 void WebCacheRenderProcessObserver::OnRenderProcessShutdown() { |
| 66 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | |
| 67 web_cache::WebCacheMemoryDumpProvider::GetInstance()); | |
| 68 webkit_initialized_ = false; | 59 webkit_initialized_ = false; |
| 69 } | 60 } |
| 70 | 61 |
| 71 void WebCacheRenderProcessObserver::OnSetCacheCapacities( | 62 void WebCacheRenderProcessObserver::OnSetCacheCapacities( |
| 72 size_t min_dead_capacity, | 63 size_t min_dead_capacity, |
| 73 size_t max_dead_capacity, | 64 size_t max_dead_capacity, |
| 74 size_t capacity) { | 65 size_t capacity) { |
| 75 if (!webkit_initialized_) { | 66 if (!webkit_initialized_) { |
| 76 pending_cache_min_dead_capacity_ = min_dead_capacity; | 67 pending_cache_min_dead_capacity_ = min_dead_capacity; |
| 77 pending_cache_max_dead_capacity_ = max_dead_capacity; | 68 pending_cache_max_dead_capacity_ = max_dead_capacity; |
| 78 pending_cache_capacity_ = capacity; | 69 pending_cache_capacity_ = capacity; |
| 79 return; | 70 return; |
| 80 } | 71 } |
| 81 | 72 |
| 82 WebCache::setCapacities( | 73 WebCache::setCapacities( |
| 83 min_dead_capacity, max_dead_capacity, capacity); | 74 min_dead_capacity, max_dead_capacity, capacity); |
| 84 } | 75 } |
| 85 | 76 |
| 86 void WebCacheRenderProcessObserver::OnClearCache(bool on_navigation) { | 77 void WebCacheRenderProcessObserver::OnClearCache(bool on_navigation) { |
| 87 if (on_navigation || !webkit_initialized_) | 78 if (on_navigation || !webkit_initialized_) |
| 88 clear_cache_pending_ = true; | 79 clear_cache_pending_ = true; |
| 89 else | 80 else |
| 90 WebCache::clear(); | 81 WebCache::clear(); |
| 91 } | 82 } |
| 92 | 83 |
| 93 } // namespace web_cache | 84 } // namespace web_cache |
| OLD | NEW |