OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 "base/trace_event/trace_event_argument.h" | 5 #include "base/trace_event/trace_event_argument.h" |
6 | 6 |
| 7 #include "base/bits.h" |
7 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
8 #include "base/trace_event/trace_event_memory_overhead.h" | 9 #include "base/trace_event/trace_event_memory_overhead.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 | 11 |
11 namespace base { | 12 namespace base { |
12 namespace trace_event { | 13 namespace trace_event { |
13 | 14 |
14 namespace { | 15 namespace { |
15 const char kTypeStartDict = '{'; | 16 const char kTypeStartDict = '{'; |
16 const char kTypeEndDict = '}'; | 17 const char kTypeEndDict = '}'; |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 // TODO(primiano): this could be smarter, skip the ToBaseValue encoding and | 447 // TODO(primiano): this could be smarter, skip the ToBaseValue encoding and |
447 // produce the JSON on its own. This will require refactoring JSONWriter | 448 // produce the JSON on its own. This will require refactoring JSONWriter |
448 // to decouple the base::Value traversal from the JSON writing bits | 449 // to decouple the base::Value traversal from the JSON writing bits |
449 std::string tmp; | 450 std::string tmp; |
450 JSONWriter::Write(*ToBaseValue(), &tmp); | 451 JSONWriter::Write(*ToBaseValue(), &tmp); |
451 *out += tmp; | 452 *out += tmp; |
452 } | 453 } |
453 | 454 |
454 void TracedValue::EstimateTraceMemoryOverhead( | 455 void TracedValue::EstimateTraceMemoryOverhead( |
455 TraceEventMemoryOverhead* overhead) { | 456 TraceEventMemoryOverhead* overhead) { |
| 457 const size_t kPickleHeapAlign = 4096; // Must be == Pickle::kPickleHeapAlign. |
456 overhead->Add("TracedValue", | 458 overhead->Add("TracedValue", |
457 pickle_.GetTotalAllocatedSize() /* allocated size */, | 459 |
458 pickle_.size() /* resident size */); | 460 /* allocated size */ |
| 461 bits::Align(pickle_.GetTotalAllocatedSize(), kPickleHeapAlign), |
| 462 |
| 463 /* resident size */ |
| 464 bits::Align(pickle_.size(), kPickleHeapAlign)); |
459 } | 465 } |
460 | 466 |
461 } // namespace trace_event | 467 } // namespace trace_event |
462 } // namespace base | 468 } // namespace base |
OLD | NEW |