OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |