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

Side by Side Diff: content/browser/tracing/background_tracing_manager_impl.cc

Issue 1148633007: Hooked the trace event argument whitelist up to the background_trace_manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved tracing enabled callback to its own testing function Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/tracing/background_tracing_manager_impl.h" 5 #include "content/browser/tracing/background_tracing_manager_impl.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "content/public/browser/background_tracing_preemptive_config.h" 8 #include "content/public/browser/background_tracing_preemptive_config.h"
9 #include "content/public/browser/background_tracing_reactive_config.h" 9 #include "content/public/browser/background_tracing_reactive_config.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 BackgroundTracingPreemptiveConfig::MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED) 86 BackgroundTracingPreemptiveConfig::MONITOR_AND_DUMP_WHEN_TRIGGER_NAMED)
87 return false; 87 return false;
88 } 88 }
89 89
90 return true; 90 return true;
91 } 91 }
92 92
93 bool BackgroundTracingManagerImpl::SetActiveScenario( 93 bool BackgroundTracingManagerImpl::SetActiveScenario(
94 scoped_ptr<BackgroundTracingConfig> config, 94 scoped_ptr<BackgroundTracingConfig> config,
95 const BackgroundTracingManager::ReceiveCallback& receive_callback, 95 const BackgroundTracingManager::ReceiveCallback& receive_callback,
96 bool requires_anonymized_data) { 96 DataFiltering data_filtering) {
97 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 97 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
98 if (is_tracing_) 98 if (is_tracing_)
99 return false; 99 return false;
100 100
101 if (!IsSupportedConfig(config.get())) 101 if (!IsSupportedConfig(config.get()))
102 return false; 102 return false;
103 103
104 // No point in tracing if there's nowhere to send it. 104 // No point in tracing if there's nowhere to send it.
105 if (config && receive_callback.is_null()) 105 if (config && receive_callback.is_null())
106 return false; 106 return false;
107 107
108 config_ = config.Pass(); 108 config_ = config.Pass();
109 receive_callback_ = receive_callback; 109 receive_callback_ = receive_callback;
110 requires_anonymized_data_ = requires_anonymized_data; 110 requires_anonymized_data_ = (data_filtering == ANONYMIZE_DATA);
111 111
112 EnableRecordingIfConfigNeedsIt(); 112 EnableRecordingIfConfigNeedsIt();
113 113
114 return true; 114 return true;
115 } 115 }
116 116
117 void BackgroundTracingManagerImpl::EnableRecordingIfConfigNeedsIt() { 117 void BackgroundTracingManagerImpl::EnableRecordingIfConfigNeedsIt() {
118 if (!config_) 118 if (!config_)
119 return; 119 return;
120 120
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 for (std::map<TriggerHandle, std::string>::iterator it = 220 for (std::map<TriggerHandle, std::string>::iterator it =
221 trigger_handles_.begin(); 221 trigger_handles_.begin();
222 it != trigger_handles_.end(); ++it) 222 it != trigger_handles_.end(); ++it)
223 trigger_names->push_back(it->second); 223 trigger_names->push_back(it->second);
224 } 224 }
225 225
226 void BackgroundTracingManagerImpl::InvalidateTriggerHandlesForTesting() { 226 void BackgroundTracingManagerImpl::InvalidateTriggerHandlesForTesting() {
227 trigger_handles_.clear(); 227 trigger_handles_.clear();
228 } 228 }
229 229
230 void BackgroundTracingManagerImpl::SetTracingEnabledCallbackForTesting(
231 const base::Closure& callback) {
232 tracing_enabled_callback_for_testing_ = callback;
233 };
234
230 void BackgroundTracingManagerImpl::EnableRecording( 235 void BackgroundTracingManagerImpl::EnableRecording(
231 base::trace_event::CategoryFilter category_filter) { 236 base::trace_event::CategoryFilter category_filter) {
237 base::trace_event::TraceOptions trace_options(
238 base::trace_event::RECORD_CONTINUOUSLY);
239 trace_options.enable_argument_filter = requires_anonymized_data_;
232 is_tracing_ = TracingController::GetInstance()->EnableRecording( 240 is_tracing_ = TracingController::GetInstance()->EnableRecording(
233 category_filter, 241 category_filter, trace_options, tracing_enabled_callback_for_testing_);
234 base::trace_event::TraceOptions(base::trace_event::RECORD_CONTINUOUSLY),
235 TracingController::EnableRecordingDoneCallback());
236 } 242 }
237 243
238 void BackgroundTracingManagerImpl::OnFinalizeStarted( 244 void BackgroundTracingManagerImpl::OnFinalizeStarted(
239 scoped_refptr<base::RefCountedString> file_contents) { 245 scoped_refptr<base::RefCountedString> file_contents) {
240 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 246 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
241 247
242 if (!receive_callback_.is_null()) 248 if (!receive_callback_.is_null())
243 receive_callback_.Run( 249 receive_callback_.Run(
244 file_contents.get(), 250 file_contents,
245 base::Bind(&BackgroundTracingManagerImpl::OnFinalizeComplete, 251 base::Bind(&BackgroundTracingManagerImpl::OnFinalizeComplete,
246 base::Unretained(this))); 252 base::Unretained(this)));
247 } 253 }
248 254
249 void BackgroundTracingManagerImpl::OnFinalizeComplete() { 255 void BackgroundTracingManagerImpl::OnFinalizeComplete() {
250 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 256 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
251 BrowserThread::PostTask( 257 BrowserThread::PostTask(
252 BrowserThread::UI, FROM_HERE, 258 BrowserThread::UI, FROM_HERE,
253 base::Bind(&BackgroundTracingManagerImpl::OnFinalizeComplete, 259 base::Bind(&BackgroundTracingManagerImpl::OnFinalizeComplete,
254 base::Unretained(this))); 260 base::Unretained(this)));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 return NULL; 309 return NULL;
304 } 310 }
305 311
306 void BackgroundTracingConfig::IntoDict(const BackgroundTracingConfig* config, 312 void BackgroundTracingConfig::IntoDict(const BackgroundTracingConfig* config,
307 base::DictionaryValue* dict) { 313 base::DictionaryValue* dict) {
308 // TODO(simonhatch): Implement this. 314 // TODO(simonhatch): Implement this.
309 CHECK(false); 315 CHECK(false);
310 } 316 }
311 317
312 } // namspace content 318 } // namspace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698