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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/power_profiler/power_profiler_host.h"
6
7 #include "base/debug/trace_event.h"
8 #include "base/logging.h"
9 #include "content/browser/power_profiler/power_profiler_service.h"
10 #include "content/public/browser/browser_thread.h"
11
12 namespace content {
13
14 PowerProfilerHost::PowerProfilerHost() : resolution_(NORMAL) {
15 }
16
17 PowerProfilerHost::~PowerProfilerHost() {
18 }
19
20 bool PowerProfilerHost::Register() {
21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
22
23 if (!PowerProfilerService::Get() || PowerProfilerService::UNINITIALIZED ==
24 PowerProfilerService::Get()->status())
25 return false;
26
27 if (BrowserThread::PostTask(BrowserThread::POWER_PROFILER, FROM_HERE,
28 base::Bind(&PowerProfilerHost::RegisterWrapper, this)))
29 return true;
30
31 return false;
32 }
33
34 void PowerProfilerHost::UnRegister() {
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
36
37 if (PowerProfilerService::Get())
38 BrowserThread::PostTask(BrowserThread::POWER_PROFILER, FROM_HERE,
39 base::Bind(&PowerProfilerHost::UnRegisterWrapper, this));
40 }
41
42 void PowerProfilerHost::SetResolution(Resolution resolution) {
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
44
45 resolution_ = resolution;
46 if (PowerProfilerService::Get())
47 BrowserThread::PostTask(BrowserThread::POWER_PROFILER, FROM_HERE,
48 base::Bind(&PowerProfilerHost::SetResolutionWrapper, this));
49 }
50
51 void PowerProfilerHost::RegisterWrapper() {
52 if (PowerProfilerService::Get())
53 PowerProfilerService::Get()->AddObserver(this);
54 }
55
56 void PowerProfilerHost::UnRegisterWrapper() {
57 if (PowerProfilerService::Get())
58 PowerProfilerService::Get()->RemoveObserver(this);
59 }
60
61 void PowerProfilerHost::SetResolutionWrapper() {
62 if (PowerProfilerService::Get())
63 PowerProfilerService::Get()->UpdateResolution();
64 }
65
66 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698