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

Unified Diff: chrome/browser/process_resource_usage.cc

Issue 1081323003: Convert renderer JS memory usage reporting to use Mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@utility-process-report-js-memory
Patch Set: Fix build files. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/process_resource_usage.cc
diff --git a/chrome/browser/process_resource_usage.cc b/chrome/browser/process_resource_usage.cc
index f892ade2f1f2a42d4093c2dba2de2c6058b8c2d3..3eee701f179ada640c28a75dc76052b17677712b 100644
--- a/chrome/browser/process_resource_usage.cc
+++ b/chrome/browser/process_resource_usage.cc
@@ -5,19 +5,38 @@
#include "chrome/browser/process_resource_usage.h"
#include "base/bind.h"
+#include "base/location.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop_proxy.h"
ProcessResourceUsage::ProcessResourceUsage(ResourceUsageReporterPtr service)
: service_(service.Pass()), update_in_progress_(false) {
+ service_.set_error_handler(this);
}
ProcessResourceUsage::~ProcessResourceUsage() {
DCHECK(thread_checker_.CalledOnValidThread());
}
-void ProcessResourceUsage::Refresh() {
+void ProcessResourceUsage::RunPendingRefreshCallbacks() {
+ auto message_loop = base::MessageLoopProxy::current();
+ for (const auto& callback : refresh_callbacks_)
+ message_loop->PostTask(FROM_HERE, callback);
+ refresh_callbacks_.clear();
+}
+
+void ProcessResourceUsage::Refresh(const base::Closure& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!update_in_progress_ && service_) {
+ if (!service_ || service_.encountered_error()) {
+ if (!callback.is_null())
+ base::MessageLoopProxy::current()->PostTask(FROM_HERE, callback);
+ return;
+ }
+
+ if (!callback.is_null())
+ refresh_callbacks_.push_back(callback);
+
+ if (!update_in_progress_) {
update_in_progress_ = true;
service_->GetUsageData(base::Bind(&ProcessResourceUsage::OnRefreshDone,
base::Unretained(this)));
@@ -28,6 +47,12 @@ void ProcessResourceUsage::OnRefreshDone(ResourceUsageDataPtr data) {
DCHECK(thread_checker_.CalledOnValidThread());
update_in_progress_ = false;
stats_ = data.Pass();
+ RunPendingRefreshCallbacks();
+}
+
+void ProcessResourceUsage::OnConnectionError() {
ncarter (slow) 2015/05/14 06:28:12 Does it make sense to zero the |stats_| when the c
Anand Mistry (off Chromium) 2015/05/14 07:30:41 I honestly have no idea. Maybe we want to keep the
ncarter (slow) 2015/05/14 13:59:58 You can leave it as is. The task manager removes r
+ DCHECK(thread_checker_.CalledOnValidThread());
+ RunPendingRefreshCallbacks();
}
bool ProcessResourceUsage::ReportsV8MemoryStats() const {

Powered by Google App Engine
This is Rietveld 408576698