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

Side by Side Diff: content/browser/power_profiler/power_profiler_service.cc

Issue 332623003: [DevTools] [PowerProfiler] Fix for browser crash with active timeline recording for capturing power. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « content/browser/devtools/devtools_power_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/power_profiler/power_profiler_service.h" 5 #include "content/browser/power_profiler/power_profiler_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 void PowerProfilerService::AddObserver(PowerProfilerObserver* observer) { 53 void PowerProfilerService::AddObserver(PowerProfilerObserver* observer) {
54 if (status_ == UNINITIALIZED) 54 if (status_ == UNINITIALIZED)
55 return; 55 return;
56 56
57 observers_.AddObserver(observer); 57 observers_.AddObserver(observer);
58 if (status_ != PROFILING) 58 if (status_ != PROFILING)
59 Start(); 59 Start();
60 } 60 }
61 61
62 void PowerProfilerService::RemoveObserver(PowerProfilerObserver* observer) { 62 void PowerProfilerService::RemoveObserver(PowerProfilerObserver* observer) {
63 if (!observers_.might_have_observers())
jam 2014/06/19 16:42:34 why is this needed?
vivekg 2014/06/19 17:46:02 This was added after the discussion as per the htt
jam 2014/06/20 05:59:46 I don't follow that conversation, can you explaine
64 return;
65
63 observers_.RemoveObserver(observer); 66 observers_.RemoveObserver(observer);
64 67
65 if (!observers_.might_have_observers()) 68 if (!observers_.might_have_observers())
66 Stop(); 69 Stop();
67 } 70 }
68 71
69 void PowerProfilerService::Start() { 72 void PowerProfilerService::Start() {
70 DCHECK(status_ == INITIALIZED); 73 DCHECK(status_ == INITIALIZED);
71 status_ = PROFILING; 74 status_ = PROFILING;
72 75
(...skipping 27 matching lines...) Expand all
100 103
101 // Get data and notify. 104 // Get data and notify.
102 PowerEventVector events = data_provider_->GetData(); 105 PowerEventVector events = data_provider_->GetData();
103 if (events.size() != 0) { 106 if (events.size() != 0) {
104 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( 107 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
105 &PowerProfilerService::Notify, base::Unretained(this), events)); 108 &PowerProfilerService::Notify, base::Unretained(this), events));
106 } 109 }
107 } 110 }
108 111
109 } // namespace content 112 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_power_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698