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

Side by Side Diff: gin/v8_platform.cc

Issue 2471563003: Revert of [Tracing] Create TracingCategoryObserver in gin/. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | 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 "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"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "gin/per_isolate_data.h" 12 #include "gin/per_isolate_data.h"
13 #include "v8/include/v8-tracing.h"
14 13
15 namespace gin { 14 namespace gin {
16 15
17 namespace { 16 namespace {
18 17
19 base::LazyInstance<V8Platform>::Leaky g_v8_platform = LAZY_INSTANCE_INITIALIZER; 18 base::LazyInstance<V8Platform>::Leaky g_v8_platform = LAZY_INSTANCE_INITIALIZER;
20 19
21 } // namespace 20 } // namespace
22 21
23 // static 22 // static
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 memcpy(&traceEventHandle, &handle, sizeof(handle)); 147 memcpy(&traceEventHandle, &handle, sizeof(handle));
149 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_enabled_flag, name, 148 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_enabled_flag, name,
150 traceEventHandle); 149 traceEventHandle);
151 } 150 }
152 151
153 namespace { 152 namespace {
154 153
155 class EnabledStateObserverImpl final 154 class EnabledStateObserverImpl final
156 : public base::trace_event::TraceLog::EnabledStateObserver { 155 : public base::trace_event::TraceLog::EnabledStateObserver {
157 public: 156 public:
158 EnabledStateObserverImpl() { 157 EnabledStateObserverImpl() = default;
159 tracing_category_observer_ = v8::tracing::TracingCategoryObserver::Create();
160 observers_.insert(reinterpret_cast<v8::Platform::TraceStateObserver*>(
161 tracing_category_observer_.get()));
162 }
163 158
164 void OnTraceLogEnabled() final { 159 void OnTraceLogEnabled() final {
165 base::AutoLock lock(mutex_); 160 base::AutoLock lock(mutex_);
166 for (auto o : observers_) { 161 for (auto o : observers_) {
167 o->OnTraceEnabled(); 162 o->OnTraceEnabled();
168 } 163 }
169 } 164 }
170 165
171 void OnTraceLogDisabled() final { 166 void OnTraceLogDisabled() final {
172 base::AutoLock lock(mutex_); 167 base::AutoLock lock(mutex_);
(...skipping 17 matching lines...) Expand all
190 observers_.erase(observer); 185 observers_.erase(observer);
191 if (observers_.empty()) { 186 if (observers_.empty()) {
192 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver( 187 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(
193 this); 188 this);
194 } 189 }
195 } 190 }
196 191
197 private: 192 private:
198 base::Lock mutex_; 193 base::Lock mutex_;
199 std::unordered_set<v8::Platform::TraceStateObserver*> observers_; 194 std::unordered_set<v8::Platform::TraceStateObserver*> observers_;
200 std::unique_ptr<v8::tracing::TracingCategoryObserver>
201 tracing_category_observer_;
202 195
203 DISALLOW_COPY_AND_ASSIGN(EnabledStateObserverImpl); 196 DISALLOW_COPY_AND_ASSIGN(EnabledStateObserverImpl);
204 }; 197 };
205 198
206 base::LazyInstance<EnabledStateObserverImpl>::Leaky g_trace_state_dispatcher = 199 base::LazyInstance<EnabledStateObserverImpl>::Leaky g_trace_state_dispatcher =
207 LAZY_INSTANCE_INITIALIZER; 200 LAZY_INSTANCE_INITIALIZER;
208 201
209 } // namespace 202 } // namespace
210 203
211 void V8Platform::AddTraceStateObserver( 204 void V8Platform::AddTraceStateObserver(
212 v8::Platform::TraceStateObserver* observer) { 205 v8::Platform::TraceStateObserver* observer) {
213 g_trace_state_dispatcher.Get().AddObserver(observer); 206 g_trace_state_dispatcher.Get().AddObserver(observer);
214 } 207 }
215 208
216 void V8Platform::RemoveTraceStateObserver( 209 void V8Platform::RemoveTraceStateObserver(
217 v8::Platform::TraceStateObserver* observer) { 210 v8::Platform::TraceStateObserver* observer) {
218 g_trace_state_dispatcher.Get().RemoveObserver(observer); 211 g_trace_state_dispatcher.Get().RemoveObserver(observer);
219 } 212 }
220 213
221 } // namespace gin 214 } // namespace gin
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698