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

Side by Side Diff: components/web_cache/renderer/web_cache_render_process_observer.cc

Issue 1283793004: [tracing] Add WebCache memory usage in Blink to chrome://tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove browser side dumps. Created 5 years, 4 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 unified diff | Download patch
OLDNEW
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"
9 #include "components/web_cache/common/web_cache_messages.h" 11 #include "components/web_cache/common/web_cache_messages.h"
12 #include "components/web_cache/renderer/web_cache_memory_dump_provider.h"
10 #include "third_party/WebKit/public/web/WebCache.h" 13 #include "third_party/WebKit/public/web/WebCache.h"
11 14
12 using blink::WebCache; 15 using blink::WebCache;
13 16
14 namespace web_cache { 17 namespace web_cache {
15 18
16 namespace { 19 namespace {
17 const size_t kUnitializedCacheCapacity = UINT_MAX; 20 const size_t kUnitializedCacheCapacity = UINT_MAX;
18 } 21 }
19 22
(...skipping 26 matching lines...) Expand all
46 return handled; 49 return handled;
47 } 50 }
48 51
49 void WebCacheRenderProcessObserver::WebKitInitialized() { 52 void WebCacheRenderProcessObserver::WebKitInitialized() {
50 webkit_initialized_ = true; 53 webkit_initialized_ = true;
51 if (pending_cache_capacity_ != kUnitializedCacheCapacity) { 54 if (pending_cache_capacity_ != kUnitializedCacheCapacity) {
52 WebCache::setCapacities(pending_cache_min_dead_capacity_, 55 WebCache::setCapacities(pending_cache_min_dead_capacity_,
53 pending_cache_max_dead_capacity_, 56 pending_cache_max_dead_capacity_,
54 pending_cache_capacity_); 57 pending_cache_capacity_);
55 } 58 }
59
60 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
61 web_cache::WebCacheMemoryDumpProvider::GetInstance(),
62 base::ThreadTaskRunnerHandle::Get());
56 } 63 }
57 64
58 void WebCacheRenderProcessObserver::OnRenderProcessShutdown() { 65 void WebCacheRenderProcessObserver::OnRenderProcessShutdown() {
59 webkit_initialized_ = false; 66 webkit_initialized_ = false;
Primiano Tucci (use gerrit) 2015/08/13 13:30:21 Just for consistency, I'd make the register and un
ssid 2015/08/13 15:25:34 Done.
67 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
68 web_cache::WebCacheMemoryDumpProvider::GetInstance());
60 } 69 }
61 70
62 void WebCacheRenderProcessObserver::OnSetCacheCapacities( 71 void WebCacheRenderProcessObserver::OnSetCacheCapacities(
63 size_t min_dead_capacity, 72 size_t min_dead_capacity,
64 size_t max_dead_capacity, 73 size_t max_dead_capacity,
65 size_t capacity) { 74 size_t capacity) {
66 if (!webkit_initialized_) { 75 if (!webkit_initialized_) {
67 pending_cache_min_dead_capacity_ = min_dead_capacity; 76 pending_cache_min_dead_capacity_ = min_dead_capacity;
68 pending_cache_max_dead_capacity_ = max_dead_capacity; 77 pending_cache_max_dead_capacity_ = max_dead_capacity;
69 pending_cache_capacity_ = capacity; 78 pending_cache_capacity_ = capacity;
70 return; 79 return;
71 } 80 }
72 81
73 WebCache::setCapacities( 82 WebCache::setCapacities(
74 min_dead_capacity, max_dead_capacity, capacity); 83 min_dead_capacity, max_dead_capacity, capacity);
75 } 84 }
76 85
77 void WebCacheRenderProcessObserver::OnClearCache(bool on_navigation) { 86 void WebCacheRenderProcessObserver::OnClearCache(bool on_navigation) {
78 if (on_navigation || !webkit_initialized_) 87 if (on_navigation || !webkit_initialized_)
79 clear_cache_pending_ = true; 88 clear_cache_pending_ = true;
80 else 89 else
81 WebCache::clear(); 90 WebCache::clear();
82 } 91 }
83 92
84 } // namespace web_cache 93 } // namespace web_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698