Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / base / trace_event / trace_event_argument.h
blobaab58bc5ba75b1c8933c794502ac9c148af95973
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.
5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_ARGUMENT_H_
6 #define BASE_TRACE_EVENT_TRACE_EVENT_ARGUMENT_H_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_ptr.h"
12 #include "base/pickle.h"
13 #include "base/trace_event/trace_event.h"
15 namespace base {
17 class Value;
19 namespace trace_event {
21 class BASE_EXPORT TracedValue : public ConvertableToTraceFormat {
22 public:
23 TracedValue();
24 explicit TracedValue(size_t capacity);
26 void EndDictionary();
27 void EndArray();
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);
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);
49 void AppendInteger(int);
50 void AppendDouble(double);
51 void AppendBoolean(bool);
52 void AppendString(const std::string&);
53 void BeginArray();
54 void BeginDictionary();
56 // ConvertableToTraceFormat implementation.
57 void AppendAsTraceFormat(std::string* out) const override;
59 void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead) override;
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);
70 // Public for tests only.
71 scoped_ptr<base::Value> ToBaseValue() const;
73 private:
74 ~TracedValue() override;
76 Pickle pickle_;
78 #ifndef NDEBUG
79 // In debug builds checks the pairings of {Start,End}{Dictionary,Array}
80 std::vector<bool> nesting_stack_;
81 #endif
83 DISALLOW_COPY_AND_ASSIGN(TracedValue);
86 } // namespace trace_event
87 } // namespace base
89 #endif // BASE_TRACE_EVENT_TRACE_EVENT_ARGUMENT_H_