| 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 "gin/public/v8_platform.h" | 5 #include "gin/public/v8_platform.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 10 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 namespace { | 198 namespace { |
| 199 | 199 |
| 200 class EnabledStateObserverImpl final | 200 class EnabledStateObserverImpl final |
| 201 : public base::trace_event::TraceLog::EnabledStateObserver { | 201 : public base::trace_event::TraceLog::EnabledStateObserver { |
| 202 public: | 202 public: |
| 203 EnabledStateObserverImpl() = default; | 203 EnabledStateObserverImpl() = default; |
| 204 | 204 |
| 205 void OnTraceLogEnabled() final { | 205 void OnTraceLogEnabled() final { |
| 206 base::AutoLock lock(mutex_); | 206 base::AutoLock lock(mutex_); |
| 207 for (auto o : observers_) { | 207 for (auto* o : observers_) { |
| 208 o->OnTraceEnabled(); | 208 o->OnTraceEnabled(); |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 void OnTraceLogDisabled() final { | 212 void OnTraceLogDisabled() final { |
| 213 base::AutoLock lock(mutex_); | 213 base::AutoLock lock(mutex_); |
| 214 for (auto o : observers_) { | 214 for (auto* o : observers_) { |
| 215 o->OnTraceDisabled(); | 215 o->OnTraceDisabled(); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 void AddObserver(v8::Platform::TraceStateObserver* observer) { | 219 void AddObserver(v8::Platform::TraceStateObserver* observer) { |
| 220 { | 220 { |
| 221 base::AutoLock lock(mutex_); | 221 base::AutoLock lock(mutex_); |
| 222 DCHECK(!observers_.count(observer)); | 222 DCHECK(!observers_.count(observer)); |
| 223 if (observers_.empty()) { | 223 if (observers_.empty()) { |
| 224 base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver( | 224 base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 v8::Platform::TraceStateObserver* observer) { | 257 v8::Platform::TraceStateObserver* observer) { |
| 258 g_trace_state_dispatcher.Get().AddObserver(observer); | 258 g_trace_state_dispatcher.Get().AddObserver(observer); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void V8Platform::RemoveTraceStateObserver( | 261 void V8Platform::RemoveTraceStateObserver( |
| 262 v8::Platform::TraceStateObserver* observer) { | 262 v8::Platform::TraceStateObserver* observer) { |
| 263 g_trace_state_dispatcher.Get().RemoveObserver(observer); | 263 g_trace_state_dispatcher.Get().RemoveObserver(observer); |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace gin | 266 } // namespace gin |
| OLD | NEW |