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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/tracing_controller.h" | 15 #include "content/public/browser/tracing_controller.h" |
16 #include "content/public/test/test_utils.h" | 16 #include "content/public/test/test_utils.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 using content::BrowserThread; | 20 using content::BrowserThread; |
21 | 21 |
22 class StringTraceSink : public content::TracingController::TraceDataSink { | 22 class StringTraceSink : public content::TracingController::TraceDataSink { |
23 public: | 23 public: |
24 StringTraceSink(std::string* result, const base::Closure& callback) | 24 StringTraceSink(std::string* result, const base::Closure& callback) |
25 : result_(result), completion_callback_(callback) {} | 25 : result_(result), completion_callback_(callback) {} |
26 | 26 |
27 virtual void AddTraceChunk(const std::string& chunk) OVERRIDE { | 27 virtual void AddTraceChunk(const std::string& chunk) override { |
28 *result_ += result_->empty() ? "[" : ","; | 28 *result_ += result_->empty() ? "[" : ","; |
29 *result_ += chunk; | 29 *result_ += chunk; |
30 } | 30 } |
31 virtual void Close() OVERRIDE { | 31 virtual void Close() override { |
32 if (!result_->empty()) | 32 if (!result_->empty()) |
33 *result_ += "]"; | 33 *result_ += "]"; |
34 completion_callback_.Run(); | 34 completion_callback_.Run(); |
35 } | 35 } |
36 | 36 |
37 private: | 37 private: |
38 virtual ~StringTraceSink() {} | 38 virtual ~StringTraceSink() {} |
39 | 39 |
40 std::string* result_; | 40 std::string* result_; |
41 base::Closure completion_callback_; | 41 base::Closure completion_callback_; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 bool WaitForWatchEvent(base::TimeDelta timeout) { | 181 bool WaitForWatchEvent(base::TimeDelta timeout) { |
182 return InProcessTraceController::GetInstance()->WaitForWatchEvent(timeout); | 182 return InProcessTraceController::GetInstance()->WaitForWatchEvent(timeout); |
183 } | 183 } |
184 | 184 |
185 bool EndTracing(std::string* json_trace_output) { | 185 bool EndTracing(std::string* json_trace_output) { |
186 return InProcessTraceController::GetInstance()->EndTracing(json_trace_output); | 186 return InProcessTraceController::GetInstance()->EndTracing(json_trace_output); |
187 } | 187 } |
188 | 188 |
189 } // namespace tracing | 189 } // namespace tracing |
190 | 190 |
OLD | NEW |