| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BROWSER_TRACE_CONTROLLER_H_ | 5 #ifndef CONTENT_BROWSER_TRACE_CONTROLLER_H_ |
| 6 #define CONTENT_BROWSER_TRACE_CONTROLLER_H_ | 6 #define CONTENT_BROWSER_TRACE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 15 #include "base/task.h" | 15 #include "base/task.h" |
| 16 #include "content/common/content_export.h" |
| 16 | 17 |
| 17 class TraceMessageFilter; | 18 class TraceMessageFilter; |
| 18 | 19 |
| 19 // Objects interested in receiving trace data derive from TraceSubscriber. | 20 // Objects interested in receiving trace data derive from TraceSubscriber. |
| 20 // See also: trace_message_filter.h | 21 // See also: trace_message_filter.h |
| 21 // See also: child_trace_message_filter.h | 22 // See also: child_trace_message_filter.h |
| 22 class TraceSubscriber { | 23 class TraceSubscriber { |
| 23 public: | 24 public: |
| 24 // Called once after TraceController::EndTracingAsync. | 25 // Called once after TraceController::EndTracingAsync. |
| 25 virtual void OnEndTracingComplete() = 0; | 26 virtual void OnEndTracingComplete() = 0; |
| 26 // Called 0 or more times between TraceController::BeginTracing and | 27 // Called 0 or more times between TraceController::BeginTracing and |
| 27 // OnEndTracingComplete. | 28 // OnEndTracingComplete. |
| 28 virtual void OnTraceDataCollected(const std::string& json_events) = 0; | 29 virtual void OnTraceDataCollected(const std::string& json_events) = 0; |
| 29 // Called once after TraceController::GetKnownCategoriesAsync. | 30 // Called once after TraceController::GetKnownCategoriesAsync. |
| 30 virtual void OnKnownCategoriesCollected( | 31 virtual void OnKnownCategoriesCollected( |
| 31 const std::set<std::string>& known_categories) {} | 32 const std::set<std::string>& known_categories) {} |
| 32 virtual void OnTraceBufferPercentFullReply(float percent_full) {} | 33 virtual void OnTraceBufferPercentFullReply(float percent_full) {} |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 // TraceController is used on the browser processes to enable/disable | 36 // TraceController is used on the browser processes to enable/disable |
| 36 // trace status and collect trace data. Only the browser UI thread is allowed | 37 // trace status and collect trace data. Only the browser UI thread is allowed |
| 37 // to interact with the TraceController object. All calls on the TraceSubscriber | 38 // to interact with the TraceController object. All calls on the TraceSubscriber |
| 38 // happen on the UI thread. | 39 // happen on the UI thread. |
| 39 class TraceController { | 40 class CONTENT_EXPORT TraceController { |
| 40 public: | 41 public: |
| 41 static TraceController* GetInstance(); | 42 static TraceController* GetInstance(); |
| 42 | 43 |
| 43 // Get set of known categories. This can change as new code paths are reached. | 44 // Get set of known categories. This can change as new code paths are reached. |
| 44 // If true is returned, subscriber->OnKnownCategoriesCollected will be called | 45 // If true is returned, subscriber->OnKnownCategoriesCollected will be called |
| 45 // when once the categories are retrieved from child processes. | 46 // when once the categories are retrieved from child processes. |
| 46 bool GetKnownCategoriesAsync(TraceSubscriber* subscriber); | 47 bool GetKnownCategoriesAsync(TraceSubscriber* subscriber); |
| 47 | 48 |
| 48 // Called by browser process to start tracing events on all processes. | 49 // Called by browser process to start tracing events on all processes. |
| 49 // | 50 // |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 std::vector<std::string> included_categories_; | 153 std::vector<std::string> included_categories_; |
| 153 std::vector<std::string> excluded_categories_; | 154 std::vector<std::string> excluded_categories_; |
| 154 | 155 |
| 155 DISALLOW_COPY_AND_ASSIGN(TraceController); | 156 DISALLOW_COPY_AND_ASSIGN(TraceController); |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 DISABLE_RUNNABLE_METHOD_REFCOUNT(TraceController); | 159 DISABLE_RUNNABLE_METHOD_REFCOUNT(TraceController); |
| 159 | 160 |
| 160 #endif // CONTENT_BROWSER_TRACE_CONTROLLER_H_ | 161 #endif // CONTENT_BROWSER_TRACE_CONTROLLER_H_ |
| 161 | 162 |
| OLD | NEW |