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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/trace_event/v2/trace_event.h"
6
7 #include "base/logging.h"
8
9 namespace base {
10 namespace trace_event {
11 namespace v2 {
12
13 TraceEvent::TraceEvent() : handle_(nullptr) {}
14
15 TraceEvent::~TraceEvent() {
16 // TODO this (and all the = nullptr) should be only on DCHECK_IS_ON or debug.
17 if (handle_)
18 handle_->event_ = nullptr;
19 }
20
21 TraceEventHandle::TraceEventHandle() : event_(nullptr) {}
22
23 TraceEventHandle::TraceEventHandle(TraceEvent* event) : event_(event) {
24 event_->set_event_handle(this);
25 }
26
27 TraceEventHandle::~TraceEventHandle() {
28 if (event_) {
29 event_->Finalize();
30 event_->set_event_handle(nullptr);
31 }
32 }
33
34 TraceEventHandle::TraceEventHandle(TraceEventHandle&& other) {
35 Swap(&other);
36 }
37
38 TraceEventHandle& TraceEventHandle::operator=(TraceEventHandle&& other) {
39 Swap(&other);
40 return *this;
41 }
42
43 void TraceEventHandle::Swap(TraceEventHandle* other) {
44 if (event_) {
45 event_->Finalize();
46 event_->set_event_handle(nullptr);
47 }
48 event_ = other->event_;
49 other->event_ = nullptr;
50 event_->set_event_handle(this);
51 }
52
53 } // namespace v2
54 } // namespace trace_event
55 } // namespace base
OLDNEW
« 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