| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_TRACING_TRACE_CONTROLLER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_H_ | 6 #define CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_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/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "content/public/browser/trace_controller.h" | 14 #include "content/public/browser/trace_controller.h" |
| 15 | 15 |
| 16 class CommandLine; | 16 class CommandLine; |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 class TraceMessageFilter; | 19 class TraceMessageFilter; |
| 20 | 20 |
| 21 class TraceControllerImpl : public TraceController { | 21 class TraceControllerImpl : public TraceController { |
| 22 public: | 22 public: |
| 23 static TraceControllerImpl* GetInstance(); | 23 static TraceControllerImpl* GetInstance(); |
| 24 | 24 |
| 25 // Called on the main thread of the browser process to initialize | 25 // Called on the main thread of the browser process to initialize |
| 26 // startup tracing. | 26 // startup tracing. |
| 27 void InitStartupTracing(const CommandLine& command_line); | 27 void InitStartupTracing(const CommandLine& command_line); |
| 28 | 28 |
| 29 // Same as above, but specifies which categories to trace. | |
| 30 // If both included_categories and excluded_categories are empty, | |
| 31 // all categories are traced. | |
| 32 // Else if included_categories is non-empty, only those are traced. | |
| 33 // Else if excluded_categories is non-empty, everything but those are traced. | |
| 34 bool BeginTracing(TraceSubscriber* subscriber, | |
| 35 const std::vector<std::string>& included_categories, | |
| 36 const std::vector<std::string>& excluded_categories, | |
| 37 base::debug::TraceLog::Options options); | |
| 38 | |
| 39 // TraceController implementation: | 29 // TraceController implementation: |
| 40 virtual bool BeginTracing(TraceSubscriber* subscriber, | 30 virtual bool BeginTracing(TraceSubscriber* subscriber, |
| 41 const std::string& categories, | 31 const std::string& category_patterns, |
| 42 base::debug::TraceLog::Options options) OVERRIDE; | 32 base::debug::TraceLog::Options options) OVERRIDE; |
| 43 virtual bool EndTracingAsync(TraceSubscriber* subscriber) OVERRIDE; | 33 virtual bool EndTracingAsync(TraceSubscriber* subscriber) OVERRIDE; |
| 44 virtual bool GetTraceBufferPercentFullAsync( | 34 virtual bool GetTraceBufferPercentFullAsync( |
| 45 TraceSubscriber* subscriber) OVERRIDE; | 35 TraceSubscriber* subscriber) OVERRIDE; |
| 46 virtual bool SetWatchEvent(TraceSubscriber* subscriber, | 36 virtual bool SetWatchEvent(TraceSubscriber* subscriber, |
| 47 const std::string& category_name, | 37 const std::string& category_name, |
| 48 const std::string& event_name) OVERRIDE; | 38 const std::string& event_name) OVERRIDE; |
| 49 virtual bool CancelWatchEvent(TraceSubscriber* subscriber) OVERRIDE; | 39 virtual bool CancelWatchEvent(TraceSubscriber* subscriber) OVERRIDE; |
| 50 virtual void CancelSubscriber(TraceSubscriber* subscriber) OVERRIDE; | 40 virtual void CancelSubscriber(TraceSubscriber* subscriber) OVERRIDE; |
| 51 virtual bool GetKnownCategoriesAsync(TraceSubscriber* subscriber) OVERRIDE; | 41 virtual bool GetKnownCategoryGroupsAsync(TraceSubscriber* subscriber) |
| 42 OVERRIDE; |
| 52 | 43 |
| 53 private: | 44 private: |
| 54 typedef std::set<scoped_refptr<TraceMessageFilter> > FilterMap; | 45 typedef std::set<scoped_refptr<TraceMessageFilter> > FilterMap; |
| 55 | 46 |
| 56 friend struct base::DefaultLazyInstanceTraits<TraceControllerImpl>; | 47 friend struct base::DefaultLazyInstanceTraits<TraceControllerImpl>; |
| 57 friend class TraceMessageFilter; | 48 friend class TraceMessageFilter; |
| 58 | 49 |
| 59 TraceControllerImpl(); | 50 TraceControllerImpl(); |
| 60 virtual ~TraceControllerImpl(); | 51 virtual ~TraceControllerImpl(); |
| 61 | 52 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 77 bool can_begin_tracing(TraceSubscriber* subscriber) const { | 68 bool can_begin_tracing(TraceSubscriber* subscriber) const { |
| 78 return !is_tracing_ && | 69 return !is_tracing_ && |
| 79 (subscriber_ == NULL || subscriber == subscriber_); | 70 (subscriber_ == NULL || subscriber == subscriber_); |
| 80 } | 71 } |
| 81 | 72 |
| 82 // Methods for use by TraceMessageFilter. | 73 // Methods for use by TraceMessageFilter. |
| 83 | 74 |
| 84 void AddFilter(TraceMessageFilter* filter); | 75 void AddFilter(TraceMessageFilter* filter); |
| 85 void RemoveFilter(TraceMessageFilter* filter); | 76 void RemoveFilter(TraceMessageFilter* filter); |
| 86 void OnTracingBegan(TraceSubscriber* subscriber); | 77 void OnTracingBegan(TraceSubscriber* subscriber); |
| 87 void OnEndTracingAck(const std::vector<std::string>& known_categories); | 78 void OnEndTracingAck(const std::vector<std::string>& known_category_groups); |
| 88 void OnTraceDataCollected( | 79 void OnTraceDataCollected( |
| 89 const scoped_refptr<base::RefCountedString>& events_str_ptr); | 80 const scoped_refptr<base::RefCountedString>& events_str_ptr); |
| 90 void OnTraceNotification(int notification); | 81 void OnTraceNotification(int notification); |
| 91 void OnTraceBufferPercentFullReply(float percent_full); | 82 void OnTraceBufferPercentFullReply(float percent_full); |
| 92 | 83 |
| 93 FilterMap filters_; | 84 FilterMap filters_; |
| 94 TraceSubscriber* subscriber_; | 85 TraceSubscriber* subscriber_; |
| 95 // Pending acks for EndTracingAsync: | 86 // Pending acks for EndTracingAsync: |
| 96 int pending_end_ack_count_; | 87 int pending_end_ack_count_; |
| 97 // Pending acks for GetTraceBufferPercentFullAsync: | 88 // Pending acks for GetTraceBufferPercentFullAsync: |
| 98 int pending_bpf_ack_count_; | 89 int pending_bpf_ack_count_; |
| 99 float maximum_bpf_; | 90 float maximum_bpf_; |
| 100 bool is_tracing_; | 91 bool is_tracing_; |
| 101 bool is_get_categories_; | 92 bool is_get_category_groups_; |
| 102 std::set<std::string> known_categories_; | 93 std::set<std::string> known_category_groups_; |
| 103 std::vector<std::string> included_categories_; | |
| 104 std::vector<std::string> excluded_categories_; | |
| 105 std::string watch_category_; | 94 std::string watch_category_; |
| 106 std::string watch_name_; | 95 std::string watch_name_; |
| 107 base::debug::TraceLog::Options trace_options_; | 96 base::debug::TraceLog::Options trace_options_; |
| 97 base::debug::CategoryFilter category_filter_; |
| 108 | 98 |
| 109 DISALLOW_COPY_AND_ASSIGN(TraceControllerImpl); | 99 DISALLOW_COPY_AND_ASSIGN(TraceControllerImpl); |
| 110 }; | 100 }; |
| 111 | 101 |
| 112 } // namespace content | 102 } // namespace content |
| 113 | 103 |
| 114 #endif // CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_H_ | 104 #endif // CONTENT_BROWSER_TRACING_TRACE_CONTROLLER_IMPL_H_ |
| OLD | NEW |