Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: content/browser/tracing/tracing_controller_impl.h

Issue 66893003: Allow TracingController to output trace data to specified file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed unnecessary include Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_
6 #define CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 6 #define CONTENT_BROWSER_TRACING_TRACING_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/files/file_path.h"
12 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
13 #include "content/public/browser/trace_subscriber.h" 14 #include "content/public/browser/trace_subscriber.h"
14 #include "content/public/browser/tracing_controller.h" 15 #include "content/public/browser/tracing_controller.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 class TraceMessageFilter; 19 class TraceMessageFilter;
19 20
20 class TracingControllerImpl : 21 class TracingControllerImpl : public TracingController {
21 public TracingController, public TraceSubscriber {
22 public: 22 public:
23 static TracingControllerImpl* GetInstance(); 23 static TracingControllerImpl* GetInstance();
24 24
25 // TracingController implementation. 25 // TracingController implementation.
26 virtual void GetCategories( 26 virtual void GetCategories(
27 const GetCategoriesDoneCallback& callback) OVERRIDE; 27 const GetCategoriesDoneCallback& callback) OVERRIDE;
28 virtual bool EnableRecording( 28 virtual bool EnableRecording(
29 const base::debug::CategoryFilter& filter, 29 const base::debug::CategoryFilter& filter,
30 TracingController::Options options, 30 TracingController::Options options,
31 const EnableRecordingDoneCallback& callback) OVERRIDE; 31 const EnableRecordingDoneCallback& callback) OVERRIDE;
32 virtual bool DisableRecording( 32 virtual bool DisableRecording(
33 const base::FilePath& result_file_path,
33 const TracingFileResultCallback& callback) OVERRIDE; 34 const TracingFileResultCallback& callback) OVERRIDE;
34 virtual bool EnableMonitoring(const base::debug::CategoryFilter& filter, 35 virtual bool EnableMonitoring(const base::debug::CategoryFilter& filter,
35 TracingController::Options options, 36 TracingController::Options options,
36 const EnableMonitoringDoneCallback& callback) OVERRIDE; 37 const EnableMonitoringDoneCallback& callback) OVERRIDE;
37 virtual bool DisableMonitoring( 38 virtual bool DisableMonitoring(
38 const DisableMonitoringDoneCallback& callback) OVERRIDE; 39 const DisableMonitoringDoneCallback& callback) OVERRIDE;
39 virtual void GetMonitoringStatus( 40 virtual void GetMonitoringStatus(
40 bool* out_enabled, 41 bool* out_enabled,
41 base::debug::CategoryFilter* out_filter, 42 base::debug::CategoryFilter* out_filter,
42 TracingController::Options* out_options) OVERRIDE; 43 TracingController::Options* out_options) OVERRIDE;
43 virtual void CaptureMonitoringSnapshot( 44 virtual void CaptureMonitoringSnapshot(
45 const base::FilePath& result_file_path,
44 const TracingFileResultCallback& callback) OVERRIDE; 46 const TracingFileResultCallback& callback) OVERRIDE;
45 47
46 private: 48 private:
47 typedef std::set<scoped_refptr<TraceMessageFilter> > FilterMap; 49 typedef std::set<scoped_refptr<TraceMessageFilter> > FilterMap;
50 class ResultFile;
48 51
49 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>; 52 friend struct base::DefaultLazyInstanceTraits<TracingControllerImpl>;
50 friend class TraceMessageFilter; 53 friend class TraceMessageFilter;
51 54
52 TracingControllerImpl(); 55 TracingControllerImpl();
53 virtual ~TracingControllerImpl(); 56 virtual ~TracingControllerImpl();
54 57
55 // TraceSubscriber implementation.
56 virtual void OnTraceDataCollected(
57 const scoped_refptr<base::RefCountedString>& events_str_ptr) OVERRIDE;
58
59 bool can_enable_recording() const { 58 bool can_enable_recording() const {
60 return !is_recording_; 59 return !is_recording_;
61 } 60 }
62 61
63 bool can_disable_recording() const { 62 bool can_disable_recording() const {
64 return is_recording_ && pending_disable_recording_ack_count_ == 0; 63 return is_recording_ && !result_file_;
65 } 64 }
66 65
67 bool can_enable_monitoring() const { 66 bool can_enable_monitoring() const {
68 return !is_monitoring_; 67 return !is_monitoring_;
69 } 68 }
70 69
71 bool can_disable_monitoring() const { 70 bool can_disable_monitoring() const {
72 return is_monitoring_ && 71 return is_monitoring_ && !monitoring_snapshot_file_;
73 pending_capture_monitoring_snapshot_ack_count_ == 0;
74 } 72 }
75 73
76 // Methods for use by TraceMessageFilter. 74 // Methods for use by TraceMessageFilter.
77 void AddFilter(TraceMessageFilter* filter); 75 void AddFilter(TraceMessageFilter* filter);
78 void RemoveFilter(TraceMessageFilter* filter); 76 void RemoveFilter(TraceMessageFilter* filter);
79 77
78 void OnTraceDataCollected(
79 const scoped_refptr<base::RefCountedString>& events_str_ptr);
80 void OnMonitoringTraceDataCollected(
81 const scoped_refptr<base::RefCountedString>& events_str_ptr);
82
80 // Callback of TraceLog::Flush() for the local trace. 83 // Callback of TraceLog::Flush() for the local trace.
81 void OnLocalTraceDataCollected( 84 void OnLocalTraceDataCollected(
82 const scoped_refptr<base::RefCountedString>& events_str_ptr, 85 const scoped_refptr<base::RefCountedString>& events_str_ptr,
83 bool has_more_events); 86 bool has_more_events);
84 // Callback of TraceLog::FlushMonitoring() for the local trace. 87 // Callback of TraceLog::FlushMonitoring() for the local trace.
85 void OnLocalMonitoringTraceDataCollected( 88 void OnLocalMonitoringTraceDataCollected(
86 const scoped_refptr<base::RefCountedString>& events_str_ptr, 89 const scoped_refptr<base::RefCountedString>& events_str_ptr,
87 bool has_more_events); 90 bool has_more_events);
88 91
89 void OnDisableRecordingAcked( 92 void OnDisableRecordingAcked(
90 const std::vector<std::string>& known_category_groups); 93 const std::vector<std::string>& known_category_groups);
94 void OnResultFileClosed();
95
91 void OnCaptureMonitoringSnapshotAcked(); 96 void OnCaptureMonitoringSnapshotAcked();
97 void OnMonitoringSnapshotFileClosed();
92 98
93 FilterMap filters_; 99 FilterMap filters_;
94 // Pending acks for DisableRecording. 100 // Pending acks for DisableRecording.
95 int pending_disable_recording_ack_count_; 101 int pending_disable_recording_ack_count_;
96 // Pending acks for CaptureMonitoringSnapshot. 102 // Pending acks for CaptureMonitoringSnapshot.
97 int pending_capture_monitoring_snapshot_ack_count_; 103 int pending_capture_monitoring_snapshot_ack_count_;
98 bool is_recording_; 104 bool is_recording_;
99 bool is_monitoring_; 105 bool is_monitoring_;
100 GetCategoriesDoneCallback pending_get_categories_done_callback_; 106 GetCategoriesDoneCallback pending_get_categories_done_callback_;
101 TracingFileResultCallback pending_disable_recording_done_callback_; 107 TracingFileResultCallback pending_disable_recording_done_callback_;
102 TracingFileResultCallback pending_capture_monitoring_snapshot_done_callback_; 108 TracingFileResultCallback pending_capture_monitoring_snapshot_done_callback_;
103 std::set<std::string> known_category_groups_; 109 std::set<std::string> known_category_groups_;
104 base::debug::TraceLog::Options trace_options_; 110 base::debug::TraceLog::Options trace_options_;
105 base::debug::CategoryFilter category_filter_; 111 base::debug::CategoryFilter category_filter_;
106 FILE* result_file_; 112 scoped_ptr<ResultFile> result_file_;
107 scoped_ptr<base::FilePath> result_file_path_; 113 scoped_ptr<ResultFile> monitoring_snapshot_file_;
108 bool result_file_has_at_least_one_result_;
109
110 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl); 114 DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl);
111 }; 115 };
112 116
113 } // namespace content 117 } // namespace content
114 118
115 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_ 119 #endif // CONTENT_BROWSER_TRACING_TRACING_CONTROLLER_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/tracing/tracing_controller_browsertest.cc ('k') | content/browser/tracing/tracing_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698