X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcontent%2Fpublic%2Fbrowser%2Ftracing_controller.h;h=5b3eb4e4873abf6930d398294003aa0ef84c4098;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=67a28cd919f7b03291006b128946cf56a332d9b1;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/content/public/browser/tracing_controller.h b/src/content/public/browser/tracing_controller.h index 67a28cd..5b3eb4e 100644 --- a/src/content/public/browser/tracing_controller.h +++ b/src/content/public/browser/tracing_controller.h @@ -10,12 +10,9 @@ #include "base/callback.h" #include "base/debug/trace_event.h" +#include "base/memory/ref_counted.h" #include "content/common/content_export.h" -namespace base { -class FilePath; -}; - namespace content { class TracingController; @@ -29,6 +26,36 @@ class TracingController { CONTENT_EXPORT static TracingController* GetInstance(); + // An interface for trace data consumer. An implemnentation of this interface + // is passed to either DisableTracing() or CaptureMonitoringSnapshot() and + // receives the trace data followed by a notification that all child processes + // have completed tracing and the data collection is over. + // All methods are called on the UI thread. + // Close method will be called exactly once and no methods will be + // called after that. + class CONTENT_EXPORT TraceDataSink + : public base::RefCountedThreadSafe { + public: + virtual void AddTraceChunk(const std::string& chunk) {} + virtual void SetSystemTrace(const std::string& data) {} + virtual void Close() {} + + protected: + friend class base::RefCountedThreadSafe; + virtual ~TraceDataSink() {} + }; + + // Create a trace sink that may be supplied to DisableRecording or + // CaptureMonitoringSnapshot to capture the trace data as a string. + CONTENT_EXPORT static scoped_refptr CreateStringSink( + const base::Callback& callback); + + // Create a trace sink that may be supplied to DisableRecording or + // CaptureMonitoringSnapshot to dump the trace data to a file. + CONTENT_EXPORT static scoped_refptr CreateFileSink( + const base::FilePath& file_path, + const base::Closure& callback); + // Get a set of category groups. The category groups can change as // new code paths are reached. // @@ -76,15 +103,12 @@ class TracingController { // TracingFileResultCallback will be called back with a file that contains // the traced data. // - // Trace data will be written into |result_file_path| if it is not empty, or - // into a temporary file. The actual file path will be passed to |callback| if - // it's not null. + // If |trace_data_sink| is not null, it will receive chunks of trace data + // as a comma-separated sequences of JSON-stringified events, followed by + // a notification that the trace collection is finished. // - // If |result_file_path| is empty and |callback| is null, trace data won't be - // written to any file. - typedef base::Callback TracingFileResultCallback; - virtual bool DisableRecording(const base::FilePath& result_file_path, - const TracingFileResultCallback& callback) = 0; + virtual bool DisableRecording( + const scoped_refptr& trace_data_sink) = 0; // Start monitoring on all processes. // @@ -130,14 +154,11 @@ class TracingController { // request, TracingFileResultCallback will be called back with a file that // contains the traced data. // - // Trace data will be written into |result_file_path| if it is not empty, or - // into a temporary file. The actual file path will be passed to |callback|. - // - // If |result_file_path| is empty and |callback| is null, trace data won't be - // written to any file. + // If |trace_data_sink| is not null, it will receive chunks of trace data + // as a comma-separated sequences of JSON-stringified events, followed by + // a notification that the trace collection is finished. virtual bool CaptureMonitoringSnapshot( - const base::FilePath& result_file_path, - const TracingFileResultCallback& callback) = 0; + const scoped_refptr& trace_data_sink) = 0; // Get the maximum across processes of trace buffer percent full state. // When the TraceBufferPercentFull value is determined, the callback is