| 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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/browser/tracing_delegate.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 class TracingController; | 20 class TracingController; |
| 20 | 21 |
| 21 // TracingController is used on the browser processes to enable/disable | 22 // TracingController is used on the browser processes to enable/disable |
| 22 // tracing status and collect trace data. Only the browser UI thread is allowed | 23 // tracing status and collect trace data. Only the browser UI thread is allowed |
| 23 // to interact with the TracingController object. All callbacks are called on | 24 // to interact with the TracingController object. All callbacks are called on |
| 24 // the UI thread. | 25 // the UI thread. |
| 25 class TracingController { | 26 class TracingController { |
| 26 public: | 27 public: |
| 27 | 28 |
| 28 CONTENT_EXPORT static TracingController* GetInstance(); | 29 CONTENT_EXPORT static TracingController* GetInstance(); |
| 29 | 30 |
| 30 // An interface for trace data consumer. An implemnentation of this interface | 31 // An interface for trace data consumer. An implemnentation of this interface |
| 31 // is passed to either DisableTracing() or CaptureMonitoringSnapshot() and | 32 // is passed to either DisableTracing() or CaptureMonitoringSnapshot() and |
| 32 // receives the trace data followed by a notification that all child processes | 33 // receives the trace data followed by a notification that all child processes |
| 33 // have completed tracing and the data collection is over. | 34 // have completed tracing and the data collection is over. |
| 34 // All methods are called on the UI thread. | 35 // All methods are called on the UI thread. |
| 35 // Close method will be called exactly once and no methods will be | 36 // Close method will be called exactly once and no methods will be |
| 36 // called after that. | 37 // called after that. |
| 37 class CONTENT_EXPORT TraceDataSink | 38 class CONTENT_EXPORT TraceDataSink |
| 38 : public base::RefCountedThreadSafe<TraceDataSink> { | 39 : public base::RefCountedThreadSafe<TraceDataSink> { |
| 39 public: | 40 public: |
| 41 TraceDataSink(); |
| 42 |
| 40 virtual void AddTraceChunk(const std::string& chunk) {} | 43 virtual void AddTraceChunk(const std::string& chunk) {} |
| 41 virtual void SetSystemTrace(const std::string& data) {} | 44 virtual void SetSystemTrace(const std::string& data) {} |
| 42 | 45 |
| 43 // Notice that TracingController adds some default metadata when | 46 // Notice that TracingController adds some default metadata when |
| 44 // DisableRecording is called, which may override metadata that you would | 47 // StopTracing is called, which may override metadata that you would |
| 45 // set beforehand in case of key collision. | 48 // set beforehand in case of key collision. |
| 46 virtual void AddMetadata(const base::DictionaryValue& data); | 49 virtual void AddMetadata(const base::DictionaryValue& data); |
| 47 virtual const base::DictionaryValue& GetMetadata() const; | 50 virtual scoped_ptr<const base::DictionaryValue> GetMetadataCopy() const; |
| 51 virtual void SetMetadataFilterPredicate( |
| 52 const MetadataFilterPredicate& metadata_filter_predicate); |
| 48 // TODO(prabhur) Replace all the Set* functions with a generic function: | 53 // TODO(prabhur) Replace all the Set* functions with a generic function: |
| 49 // TraceDataSink::AppendAdditionalData(const std::string& name, | 54 // TraceDataSink::AppendAdditionalData(const std::string& name, |
| 50 // const std::string& trace_data) | 55 // const std::string& trace_data) |
| 51 virtual void SetPowerTrace(const std::string& data) {} | 56 virtual void SetPowerTrace(const std::string& data) {} |
| 52 virtual void Close() {} | 57 virtual void Close() {} |
| 53 | 58 |
| 54 protected: | 59 protected: |
| 55 friend class base::RefCountedThreadSafe<TraceDataSink>; | 60 friend class base::RefCountedThreadSafe<TraceDataSink>; |
| 56 virtual ~TraceDataSink() {} | 61 virtual ~TraceDataSink(); |
| 57 | 62 |
| 58 private: | 63 private: |
| 64 MetadataFilterPredicate metadata_filter_predicate_; |
| 59 base::DictionaryValue metadata_; | 65 base::DictionaryValue metadata_; |
| 60 }; | 66 }; |
| 61 | 67 |
| 62 // An implementation of this interface is passed when constructing a | 68 // An implementation of this interface is passed when constructing a |
| 63 // TraceDataSink, and receives chunks of the final trace data as it's being | 69 // TraceDataSink, and receives chunks of the final trace data as it's being |
| 64 // constructed. | 70 // constructed. |
| 65 // Methods may be called from any thread. | 71 // Methods may be called from any thread. |
| 66 class CONTENT_EXPORT TraceDataEndpoint | 72 class CONTENT_EXPORT TraceDataEndpoint |
| 67 : public base::RefCountedThreadSafe<TraceDataEndpoint> { | 73 : public base::RefCountedThreadSafe<TraceDataEndpoint> { |
| 68 public: | 74 public: |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 // Check if the tracing system is tracing | 231 // Check if the tracing system is tracing |
| 226 virtual bool IsTracing() const = 0; | 232 virtual bool IsTracing() const = 0; |
| 227 | 233 |
| 228 protected: | 234 protected: |
| 229 virtual ~TracingController() {} | 235 virtual ~TracingController() {} |
| 230 }; | 236 }; |
| 231 | 237 |
| 232 } // namespace content | 238 } // namespace content |
| 233 | 239 |
| 234 #endif // CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_ | 240 #endif // CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_ |
| OLD | NEW |