| 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/debug/trace_event.h" | 
| 12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" | 
| 13 | 14 | 
| 14 namespace base { | 15 namespace base { | 
| 15 class FilePath; | 16 class FilePath; | 
| 16 }; | 17 }; | 
| 17 | 18 | 
| 18 namespace content { | 19 namespace content { | 
| 19 | 20 | 
| 20 class TracingController; | 21 class TracingController; | 
| 21 | 22 | 
| 22 // TracingController is used on the browser processes to enable/disable | 23 // TracingController is used on the browser processes to enable/disable | 
| 23 // trace status and collect trace data. Only the browser UI thread is allowed | 24 // trace status and collect trace data. Only the browser UI thread is allowed | 
| 24 // to interact with the TracingController object. All callbacks are called on | 25 // to interact with the TracingController object. All callbacks are called on | 
| 25 // the UI thread. | 26 // the UI thread. | 
| 26 class TracingController { | 27 class TracingController { | 
| 27  public: | 28  public: | 
| 28   enum Options { |  | 
| 29     DEFAULT_OPTIONS = 0, |  | 
| 30     ENABLE_SYSTRACE = 1 << 0, |  | 
| 31     ENABLE_SAMPLING = 1 << 1, |  | 
| 32     RECORD_CONTINUOUSLY = 1 << 2,  // For EnableRecording() only. |  | 
| 33   }; |  | 
| 34 | 29 | 
| 35   CONTENT_EXPORT static TracingController* GetInstance(); | 30   CONTENT_EXPORT static TracingController* GetInstance(); | 
| 36 | 31 | 
| 37   // Get a set of category groups. The category groups can change as | 32   // Get a set of category groups. The category groups can change as | 
| 38   // new code paths are reached. | 33   // new code paths are reached. | 
| 39   // | 34   // | 
| 40   // Once all child processes have acked to the GetCategories request, | 35   // Once all child processes have acked to the GetCategories request, | 
| 41   // GetCategoriesDoneCallback is called back with a set of category | 36   // GetCategoriesDoneCallback is called back with a set of category | 
| 42   // groups. | 37   // groups. | 
| 43   typedef base::Callback<void(const std::set<std::string>&)> | 38   typedef base::Callback<void(const std::set<std::string>&)> | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 58   // that contain a matching category. Having both included and excluded | 53   // that contain a matching category. Having both included and excluded | 
| 59   // category patterns in the same list would not be supported. | 54   // category patterns in the same list would not be supported. | 
| 60   // | 55   // | 
| 61   // Examples: "test_MyTest*", | 56   // Examples: "test_MyTest*", | 
| 62   //           "test_MyTest*,test_OtherStuff", | 57   //           "test_MyTest*,test_OtherStuff", | 
| 63   //           "-excluded_category1,-excluded_category2" | 58   //           "-excluded_category1,-excluded_category2" | 
| 64   // | 59   // | 
| 65   // |options| controls what kind of tracing is enabled. | 60   // |options| controls what kind of tracing is enabled. | 
| 66   typedef base::Callback<void()> EnableRecordingDoneCallback; | 61   typedef base::Callback<void()> EnableRecordingDoneCallback; | 
| 67   virtual bool EnableRecording( | 62   virtual bool EnableRecording( | 
| 68       const std::string& category_filter, | 63       const base::debug::CategoryFilter& category_filter, | 
| 69       TracingController::Options options, | 64       const base::debug::TraceOptions& trace_options, | 
| 70       const EnableRecordingDoneCallback& callback) = 0; | 65       const EnableRecordingDoneCallback& callback) = 0; | 
| 71 | 66 | 
| 72   // Stop recording on all processes. | 67   // Stop recording on all processes. | 
| 73   // | 68   // | 
| 74   // Child processes typically are caching trace data and only rarely flush | 69   // Child processes typically are caching trace data and only rarely flush | 
| 75   // and send trace data back to the browser process. That is because it may be | 70   // and send trace data back to the browser process. That is because it may be | 
| 76   // an expensive operation to send the trace data over IPC, and we would like | 71   // an expensive operation to send the trace data over IPC, and we would like | 
| 77   // to avoid much runtime overhead of tracing. So, to end tracing, we must | 72   // to avoid much runtime overhead of tracing. So, to end tracing, we must | 
| 78   // asynchronously ask all child processes to flush any pending trace data. | 73   // asynchronously ask all child processes to flush any pending trace data. | 
| 79   // | 74   // | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 98   // | 93   // | 
| 99   // Once all child processes have acked to the EnableMonitoring request, | 94   // Once all child processes have acked to the EnableMonitoring request, | 
| 100   // EnableMonitoringDoneCallback will be called back. | 95   // EnableMonitoringDoneCallback will be called back. | 
| 101   // | 96   // | 
| 102   // |category_filter| is a filter to control what category groups should be | 97   // |category_filter| is a filter to control what category groups should be | 
| 103   // traced. | 98   // traced. | 
| 104   // | 99   // | 
| 105   // |options| controls what kind of tracing is enabled. | 100   // |options| controls what kind of tracing is enabled. | 
| 106   typedef base::Callback<void()> EnableMonitoringDoneCallback; | 101   typedef base::Callback<void()> EnableMonitoringDoneCallback; | 
| 107   virtual bool EnableMonitoring( | 102   virtual bool EnableMonitoring( | 
| 108       const std::string& category_filter, | 103       const base::debug::CategoryFilter& category_filter, | 
| 109       TracingController::Options options, | 104       const base::debug::TraceOptions& trace_options, | 
| 110       const EnableMonitoringDoneCallback& callback) = 0; | 105       const EnableMonitoringDoneCallback& callback) = 0; | 
| 111 | 106 | 
| 112   // Stop monitoring on all processes. | 107   // Stop monitoring on all processes. | 
| 113   // | 108   // | 
| 114   // Once all child processes have acked to the DisableMonitoring request, | 109   // Once all child processes have acked to the DisableMonitoring request, | 
| 115   // DisableMonitoringDoneCallback is called back. | 110   // DisableMonitoringDoneCallback is called back. | 
| 116   typedef base::Callback<void()> DisableMonitoringDoneCallback; | 111   typedef base::Callback<void()> DisableMonitoringDoneCallback; | 
| 117   virtual bool DisableMonitoring( | 112   virtual bool DisableMonitoring( | 
| 118       const DisableMonitoringDoneCallback& callback) = 0; | 113       const DisableMonitoringDoneCallback& callback) = 0; | 
| 119 | 114 | 
| 120   // Get the current monitoring configuration. | 115   // Get the current monitoring configuration. | 
| 121   virtual void GetMonitoringStatus(bool* out_enabled, | 116   virtual void GetMonitoringStatus( | 
| 122                                    std::string* out_category_filter, | 117       bool* out_enabled, | 
| 123                                    TracingController::Options* out_options) = 0; | 118       base::debug::CategoryFilter* out_category_filter, | 
|  | 119       base::debug::TraceOptions* out_trace_options) = 0; | 
| 124 | 120 | 
| 125   // Get the current monitoring traced data. | 121   // Get the current monitoring traced data. | 
| 126   // | 122   // | 
| 127   // Child processes typically are caching trace data and only rarely flush | 123   // Child processes typically are caching trace data and only rarely flush | 
| 128   // and send trace data back to the browser process. That is because it may be | 124   // and send trace data back to the browser process. That is because it may be | 
| 129   // an expensive operation to send the trace data over IPC, and we would like | 125   // an expensive operation to send the trace data over IPC, and we would like | 
| 130   // to avoid much runtime overhead of tracing. So, to end tracing, we must | 126   // to avoid much runtime overhead of tracing. So, to end tracing, we must | 
| 131   // asynchronously ask all child processes to flush any pending trace data. | 127   // asynchronously ask all child processes to flush any pending trace data. | 
| 132   // | 128   // | 
| 133   // Once all child processes have acked to the CaptureMonitoringSnapshot | 129   // Once all child processes have acked to the CaptureMonitoringSnapshot | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 161   // watch event callback. | 157   // watch event callback. | 
| 162   virtual bool CancelWatchEvent() = 0; | 158   virtual bool CancelWatchEvent() = 0; | 
| 163 | 159 | 
| 164  protected: | 160  protected: | 
| 165   virtual ~TracingController() {} | 161   virtual ~TracingController() {} | 
| 166 }; | 162 }; | 
| 167 | 163 | 
| 168 }  // namespace content | 164 }  // namespace content | 
| 169 | 165 | 
| 170 #endif  // CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_ | 166 #endif  // CONTENT_PUBLIC_BROWSER_TRACING_CONTROLLER_H_ | 
| OLD | NEW | 
|---|