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

Side by Side Diff: chrome/browser/ui/webui/memory_internals/memory_internals_proxy.cc

Issue 671653002: Standardize usage of virtual/override/final in chrome/browser/ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/webui/memory_internals/memory_internals_proxy.h" 5 #include "chrome/browser/ui/webui/memory_internals/memory_internals_proxy.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 class Profile; 46 class Profile;
47 47
48 namespace { 48 namespace {
49 49
50 class ProcessDetails : public MemoryDetails { 50 class ProcessDetails : public MemoryDetails {
51 public: 51 public:
52 typedef base::Callback<void(const ProcessData&)> DataCallback; 52 typedef base::Callback<void(const ProcessData&)> DataCallback;
53 explicit ProcessDetails(const DataCallback& callback) 53 explicit ProcessDetails(const DataCallback& callback)
54 : callback_(callback) {} 54 : callback_(callback) {}
55 // MemoryDetails: 55 // MemoryDetails:
56 virtual void OnDetailsAvailable() override { 56 void OnDetailsAvailable() override {
57 const std::vector<ProcessData>& browser_processes = processes(); 57 const std::vector<ProcessData>& browser_processes = processes();
58 // [0] means Chrome. 58 // [0] means Chrome.
59 callback_.Run(browser_processes[0]); 59 callback_.Run(browser_processes[0]);
60 } 60 }
61 61
62 private: 62 private:
63 virtual ~ProcessDetails() {} 63 ~ProcessDetails() override {}
64 64
65 DataCallback callback_; 65 DataCallback callback_;
66 66
67 DISALLOW_COPY_AND_ASSIGN(ProcessDetails); 67 DISALLOW_COPY_AND_ASSIGN(ProcessDetails);
68 }; 68 };
69 69
70 base::DictionaryValue* FindProcessFromPid(base::ListValue* processes, 70 base::DictionaryValue* FindProcessFromPid(base::ListValue* processes,
71 base::ProcessId pid) { 71 base::ProcessId pid) {
72 const size_t n = processes->GetSize(); 72 const size_t n = processes->GetSize();
73 for (size_t i = 0; i < n; ++i) { 73 for (size_t i = 0; i < n; ++i) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 public: 122 public:
123 typedef base::Callback<void(const base::ProcessId pid, 123 typedef base::Callback<void(const base::ProcessId pid,
124 const size_t v8_allocated, 124 const size_t v8_allocated,
125 const size_t v8_used)> V8DataCallback; 125 const size_t v8_used)> V8DataCallback;
126 126
127 explicit RendererDetails(const V8DataCallback& callback) 127 explicit RendererDetails(const V8DataCallback& callback)
128 : callback_(callback) { 128 : callback_(callback) {
129 registrar_.Add(this, chrome::NOTIFICATION_RENDERER_V8_HEAP_STATS_COMPUTED, 129 registrar_.Add(this, chrome::NOTIFICATION_RENDERER_V8_HEAP_STATS_COMPUTED,
130 content::NotificationService::AllSources()); 130 content::NotificationService::AllSources());
131 } 131 }
132 virtual ~RendererDetails() {} 132 ~RendererDetails() override {}
133 133
134 void Request() { 134 void Request() {
135 for (std::set<content::WebContents*>::iterator iter = web_contents_.begin(); 135 for (std::set<content::WebContents*>::iterator iter = web_contents_.begin();
136 iter != web_contents_.end(); ++iter) 136 iter != web_contents_.end(); ++iter)
137 (*iter)->GetRenderViewHost()->Send(new ChromeViewMsg_GetV8HeapStats); 137 (*iter)->GetRenderViewHost()->Send(new ChromeViewMsg_GetV8HeapStats);
138 } 138 }
139 139
140 void AddWebContents(content::WebContents* content) { 140 void AddWebContents(content::WebContents* content) {
141 web_contents_.insert(content); 141 web_contents_.insert(content);
142 } 142 }
143 143
144 void Clear() { 144 void Clear() {
145 web_contents_.clear(); 145 web_contents_.clear();
146 } 146 }
147 147
148 void RemoveWebContents(base::ProcessId) { 148 void RemoveWebContents(base::ProcessId) {
149 // We don't have to detect which content is the caller of this method. 149 // We don't have to detect which content is the caller of this method.
150 if (!web_contents_.empty()) 150 if (!web_contents_.empty())
151 web_contents_.erase(web_contents_.begin()); 151 web_contents_.erase(web_contents_.begin());
152 } 152 }
153 153
154 int IsClean() { 154 int IsClean() {
155 return web_contents_.empty(); 155 return web_contents_.empty();
156 } 156 }
157 157
158 private: 158 private:
159 // NotificationObserver: 159 // NotificationObserver:
160 virtual void Observe(int type, 160 void Observe(int type,
161 const content::NotificationSource& source, 161 const content::NotificationSource& source,
162 const content::NotificationDetails& details) override { 162 const content::NotificationDetails& details) override {
163 const base::ProcessId* pid = 163 const base::ProcessId* pid =
164 content::Source<const base::ProcessId>(source).ptr(); 164 content::Source<const base::ProcessId>(source).ptr();
165 const ChromeRenderMessageFilter::V8HeapStatsDetails* v8_heap = 165 const ChromeRenderMessageFilter::V8HeapStatsDetails* v8_heap =
166 content::Details<const ChromeRenderMessageFilter::V8HeapStatsDetails>( 166 content::Details<const ChromeRenderMessageFilter::V8HeapStatsDetails>(
167 details).ptr(); 167 details).ptr();
168 callback_.Run(*pid, 168 callback_.Run(*pid,
169 v8_heap->v8_memory_allocated(), 169 v8_heap->v8_memory_allocated(),
170 v8_heap->v8_memory_used()); 170 v8_heap->v8_memory_used());
171 } 171 }
172 172
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 const std::string& function, const base::Value& args) { 339 const std::string& function, const base::Value& args) {
340 DCHECK_CURRENTLY_ON(BrowserThread::UI); 340 DCHECK_CURRENTLY_ON(BrowserThread::UI);
341 341
342 std::vector<const base::Value*> args_vector(1, &args); 342 std::vector<const base::Value*> args_vector(1, &args);
343 base::string16 update = 343 base::string16 update =
344 content::WebUI::GetJavascriptCall(function, args_vector); 344 content::WebUI::GetJavascriptCall(function, args_vector);
345 // Don't forward updates to a destructed UI. 345 // Don't forward updates to a destructed UI.
346 if (handler_) 346 if (handler_)
347 handler_->OnUpdate(update); 347 handler_->OnUpdate(update);
348 } 348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698