| OLD | NEW |
| (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 |
| OLD | NEW |