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

Unified Diff: content/browser/power_profiler/power_profiler_host.cc

Issue 106223002: chrome power profiler chrome side changes (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years 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: content/browser/power_profiler/power_profiler_host.cc
diff --git a/content/browser/power_profiler/power_profiler_host.cc b/content/browser/power_profiler/power_profiler_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f6d72e4adf44413a308ea1f2eb0fb4805eb8509c
--- /dev/null
+++ b/content/browser/power_profiler/power_profiler_host.cc
@@ -0,0 +1,66 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/power_profiler/power_profiler_host.h"
+
+#include "base/debug/trace_event.h"
+#include "base/logging.h"
+#include "content/browser/power_profiler/power_profiler_service.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+PowerProfilerHost::PowerProfilerHost() : resolution_(NORMAL) {
+}
+
+PowerProfilerHost::~PowerProfilerHost() {
+}
+
+bool PowerProfilerHost::Register() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (!PowerProfilerService::Get() || PowerProfilerService::UNINITIALIZED ==
+ PowerProfilerService::Get()->status())
+ return false;
+
+ if (BrowserThread::PostTask(BrowserThread::POWER_PROFILER, FROM_HERE,
+ base::Bind(&PowerProfilerHost::RegisterWrapper, this)))
+ return true;
+
+ return false;
+}
+
+void PowerProfilerHost::UnRegister() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (PowerProfilerService::Get())
+ BrowserThread::PostTask(BrowserThread::POWER_PROFILER, FROM_HERE,
+ base::Bind(&PowerProfilerHost::UnRegisterWrapper, this));
+}
+
+void PowerProfilerHost::SetResolution(Resolution resolution) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ resolution_ = resolution;
+ if (PowerProfilerService::Get())
+ BrowserThread::PostTask(BrowserThread::POWER_PROFILER, FROM_HERE,
+ base::Bind(&PowerProfilerHost::SetResolutionWrapper, this));
+}
+
+void PowerProfilerHost::RegisterWrapper() {
+ if (PowerProfilerService::Get())
+ PowerProfilerService::Get()->AddObserver(this);
+}
+
+void PowerProfilerHost::UnRegisterWrapper() {
+ if (PowerProfilerService::Get())
+ PowerProfilerService::Get()->RemoveObserver(this);
+}
+
+void PowerProfilerHost::SetResolutionWrapper() {
+ if (PowerProfilerService::Get())
+ PowerProfilerService::Get()->UpdateResolution();
+}
+
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698