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

Unified Diff: base/trace_event/v2/trace_event.cc

Issue 1947373002: Tracing V2 prototype [NOT FOR REVIEW] Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WORKS Created 4 years, 7 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
« no previous file with comments | « base/trace_event/v2/trace_event.h ('k') | base/trace_event/v2/tracing_protoc.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/v2/trace_event.cc
diff --git a/base/trace_event/v2/trace_event.cc b/base/trace_event/v2/trace_event.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0aa96980618f57ab37b8e7a3505d49b6e88ad035
--- /dev/null
+++ b/base/trace_event/v2/trace_event.cc
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium 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 "base/trace_event/v2/trace_event.h"
+
+#include "base/logging.h"
+
+namespace base {
+namespace trace_event {
+namespace v2 {
+
+TraceEvent::TraceEvent() : handle_(nullptr) {}
+
+TraceEvent::~TraceEvent() {
+ // TODO this (and all the = nullptr) should be only on DCHECK_IS_ON or debug.
+ if (handle_)
+ handle_->event_ = nullptr;
+}
+
+TraceEventHandle::TraceEventHandle() : event_(nullptr) {}
+
+TraceEventHandle::TraceEventHandle(TraceEvent* event) : event_(event) {
+ event_->set_event_handle(this);
+}
+
+TraceEventHandle::~TraceEventHandle() {
+ if (event_) {
+ event_->Finalize();
+ event_->set_event_handle(nullptr);
+ }
+}
+
+TraceEventHandle::TraceEventHandle(TraceEventHandle&& other) {
+ Swap(&other);
+}
+
+TraceEventHandle& TraceEventHandle::operator=(TraceEventHandle&& other) {
+ Swap(&other);
+ return *this;
+}
+
+void TraceEventHandle::Swap(TraceEventHandle* other) {
+ if (event_) {
+ event_->Finalize();
+ event_->set_event_handle(nullptr);
+ }
+ event_ = other->event_;
+ other->event_ = nullptr;
+ event_->set_event_handle(this);
+}
+
+} // namespace v2
+} // namespace trace_event
+} // namespace base
« no previous file with comments | « base/trace_event/v2/trace_event.h ('k') | base/trace_event/v2/tracing_protoc.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698