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 #ifndef CC_DEBUG_TRACED_VALUE_H_ | 5 #ifndef CC_DEBUG_TRACED_VALUE_H_ |
6 #define CC_DEBUG_TRACED_VALUE_H_ | 6 #define CC_DEBUG_TRACED_VALUE_H_ |
7 | 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/debug/trace_event.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 |
8 namespace base { | 13 namespace base { |
9 namespace debug { | 14 class DictionaryValue; |
10 class TracedValue; | 15 class Value; |
11 } | 16 } |
12 } | |
13 | |
14 namespace cc { | 17 namespace cc { |
15 | 18 |
16 class TracedValue { | 19 class TracedValue : public base::debug::ConvertableToTraceFormat { |
17 public: | 20 public: |
18 static void AppendIDRef(const void* id, base::debug::TracedValue* array); | 21 static scoped_ptr<base::Value> CreateIDRef(const void* id); |
19 static void SetIDRef(const void* id, | 22 static void MakeDictIntoImplicitSnapshot( |
20 base::debug::TracedValue* dict, | 23 base::DictionaryValue* dict, const char* object_name, const void* id); |
21 const char* name); | |
22 static void MakeDictIntoImplicitSnapshot(base::debug::TracedValue* dict, | |
23 const char* object_name, | |
24 const void* id); | |
25 static void MakeDictIntoImplicitSnapshotWithCategory( | 24 static void MakeDictIntoImplicitSnapshotWithCategory( |
26 const char* category, | 25 const char* category, |
27 base::debug::TracedValue* dict, | 26 base::DictionaryValue* dict, |
28 const char* object_name, | 27 const char* object_name, |
29 const void* id); | 28 const void* id); |
30 static void MakeDictIntoImplicitSnapshotWithCategory( | 29 static void MakeDictIntoImplicitSnapshotWithCategory( |
31 const char* category, | 30 const char* category, |
32 base::debug::TracedValue* dict, | 31 base::DictionaryValue* dict, |
33 const char* object_base_type_name, | 32 const char* object_base_type_name, |
34 const char* object_name, | 33 const char* object_name, |
35 const void* id); | 34 const void* id); |
| 35 static scoped_refptr<base::debug::ConvertableToTraceFormat> FromValue( |
| 36 base::Value* value); |
| 37 |
| 38 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE; |
| 39 |
| 40 private: |
| 41 explicit TracedValue(base::Value* value); |
| 42 virtual ~TracedValue(); |
| 43 |
| 44 scoped_ptr<base::Value> value_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(TracedValue); |
36 }; | 47 }; |
37 | 48 |
| 49 template <class T> |
| 50 static scoped_refptr<base::debug::ConvertableToTraceFormat> ToTrace(T* t) { |
| 51 return TracedValue::FromValue(t->AsValue().release()); |
| 52 } |
| 53 |
| 54 template <class T> |
| 55 static scoped_refptr<base::debug::ConvertableToTraceFormat> ToTrace( |
| 56 const T& t) { |
| 57 return ToTrace(&t); |
| 58 } |
| 59 |
38 } // namespace cc | 60 } // namespace cc |
39 | 61 |
40 #endif // CC_DEBUG_TRACED_VALUE_H_ | 62 #endif // CC_DEBUG_TRACED_VALUE_H_ |
OLD | NEW |