| 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 CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 virtual void AddTraceChunk(const std::string& chunk) {} | 45 virtual void AddTraceChunk(const std::string& chunk) {} |
| 46 | 46 |
| 47 // Add a TracingAgent's trace to the data sink. | 47 // Add a TracingAgent's trace to the data sink. |
| 48 virtual void AddAgentTrace(const std::string& trace_label, | 48 virtual void AddAgentTrace(const std::string& trace_label, |
| 49 const std::string& trace_data); | 49 const std::string& trace_data); |
| 50 | 50 |
| 51 // Notice that TracingController adds some default metadata when | 51 // Notice that TracingController adds some default metadata when |
| 52 // StopTracing is called, which may override metadata that you would | 52 // StopTracing is called, which may override metadata that you would |
| 53 // set beforehand in case of key collision. | 53 // set beforehand in case of key collision. |
| 54 virtual void AddMetadata(const base::DictionaryValue& data); | 54 virtual void AddMetadata(const base::DictionaryValue& data); |
| 55 virtual scoped_ptr<const base::DictionaryValue> GetMetadataCopy() const; | 55 virtual std::unique_ptr<const base::DictionaryValue> GetMetadataCopy() |
| 56 const; |
| 56 virtual void SetMetadataFilterPredicate( | 57 virtual void SetMetadataFilterPredicate( |
| 57 const MetadataFilterPredicate& metadata_filter_predicate); | 58 const MetadataFilterPredicate& metadata_filter_predicate); |
| 58 virtual void Close() {} | 59 virtual void Close() {} |
| 59 | 60 |
| 60 protected: | 61 protected: |
| 61 friend class base::RefCountedThreadSafe<TraceDataSink>; | 62 friend class base::RefCountedThreadSafe<TraceDataSink>; |
| 62 | 63 |
| 63 // Get a map of TracingAgent's data, which is previously added by | 64 // Get a map of TracingAgent's data, which is previously added by |
| 64 // AddAgentTrace(). The map's key is the trace label and the map's value is | 65 // AddAgentTrace(). The map's key is the trace label and the map's value is |
| 65 // the trace data. | 66 // the trace data. |
| 66 virtual const std::map<std::string, std::string>& GetAgentTrace() const; | 67 virtual const std::map<std::string, std::string>& GetAgentTrace() const; |
| 67 | 68 |
| 68 virtual ~TraceDataSink(); | 69 virtual ~TraceDataSink(); |
| 69 | 70 |
| 70 private: | 71 private: |
| 71 std::map<std::string, std::string> additional_tracing_agent_trace_; | 72 std::map<std::string, std::string> additional_tracing_agent_trace_; |
| 72 MetadataFilterPredicate metadata_filter_predicate_; | 73 MetadataFilterPredicate metadata_filter_predicate_; |
| 73 base::DictionaryValue metadata_; | 74 base::DictionaryValue metadata_; |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 // An implementation of this interface is passed when constructing a | 77 // An implementation of this interface is passed when constructing a |
| 77 // TraceDataSink, and receives chunks of the final trace data as it's being | 78 // TraceDataSink, and receives chunks of the final trace data as it's being |
| 78 // constructed. | 79 // constructed. |
| 79 // Methods may be called from any thread. | 80 // Methods may be called from any thread. |
| 80 class CONTENT_EXPORT TraceDataEndpoint | 81 class CONTENT_EXPORT TraceDataEndpoint |
| 81 : public base::RefCountedThreadSafe<TraceDataEndpoint> { | 82 : public base::RefCountedThreadSafe<TraceDataEndpoint> { |
| 82 public: | 83 public: |
| 83 virtual void ReceiveTraceChunk(const std::string& chunk) {} | 84 virtual void ReceiveTraceChunk(const std::string& chunk) {} |
| 84 virtual void ReceiveTraceFinalContents( | 85 virtual void ReceiveTraceFinalContents( |
| 85 scoped_ptr<const base::DictionaryValue> metadata, | 86 std::unique_ptr<const base::DictionaryValue> metadata, |
| 86 const std::string& contents) {} | 87 const std::string& contents) {} |
| 87 | 88 |
| 88 protected: | 89 protected: |
| 89 friend class base::RefCountedThreadSafe<TraceDataEndpoint>; | 90 friend class base::RefCountedThreadSafe<TraceDataEndpoint>; |
| 90 virtual ~TraceDataEndpoint() {} | 91 virtual ~TraceDataEndpoint() {} |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 // Create a trace sink that may be supplied to StopTracing | 94 // Create a trace sink that may be supplied to StopTracing |
| 94 // to capture the trace data as a string. | 95 // to capture the trace data as a string. |
| 95 CONTENT_EXPORT static scoped_refptr<TraceDataSink> CreateStringSink( | 96 CONTENT_EXPORT static scoped_refptr<TraceDataSink> CreateStringSink( |
| 96 const base::Callback<void(scoped_ptr<const base::DictionaryValue>, | 97 const base::Callback<void(std::unique_ptr<const base::DictionaryValue>, |
| 97 base::RefCountedString*)>& callback); | 98 base::RefCountedString*)>& callback); |
| 98 | 99 |
| 99 CONTENT_EXPORT static scoped_refptr<TraceDataSink> CreateCompressedStringSink( | 100 CONTENT_EXPORT static scoped_refptr<TraceDataSink> CreateCompressedStringSink( |
| 100 scoped_refptr<TraceDataEndpoint> endpoint); | 101 scoped_refptr<TraceDataEndpoint> endpoint); |
| 101 | 102 |
| 102 // Create a trace sink that may be supplied to StopTracing | 103 // Create a trace sink that may be supplied to StopTracing |
| 103 // to dump the trace data to a file. | 104 // to dump the trace data to a file. |
| 104 CONTENT_EXPORT static scoped_refptr<TraceDataSink> CreateFileSink( | 105 CONTENT_EXPORT static scoped_refptr<TraceDataSink> CreateFileSink( |
| 105 const base::FilePath& file_path, | 106 const base::FilePath& file_path, |
| 106 const base::Closure& callback); | 107 const base::Closure& callback); |
| 107 | 108 |
| 108 // Create an endpoint that may be supplied to any TraceDataSink to | 109 // Create an endpoint that may be supplied to any TraceDataSink to |
| 109 // dump the trace data to a callback. | 110 // dump the trace data to a callback. |
| 110 CONTENT_EXPORT static scoped_refptr<TraceDataEndpoint> CreateCallbackEndpoint( | 111 CONTENT_EXPORT static scoped_refptr<TraceDataEndpoint> CreateCallbackEndpoint( |
| 111 const base::Callback<void(scoped_ptr<const base::DictionaryValue>, | 112 const base::Callback<void(std::unique_ptr<const base::DictionaryValue>, |
| 112 base::RefCountedString*)>& callback); | 113 base::RefCountedString*)>& callback); |
| 113 | 114 |
| 114 // Create an endpoint that may be supplied to any TraceDataSink to | 115 // Create an endpoint that may be supplied to any TraceDataSink to |
| 115 // dump the trace data to a file. | 116 // dump the trace data to a file. |
| 116 CONTENT_EXPORT static scoped_refptr<TraceDataEndpoint> CreateFileEndpoint( | 117 CONTENT_EXPORT static scoped_refptr<TraceDataEndpoint> CreateFileEndpoint( |
| 117 const base::FilePath& file_path, | 118 const base::FilePath& file_path, |
| 118 const base::Closure& callback); | 119 const base::Closure& callback); |
| 119 | 120 |
| 120 // Get a set of category groups. The category groups can change as | 121 // Get a set of category groups. The category groups can change as |
| 121 // new code paths are reached. | 122 // new code paths are reached. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // Check if the tracing system is tracing | 192 // Check if the tracing system is tracing |
| 192 virtual bool IsTracing() const = 0; | 193 virtual bool IsTracing() const = 0; |
| 193 | 194 |
| 194 protected: | 195 protected: |
| 195 virtual ~TracingController() {} | 196 virtual ~TracingController() {} |
| 196 }; | 197 }; |
| 197 | 198 |
| 198 } // namespace content | 199 } // namespace content |
| 199 | 200 |
| 200 #endif // CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_ | 201 #endif // CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_ |
| OLD | NEW |