| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "components/tracing/core/proto_zero_message_handle.h" | 5 #include "components/tracing/core/proto_zero_message_handle.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "components/tracing/core/proto_zero_message.h" | 8 #include "components/tracing/core/proto_zero_message.h" |
| 9 | 9 |
| 10 namespace tracing { | 10 namespace tracing { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // If the current handle was pointing to a message and is being reset to a new | 50 // If the current handle was pointing to a message and is being reset to a new |
| 51 // one, finalize the old message. | 51 // one, finalize the old message. |
| 52 FinalizeMessageIfSet(message_); | 52 FinalizeMessageIfSet(message_); |
| 53 | 53 |
| 54 // In theory other->message_ could be nullptr, if |other| is a handle that has | 54 // In theory other->message_ could be nullptr, if |other| is a handle that has |
| 55 // been std::move-d (and hence empty). There isn't a legitimate use case for | 55 // been std::move-d (and hence empty). There isn't a legitimate use case for |
| 56 // doing so, though. Therefore this case is deliberately ignored (if hit, it | 56 // doing so, though. Therefore this case is deliberately ignored (if hit, it |
| 57 // will manifest as a segfault when dereferencing |message_| below) to avoid a | 57 // will manifest as a segfault when dereferencing |message_| below) to avoid a |
| 58 // useless null-check. | 58 // useless null-check. |
| 59 message_ = other->message_; | 59 message_ = other->message_; |
| 60 sealed_fields_ = std::move(other->sealed_fields_); |
| 60 other->message_ = nullptr; | 61 other->message_ = nullptr; |
| 61 #if DCHECK_IS_ON() | 62 #if DCHECK_IS_ON() |
| 62 message_->set_handle(this); | 63 message_->set_handle(this); |
| 63 #endif | 64 #endif |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace v2 | 67 } // namespace v2 |
| 67 } // namespace tracing | 68 } // namespace tracing |
| OLD | NEW |