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

Unified Diff: src/tracing/tracing-flag.cc

Issue 2436273002: [Tracing] Implement TracingCategoryObserver. (Closed)
Patch Set: fix compilation error Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: src/tracing/tracing-flag.cc
diff --git a/src/tracing/tracing-flag.cc b/src/tracing/tracing-flag.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ac835b1511a5ecffd9e0599a5a1ba1bbae58158d
--- /dev/null
+++ b/src/tracing/tracing-flag.cc
@@ -0,0 +1,44 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/tracing/tracing-flag.h"
+
+#include "include/v8.h"
+#include "src/flags.h"
+#include "src/tracing/trace-event.h"
+#include "src/v8.h"
+
+namespace v8 {
+
+std::unique_ptr<Platform::TracingFlag> Platform::TracingFlag::Create() {
+ return std::unique_ptr<Platform::TracingFlag>(new tracing::TracingFlagImpl());
+}
+
+namespace tracing {
+
+TracingFlagImpl::TracingFlagImpl()
+ : platform_(v8::internal::V8::GetCurrentPlatform()) {
+ platform_->AddTraceStateObserver(this);
+}
+
+TracingFlagImpl::~TracingFlagImpl() {
+ OnTraceDisabled();
+ platform_->RemoveTraceStateObserver(this);
+}
+
+void TracingFlagImpl::OnTraceEnabled() {
+ bool enabled = false;
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(
+ TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"), &enabled);
+ if (enabled) {
+ v8::internal::FLAG_runtime_stats |= ENABLED_BY_TRACING;
+ }
+}
+
+void TracingFlagImpl::OnTraceDisabled() {
+ v8::internal::FLAG_runtime_stats &= ~ENABLED_BY_TRACING;
+}
+
+} // namespace tracing
+} // namespace v8
« src/flag-definitions.h ('K') | « src/tracing/tracing-flag.h ('k') | src/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698