| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_ARGUMENT_H_ | |
| 6 #define BASE_TRACE_EVENT_TRACE_EVENT_ARGUMENT_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/pickle.h" | |
| 13 #include "base/trace_event/trace_event.h" | |
| 14 | |
| 15 namespace base { | |
| 16 | |
| 17 class Value; | |
| 18 | |
| 19 namespace trace_event { | |
| 20 | |
| 21 class BASE_EXPORT TracedValue : public ConvertableToTraceFormat { | |
| 22 public: | |
| 23 TracedValue(); | |
| 24 explicit TracedValue(size_t capacity); | |
| 25 | |
| 26 void EndDictionary(); | |
| 27 void EndArray(); | |
| 28 | |
| 29 // These methods assume that |name| is a long lived "quoted" string. | |
| 30 void SetInteger(const char* name, int value); | |
| 31 void SetDouble(const char* name, double value); | |
| 32 void SetBoolean(const char* name, bool value); | |
| 33 void SetString(const char* name, const std::string& value); | |
| 34 void SetValue(const char* name, const TracedValue& value); | |
| 35 void BeginDictionary(const char* name); | |
| 36 void BeginArray(const char* name); | |
| 37 | |
| 38 // These, instead, can be safely passed a temporary string. | |
| 39 void SetIntegerWithCopiedName(const std::string& name, int value); | |
| 40 void SetDoubleWithCopiedName(const std::string& name, double value); | |
| 41 void SetBooleanWithCopiedName(const std::string& name, bool value); | |
| 42 void SetStringWithCopiedName(const std::string& name, | |
| 43 const std::string& value); | |
| 44 void SetValueWithCopiedName(const std::string& name, | |
| 45 const TracedValue& value); | |
| 46 void BeginDictionaryWithCopiedName(const std::string& name); | |
| 47 void BeginArrayWithCopiedName(const std::string& name); | |
| 48 | |
| 49 void AppendInteger(int); | |
| 50 void AppendDouble(double); | |
| 51 void AppendBoolean(bool); | |
| 52 void AppendString(const std::string&); | |
| 53 void BeginArray(); | |
| 54 void BeginDictionary(); | |
| 55 | |
| 56 // ConvertableToTraceFormat implementation. | |
| 57 void AppendAsTraceFormat(std::string* out) const override; | |
| 58 | |
| 59 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead) override; | |
| 60 | |
| 61 // DEPRECATED: do not use, here only for legacy reasons. These methods causes | |
| 62 // a copy-and-translation of the base::Value into the equivalent TracedValue. | |
| 63 // TODO(primiano): migrate the (three) existing clients to the cheaper | |
| 64 // SetValue(TracedValue) API. crbug.com/495628. | |
| 65 void SetValue(const char* name, scoped_ptr<base::Value> value); | |
| 66 void SetBaseValueWithCopiedName(const std::string& name, | |
| 67 const base::Value& value); | |
| 68 void AppendBaseValue(const base::Value& value); | |
| 69 | |
| 70 // Public for tests only. | |
| 71 scoped_ptr<base::Value> ToBaseValue() const; | |
| 72 | |
| 73 private: | |
| 74 ~TracedValue() override; | |
| 75 | |
| 76 Pickle pickle_; | |
| 77 | |
| 78 #ifndef NDEBUG | |
| 79 // In debug builds checks the pairings of {Start,End}{Dictionary,Array} | |
| 80 std::vector<bool> nesting_stack_; | |
| 81 #endif | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(TracedValue); | |
| 84 }; | |
| 85 | |
| 86 } // namespace trace_event | |
| 87 } // namespace base | |
| 88 | |
| 89 #endif // BASE_TRACE_EVENT_TRACE_EVENT_ARGUMENT_H_ | |
| OLD | NEW |