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

Side by Side Diff: chrome/renderer/chrome_render_process_observer.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/chrome_render_process_observer.h" 5 #include "chrome/renderer/chrome_render_process_observer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8
9 #include <limits> 8 #include <limits>
9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/metrics/field_trial.h" 18 #include "base/metrics/field_trial.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 base::WeakPtrFactory<RendererResourceDelegate> weak_factory_; 118 base::WeakPtrFactory<RendererResourceDelegate> weak_factory_;
119 119
120 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate); 120 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate);
121 }; 121 };
122 122
123 static const int kWaitForWorkersStatsTimeoutMS = 20; 123 static const int kWaitForWorkersStatsTimeoutMS = 20;
124 124
125 class ResourceUsageReporterImpl : public ResourceUsageReporter { 125 class ResourceUsageReporterImpl : public ResourceUsageReporter {
126 public: 126 public:
127 ResourceUsageReporterImpl( 127 ResourceUsageReporterImpl(base::WeakPtr<ChromeRenderProcessObserver> observer,
128 base::WeakPtr<ChromeRenderProcessObserver> observer, 128 mojo::InterfaceRequest<ResourceUsageReporter> req)
129 mojo::InterfaceRequest<ResourceUsageReporter> req) 129 : binding_(this, std::move(req)),
130 : binding_(this, req.Pass()), observer_(observer), weak_factory_(this) {} 130 observer_(observer),
131 weak_factory_(this) {}
131 ~ResourceUsageReporterImpl() override {} 132 ~ResourceUsageReporterImpl() override {}
132 133
133 private: 134 private:
134 static void CollectOnWorkerThread( 135 static void CollectOnWorkerThread(
135 const scoped_refptr<base::TaskRunner>& master, 136 const scoped_refptr<base::TaskRunner>& master,
136 base::WeakPtr<ResourceUsageReporterImpl> impl) { 137 base::WeakPtr<ResourceUsageReporterImpl> impl) {
137 size_t total_bytes = 0; 138 size_t total_bytes = 0;
138 size_t used_bytes = 0; 139 size_t used_bytes = 0;
139 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 140 v8::Isolate* isolate = v8::Isolate::GetCurrent();
140 if (isolate) { 141 if (isolate) {
(...skipping 10 matching lines...) Expand all
151 void ReceiveStats(size_t total_bytes, size_t used_bytes) { 152 void ReceiveStats(size_t total_bytes, size_t used_bytes) {
152 usage_data_->v8_bytes_allocated += total_bytes; 153 usage_data_->v8_bytes_allocated += total_bytes;
153 usage_data_->v8_bytes_used += used_bytes; 154 usage_data_->v8_bytes_used += used_bytes;
154 workers_to_go_--; 155 workers_to_go_--;
155 if (!workers_to_go_) 156 if (!workers_to_go_)
156 SendResults(); 157 SendResults();
157 } 158 }
158 159
159 void SendResults() { 160 void SendResults() {
160 if (!callback_.is_null()) 161 if (!callback_.is_null())
161 callback_.Run(usage_data_.Pass()); 162 callback_.Run(std::move(usage_data_));
162 callback_.reset(); 163 callback_.reset();
163 weak_factory_.InvalidateWeakPtrs(); 164 weak_factory_.InvalidateWeakPtrs();
164 workers_to_go_ = 0; 165 workers_to_go_ = 0;
165 } 166 }
166 167
167 void GetUsageData( 168 void GetUsageData(
168 const mojo::Callback<void(ResourceUsageDataPtr)>& callback) override { 169 const mojo::Callback<void(ResourceUsageDataPtr)>& callback) override {
169 DCHECK(callback_.is_null()); 170 DCHECK(callback_.is_null());
170 weak_factory_.InvalidateWeakPtrs(); 171 weak_factory_.InvalidateWeakPtrs();
171 usage_data_ = ResourceUsageData::New(); 172 usage_data_ = ResourceUsageData::New();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 int workers_to_go_; 214 int workers_to_go_;
214 mojo::StrongBinding<ResourceUsageReporter> binding_; 215 mojo::StrongBinding<ResourceUsageReporter> binding_;
215 base::WeakPtr<ChromeRenderProcessObserver> observer_; 216 base::WeakPtr<ChromeRenderProcessObserver> observer_;
216 217
217 base::WeakPtrFactory<ResourceUsageReporterImpl> weak_factory_; 218 base::WeakPtrFactory<ResourceUsageReporterImpl> weak_factory_;
218 }; 219 };
219 220
220 void CreateResourceUsageReporter( 221 void CreateResourceUsageReporter(
221 base::WeakPtr<ChromeRenderProcessObserver> observer, 222 base::WeakPtr<ChromeRenderProcessObserver> observer,
222 mojo::InterfaceRequest<ResourceUsageReporter> request) { 223 mojo::InterfaceRequest<ResourceUsageReporter> request) {
223 new ResourceUsageReporterImpl(observer, request.Pass()); 224 new ResourceUsageReporterImpl(observer, std::move(request));
224 } 225 }
225 226
226 } // namespace 227 } // namespace
227 228
228 bool ChromeRenderProcessObserver::is_incognito_process_ = false; 229 bool ChromeRenderProcessObserver::is_incognito_process_ = false;
229 230
230 ChromeRenderProcessObserver::ChromeRenderProcessObserver() 231 ChromeRenderProcessObserver::ChromeRenderProcessObserver()
231 : webkit_initialized_(false), weak_factory_(this) { 232 : webkit_initialized_(false), weak_factory_(this) {
232 const base::CommandLine& command_line = 233 const base::CommandLine& command_line =
233 *base::CommandLine::ForCurrentProcess(); 234 *base::CommandLine::ForCurrentProcess();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 ChromeRenderProcessObserver::content_setting_rules() const { 335 ChromeRenderProcessObserver::content_setting_rules() const {
335 return &content_setting_rules_; 336 return &content_setting_rules_;
336 } 337 }
337 338
338 void ChromeRenderProcessObserver::OnFieldTrialGroupFinalized( 339 void ChromeRenderProcessObserver::OnFieldTrialGroupFinalized(
339 const std::string& trial_name, 340 const std::string& trial_name,
340 const std::string& group_name) { 341 const std::string& group_name) {
341 content::RenderThread::Get()->Send( 342 content::RenderThread::Get()->Send(
342 new ChromeViewHostMsg_FieldTrialActivated(trial_name)); 343 new ChromeViewHostMsg_FieldTrialActivated(trial_name));
343 } 344 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698