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

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

Issue 2792183003: Remove base::is_trivially_destructible and use the standard library. (Closed)
Patch Set: triviallydestruct: rm-tests Created 3 years, 8 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/memory_usage_estimator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #if !defined(ARCH_CPU_LITTLE_ENDIAN) 11 #if !defined(ARCH_CPU_LITTLE_ENDIAN)
12 // The memcpy() for float and double below needs to be adjusted if we want to 12 // The memcpy() for float and double below needs to be adjusted if we want to
13 // support big endian CPUs. There doesn't seem to be a compelling need today. 13 // support big endian CPUs. There doesn't seem to be a compelling need today.
14 #error big-endian CPUs not supported by this translation unit. 14 #error big-endian CPUs not supported by this translation unit.
15 #endif 15 #endif
16 16
17 namespace tracing { 17 namespace tracing {
18 namespace v2 { 18 namespace v2 {
19 19
20 ProtoZeroMessage::ProtoZeroMessage() { 20 ProtoZeroMessage::ProtoZeroMessage() {
21 // Do NOT add any code here, use the Reset() method below instead. 21 // Do NOT add any code here, use the Reset() method below instead.
22 // Ctor and Dtor of ProtoZeroMessage are never called, with the exeception 22 // Ctor and Dtor of ProtoZeroMessage are never called, with the exeception
23 // of root (non-nested) messages. Nested messages are allocated in the 23 // of root (non-nested) messages. Nested messages are allocated in the
24 // |nested_messages_arena_| and implictly destroyed when the arena of the 24 // |nested_messages_arena_| and implictly destroyed when the arena of the
25 // root message goes away. This is fine as long as all the fields are PODs, 25 // root message goes away. This is fine as long as all the fields are PODs,
26 // hence the static_assert below. 26 // hence the static_assert below.
27 static_assert(base::is_trivially_destructible<ProtoZeroMessage>::value, 27 static_assert(std::is_trivially_destructible<ProtoZeroMessage>::value,
28 "ProtoZeroMessage must be trivially destructible"); 28 "ProtoZeroMessage must be trivially destructible");
29 29
30 static_assert( 30 static_assert(
31 sizeof(ProtoZeroMessage::nested_messages_arena_) >= 31 sizeof(ProtoZeroMessage::nested_messages_arena_) >=
32 kMaxNestingDepth * (sizeof(ProtoZeroMessage) - 32 kMaxNestingDepth * (sizeof(ProtoZeroMessage) -
33 sizeof(ProtoZeroMessage::nested_messages_arena_)), 33 sizeof(ProtoZeroMessage::nested_messages_arena_)),
34 "ProtoZeroMessage::nested_messages_arena_ is too small"); 34 "ProtoZeroMessage::nested_messages_arena_ is too small");
35 } 35 }
36 36
37 // This method is called to initialize both root and nested messages. 37 // This method is called to initialize both root and nested messages.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 | « base/trace_event/memory_usage_estimator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698