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

Side by Side Diff: chrome/browser/process_resource_usage.cc

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/process_resource_usage.h" 5 #include "chrome/browser/process_resource_usage.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
11 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
12 13
13 class ProcessResourceUsage::ErrorHandler : public mojo::ErrorHandler { 14 class ProcessResourceUsage::ErrorHandler : public mojo::ErrorHandler {
14 public: 15 public:
15 ErrorHandler(ProcessResourceUsage* usage) : usage_(usage) {} 16 ErrorHandler(ProcessResourceUsage* usage) : usage_(usage) {}
16 17
17 // mojo::ErrorHandler implementation: 18 // mojo::ErrorHandler implementation:
18 void OnConnectionError() override; 19 void OnConnectionError() override;
19 20
20 private: 21 private:
(...skipping 10 matching lines...) Expand all
31 error_handler_(new ErrorHandler(this)) { 32 error_handler_(new ErrorHandler(this)) {
32 service_.set_error_handler(error_handler_.get()); 33 service_.set_error_handler(error_handler_.get());
33 } 34 }
34 35
35 ProcessResourceUsage::~ProcessResourceUsage() { 36 ProcessResourceUsage::~ProcessResourceUsage() {
36 DCHECK(thread_checker_.CalledOnValidThread()); 37 DCHECK(thread_checker_.CalledOnValidThread());
37 } 38 }
38 39
39 void ProcessResourceUsage::RunPendingRefreshCallbacks() { 40 void ProcessResourceUsage::RunPendingRefreshCallbacks() {
40 DCHECK(thread_checker_.CalledOnValidThread()); 41 DCHECK(thread_checker_.CalledOnValidThread());
41 auto message_loop = base::MessageLoopProxy::current(); 42 auto task_runner = base::ThreadTaskRunnerHandle::Get();
42 for (const auto& callback : refresh_callbacks_) 43 for (const auto& callback : refresh_callbacks_)
43 message_loop->PostTask(FROM_HERE, callback); 44 task_runner->PostTask(FROM_HERE, callback);
44 refresh_callbacks_.clear(); 45 refresh_callbacks_.clear();
45 } 46 }
46 47
47 void ProcessResourceUsage::Refresh(const base::Closure& callback) { 48 void ProcessResourceUsage::Refresh(const base::Closure& callback) {
48 DCHECK(thread_checker_.CalledOnValidThread()); 49 DCHECK(thread_checker_.CalledOnValidThread());
49 if (!service_ || service_.encountered_error()) { 50 if (!service_ || service_.encountered_error()) {
50 if (!callback.is_null()) 51 if (!callback.is_null())
51 base::MessageLoopProxy::current()->PostTask(FROM_HERE, callback); 52 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback);
52 return; 53 return;
53 } 54 }
54 55
55 if (!callback.is_null()) 56 if (!callback.is_null())
56 refresh_callbacks_.push_back(callback); 57 refresh_callbacks_.push_back(callback);
57 58
58 if (!update_in_progress_) { 59 if (!update_in_progress_) {
59 update_in_progress_ = true; 60 update_in_progress_ = true;
60 service_->GetUsageData(base::Bind(&ProcessResourceUsage::OnRefreshDone, 61 service_->GetUsageData(base::Bind(&ProcessResourceUsage::OnRefreshDone,
61 base::Unretained(this))); 62 base::Unretained(this)));
(...skipping 20 matching lines...) Expand all
82 return stats_->v8_bytes_allocated; 83 return stats_->v8_bytes_allocated;
83 return 0; 84 return 0;
84 } 85 }
85 86
86 size_t ProcessResourceUsage::GetV8MemoryUsed() const { 87 size_t ProcessResourceUsage::GetV8MemoryUsed() const {
87 DCHECK(thread_checker_.CalledOnValidThread()); 88 DCHECK(thread_checker_.CalledOnValidThread());
88 if (stats_ && stats_->reports_v8_stats) 89 if (stats_ && stats_->reports_v8_stats)
89 return stats_->v8_bytes_used; 90 return stats_->v8_bytes_used;
90 return 0; 91 return 0;
91 } 92 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_view_manager_base.cc ('k') | chrome/browser/process_singleton_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698