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 #include "chrome/test/base/tracing.h" | 5 #include "chrome/test/base/tracing.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 std::string* result_; | 40 std::string* result_; |
41 base::Closure completion_callback_; | 41 base::Closure completion_callback_; |
42 | 42 |
43 DISALLOW_COPY_AND_ASSIGN(StringTraceSink); | 43 DISALLOW_COPY_AND_ASSIGN(StringTraceSink); |
44 }; | 44 }; |
45 | 45 |
46 class InProcessTraceController { | 46 class InProcessTraceController { |
47 public: | 47 public: |
48 static InProcessTraceController* GetInstance() { | 48 static InProcessTraceController* GetInstance() { |
49 return Singleton<InProcessTraceController>::get(); | 49 return base::Singleton<InProcessTraceController>::get(); |
50 } | 50 } |
51 | 51 |
52 InProcessTraceController() | 52 InProcessTraceController() |
53 : is_waiting_on_watch_(false), | 53 : is_waiting_on_watch_(false), |
54 watch_notification_count_(0) {} | 54 watch_notification_count_(0) {} |
55 virtual ~InProcessTraceController() {} | 55 virtual ~InProcessTraceController() {} |
56 | 56 |
57 bool BeginTracing(const std::string& category_patterns) { | 57 bool BeginTracing(const std::string& category_patterns) { |
58 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 58 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
59 return content::TracingController::GetInstance()->EnableRecording( | 59 return content::TracingController::GetInstance()->EnableRecording( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 message_loop_runner_ = new content::MessageLoopRunner; | 119 message_loop_runner_ = new content::MessageLoopRunner; |
120 message_loop_runner_->Run(); | 120 message_loop_runner_->Run(); |
121 | 121 |
122 // Watch notifications can occur during this method's message loop run, but | 122 // Watch notifications can occur during this method's message loop run, but |
123 // not after, so clear them here. | 123 // not after, so clear them here. |
124 watch_notification_count_ = 0; | 124 watch_notification_count_ = 0; |
125 return true; | 125 return true; |
126 } | 126 } |
127 | 127 |
128 private: | 128 private: |
129 friend struct DefaultSingletonTraits<InProcessTraceController>; | 129 friend struct base::DefaultSingletonTraits<InProcessTraceController>; |
130 | 130 |
131 void OnEnableTracingComplete() { | 131 void OnEnableTracingComplete() { |
132 message_loop_runner_->Quit(); | 132 message_loop_runner_->Quit(); |
133 } | 133 } |
134 | 134 |
135 void OnTracingComplete() { message_loop_runner_->Quit(); } | 135 void OnTracingComplete() { message_loop_runner_->Quit(); } |
136 | 136 |
137 void OnWatchEventMatched() { | 137 void OnWatchEventMatched() { |
138 if (watch_notification_count_ == 0) | 138 if (watch_notification_count_ == 0) |
139 return; | 139 return; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 bool WaitForWatchEvent(base::TimeDelta timeout) { | 179 bool WaitForWatchEvent(base::TimeDelta timeout) { |
180 return InProcessTraceController::GetInstance()->WaitForWatchEvent(timeout); | 180 return InProcessTraceController::GetInstance()->WaitForWatchEvent(timeout); |
181 } | 181 } |
182 | 182 |
183 bool EndTracing(std::string* json_trace_output) { | 183 bool EndTracing(std::string* json_trace_output) { |
184 return InProcessTraceController::GetInstance()->EndTracing(json_trace_output); | 184 return InProcessTraceController::GetInstance()->EndTracing(json_trace_output); |
185 } | 185 } |
186 | 186 |
187 } // namespace tracing | 187 } // namespace tracing |
188 | 188 |
OLD | NEW |