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

Side by Side Diff: components/tracing/core/proto_zero_message.cc

Issue 2271653004: Reland of tracing v2: Introduce TraceBufferWriter (https://codereview.chromium.org/2196663002) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix undefined behavior of move ctor that caused revert on Win Created 4 years, 3 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
OLDNEW
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.h" 5 #include "components/tracing/core/proto_zero_message.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "components/tracing/core/proto_zero_message_handle.h" 9 #include "components/tracing/core/proto_zero_message_handle.h"
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 EndNestedMessage(); 75 EndNestedMessage();
76 76
77 if (size_field_.is_valid()) { 77 if (size_field_.is_valid()) {
78 // Write the length of the nested message a posteriori, using a leading-zero 78 // Write the length of the nested message a posteriori, using a leading-zero
79 // redundant varint encoding. 79 // redundant varint encoding.
80 #if DCHECK_IS_ON() 80 #if DCHECK_IS_ON()
81 DCHECK(!sealed_); 81 DCHECK(!sealed_);
82 #endif 82 #endif
83 DCHECK_LT(size_, proto::kMaxMessageLength); 83 DCHECK_LT(size_, proto::kMaxMessageLength);
84 DCHECK_EQ(proto::kMessageLengthFieldSize, size_field_.size()); 84 DCHECK_EQ(proto::kMessageLengthFieldSize, size_field_.size());
85 proto::WriteRedundantLength( 85 proto::WriteRedundantVarInt(
86 static_cast<uint32_t>(size_ - size_already_written_), 86 static_cast<uint32_t>(size_ - size_already_written_),
87 size_field_.begin); 87 size_field_.begin);
88 size_field_.reset(); 88 size_field_.reset();
89 } 89 }
90 90
91 #if DCHECK_IS_ON() 91 #if DCHECK_IS_ON()
92 sealed_ = true; 92 sealed_ = true;
93 if (handle_) 93 if (handle_)
94 handle_->reset_message(); 94 handle_->reset_message();
95 #endif 95 #endif
(...skipping 24 matching lines...) Expand all
120 nested_message_ = message; 120 nested_message_ = message;
121 } 121 }
122 122
123 void ProtoZeroMessage::EndNestedMessage() { 123 void ProtoZeroMessage::EndNestedMessage() {
124 size_ += nested_message_->Finalize(); 124 size_ += nested_message_->Finalize();
125 nested_message_ = nullptr; 125 nested_message_ = nullptr;
126 } 126 }
127 127
128 } // namespace v2 128 } // namespace v2
129 } // namespace tracing 129 } // namespace tracing
OLDNEW
« no previous file with comments | « components/tracing/core/proto_zero_message.h ('k') | components/tracing/core/proto_zero_message_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698