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

Side by Side Diff: chrome/test/base/tracing.cc

Issue 2047533002: [tracing] Add browser test for background memory tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@set_whitelist
Patch Set: Remove useless watch event. Created 4 years, 6 months 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
« no previous file with comments | « chrome/test/base/tracing.h ('k') | chrome/test/base/tracing_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 public: 48 public:
49 static InProcessTraceController* GetInstance() { 49 static InProcessTraceController* GetInstance() {
50 return base::Singleton<InProcessTraceController>::get(); 50 return base::Singleton<InProcessTraceController>::get();
51 } 51 }
52 52
53 InProcessTraceController() 53 InProcessTraceController()
54 : is_waiting_on_watch_(false), 54 : is_waiting_on_watch_(false),
55 watch_notification_count_(0) {} 55 watch_notification_count_(0) {}
56 virtual ~InProcessTraceController() {} 56 virtual ~InProcessTraceController() {}
57 57
58 bool BeginTracing(const std::string& category_patterns) { 58 bool BeginTracing(const base::trace_event::TraceConfig& trace_config) {
59 DCHECK_CURRENTLY_ON(BrowserThread::UI); 59 DCHECK_CURRENTLY_ON(BrowserThread::UI);
60 return content::TracingController::GetInstance()->StartTracing( 60 return content::TracingController::GetInstance()->StartTracing(
61 base::trace_event::TraceConfig(category_patterns, ""), 61 trace_config, content::TracingController::StartTracingDoneCallback());
62 content::TracingController::StartTracingDoneCallback());
63 } 62 }
64 63
65 bool BeginTracingWithWatch(const std::string& category_patterns, 64 bool BeginTracingWithWatch(const std::string& category_patterns,
66 const std::string& category_name, 65 const std::string& category_name,
67 const std::string& event_name, 66 const std::string& event_name,
68 int num_occurrences) { 67 int num_occurrences) {
69 DCHECK_CURRENTLY_ON(BrowserThread::UI); 68 DCHECK_CURRENTLY_ON(BrowserThread::UI);
70 DCHECK(num_occurrences > 0); 69 DCHECK(num_occurrences > 0);
71 watch_notification_count_ = num_occurrences; 70 watch_notification_count_ = num_occurrences;
72 if (!content::TracingController::GetInstance()->SetWatchEvent( 71 if (!content::TracingController::GetInstance()->SetWatchEvent(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 158
160 DISALLOW_COPY_AND_ASSIGN(InProcessTraceController); 159 DISALLOW_COPY_AND_ASSIGN(InProcessTraceController);
161 }; 160 };
162 161
163 } // namespace 162 } // namespace
164 163
165 namespace tracing { 164 namespace tracing {
166 165
167 bool BeginTracing(const std::string& category_patterns) { 166 bool BeginTracing(const std::string& category_patterns) {
168 return InProcessTraceController::GetInstance()->BeginTracing( 167 return InProcessTraceController::GetInstance()->BeginTracing(
169 category_patterns); 168 base::trace_event::TraceConfig(category_patterns, ""));
170 } 169 }
171 170
172 bool BeginTracingWithWatch(const std::string& category_patterns, 171 bool BeginTracingWithWatch(const std::string& category_patterns,
173 const std::string& category_name, 172 const std::string& category_name,
174 const std::string& event_name, 173 const std::string& event_name,
175 int num_occurrences) { 174 int num_occurrences) {
176 return InProcessTraceController::GetInstance()->BeginTracingWithWatch( 175 return InProcessTraceController::GetInstance()->BeginTracingWithWatch(
177 category_patterns, category_name, event_name, num_occurrences); 176 category_patterns, category_name, event_name, num_occurrences);
178 } 177 }
179 178
179 bool BeginTracingWithTraceConfig(
180 const base::trace_event::TraceConfig& trace_config) {
181 return InProcessTraceController::GetInstance()->BeginTracing(trace_config);
182 }
183
180 bool WaitForWatchEvent(base::TimeDelta timeout) { 184 bool WaitForWatchEvent(base::TimeDelta timeout) {
181 return InProcessTraceController::GetInstance()->WaitForWatchEvent(timeout); 185 return InProcessTraceController::GetInstance()->WaitForWatchEvent(timeout);
182 } 186 }
183 187
184 bool EndTracing(std::string* json_trace_output) { 188 bool EndTracing(std::string* json_trace_output) {
185 return InProcessTraceController::GetInstance()->EndTracing(json_trace_output); 189 return InProcessTraceController::GetInstance()->EndTracing(json_trace_output);
186 } 190 }
187 191
188 } // namespace tracing 192 } // namespace tracing
189 193
OLDNEW
« no previous file with comments | « chrome/test/base/tracing.h ('k') | chrome/test/base/tracing_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698