OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/debug/trace_event_memory.h" | 5 #include "base/debug/trace_event_memory.h" |
6 | 6 |
7 #include "base/debug/leak_annotations.h" | 7 #include "base/debug/leak_annotations.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 ///////////////////////////////////////////////////////////////////////////// | 27 ///////////////////////////////////////////////////////////////////////////// |
28 // Holds a memory dump until the tracing system needs to serialize it. | 28 // Holds a memory dump until the tracing system needs to serialize it. |
29 class MemoryDumpHolder : public base::debug::ConvertableToTraceFormat { | 29 class MemoryDumpHolder : public base::debug::ConvertableToTraceFormat { |
30 public: | 30 public: |
31 // Takes ownership of dump, which must be a JSON string, allocated with | 31 // Takes ownership of dump, which must be a JSON string, allocated with |
32 // malloc() and NULL terminated. | 32 // malloc() and NULL terminated. |
33 explicit MemoryDumpHolder(char* dump) : dump_(dump) {} | 33 explicit MemoryDumpHolder(char* dump) : dump_(dump) {} |
34 | 34 |
35 // base::debug::ConvertableToTraceFormat overrides: | 35 // base::debug::ConvertableToTraceFormat overrides: |
36 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { | 36 virtual void AppendAsTraceFormat(std::string* out) const override { |
37 AppendHeapProfileAsTraceFormat(dump_, out); | 37 AppendHeapProfileAsTraceFormat(dump_, out); |
38 } | 38 } |
39 | 39 |
40 private: | 40 private: |
41 virtual ~MemoryDumpHolder() { free(dump_); } | 41 virtual ~MemoryDumpHolder() { free(dump_); } |
42 | 42 |
43 char* dump_; | 43 char* dump_; |
44 | 44 |
45 DISALLOW_COPY_AND_ASSIGN(MemoryDumpHolder); | 45 DISALLOW_COPY_AND_ASSIGN(MemoryDumpHolder); |
46 }; | 46 }; |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 if (!base::HexStringToUInt64(hex_address, &address)) | 431 if (!base::HexStringToUInt64(hex_address, &address)) |
432 return "error"; | 432 return "error"; |
433 if (!address) | 433 if (!address) |
434 return "null"; | 434 return "null"; |
435 // Note that this cast handles 64-bit to 32-bit conversion if necessary. | 435 // Note that this cast handles 64-bit to 32-bit conversion if necessary. |
436 return reinterpret_cast<const char*>(address); | 436 return reinterpret_cast<const char*>(address); |
437 } | 437 } |
438 | 438 |
439 } // namespace debug | 439 } // namespace debug |
440 } // namespace base | 440 } // namespace base |
OLD | NEW |