| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/browser/tracing/tracing_controller_impl.h" | 4 #include "content/browser/tracing/tracing_controller_impl.h" |
| 5 | 5 |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/json/string_escape.h" | 8 #include "base/json/string_escape.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // This is a Leaky instance. | 181 // This is a Leaky instance. |
| 182 NOTREACHED(); | 182 NOTREACHED(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 TracingControllerImpl* TracingControllerImpl::GetInstance() { | 185 TracingControllerImpl* TracingControllerImpl::GetInstance() { |
| 186 return g_controller.Pointer(); | 186 return g_controller.Pointer(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 bool TracingControllerImpl::GetCategories( | 189 bool TracingControllerImpl::GetCategories( |
| 190 const GetCategoriesDoneCallback& callback) { | 190 const GetCategoriesDoneCallback& callback) { |
| 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 191 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 192 | 192 |
| 193 // Known categories come back from child processes with the EndTracingAck | 193 // Known categories come back from child processes with the EndTracingAck |
| 194 // message. So to get known categories, just begin and end tracing immediately | 194 // message. So to get known categories, just begin and end tracing immediately |
| 195 // afterwards. This will ping all the child processes for categories. | 195 // afterwards. This will ping all the child processes for categories. |
| 196 pending_get_categories_done_callback_ = callback; | 196 pending_get_categories_done_callback_ = callback; |
| 197 if (!EnableRecording( | 197 if (!EnableRecording( |
| 198 CategoryFilter("*"), TraceOptions(), EnableRecordingDoneCallback())) { | 198 CategoryFilter("*"), TraceOptions(), EnableRecordingDoneCallback())) { |
| 199 pending_get_categories_done_callback_.Reset(); | 199 pending_get_categories_done_callback_.Reset(); |
| 200 return false; | 200 return false; |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool ok = DisableRecording(NULL); | 203 bool ok = DisableRecording(NULL); |
| 204 DCHECK(ok); | 204 DCHECK(ok); |
| 205 return true; | 205 return true; |
| 206 } | 206 } |
| 207 | 207 |
| 208 void TracingControllerImpl::SetEnabledOnFileThread( | 208 void TracingControllerImpl::SetEnabledOnFileThread( |
| 209 const CategoryFilter& category_filter, | 209 const CategoryFilter& category_filter, |
| 210 int mode, | 210 int mode, |
| 211 const TraceOptions& trace_options, | 211 const TraceOptions& trace_options, |
| 212 const base::Closure& callback) { | 212 const base::Closure& callback) { |
| 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 213 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 214 | 214 |
| 215 TraceLog::GetInstance()->SetEnabled( | 215 TraceLog::GetInstance()->SetEnabled( |
| 216 category_filter, static_cast<TraceLog::Mode>(mode), trace_options); | 216 category_filter, static_cast<TraceLog::Mode>(mode), trace_options); |
| 217 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 217 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void TracingControllerImpl::SetDisabledOnFileThread( | 220 void TracingControllerImpl::SetDisabledOnFileThread( |
| 221 const base::Closure& callback) { | 221 const base::Closure& callback) { |
| 222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 222 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 223 | 223 |
| 224 TraceLog::GetInstance()->SetDisabled(); | 224 TraceLog::GetInstance()->SetDisabled(); |
| 225 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 225 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
| 226 } | 226 } |
| 227 | 227 |
| 228 bool TracingControllerImpl::EnableRecording( | 228 bool TracingControllerImpl::EnableRecording( |
| 229 const CategoryFilter& category_filter, | 229 const CategoryFilter& category_filter, |
| 230 const TraceOptions& trace_options, | 230 const TraceOptions& trace_options, |
| 231 const EnableRecordingDoneCallback& callback) { | 231 const EnableRecordingDoneCallback& callback) { |
| 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 232 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 233 | 233 |
| 234 if (!can_enable_recording()) | 234 if (!can_enable_recording()) |
| 235 return false; | 235 return false; |
| 236 is_recording_ = true; | 236 is_recording_ = true; |
| 237 | 237 |
| 238 #if defined(OS_ANDROID) | 238 #if defined(OS_ANDROID) |
| 239 if (pending_get_categories_done_callback_.is_null()) | 239 if (pending_get_categories_done_callback_.is_null()) |
| 240 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); | 240 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); |
| 241 #endif | 241 #endif |
| 242 | 242 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 267 base::trace_event::TraceLog::RECORDING_MODE, | 267 base::trace_event::TraceLog::RECORDING_MODE, |
| 268 trace_options, | 268 trace_options, |
| 269 on_enable_recording_done_callback)); | 269 on_enable_recording_done_callback)); |
| 270 return true; | 270 return true; |
| 271 } | 271 } |
| 272 | 272 |
| 273 void TracingControllerImpl::OnEnableRecordingDone( | 273 void TracingControllerImpl::OnEnableRecordingDone( |
| 274 const CategoryFilter& category_filter, | 274 const CategoryFilter& category_filter, |
| 275 const TraceOptions& trace_options, | 275 const TraceOptions& trace_options, |
| 276 const EnableRecordingDoneCallback& callback) { | 276 const EnableRecordingDoneCallback& callback) { |
| 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 277 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 278 | 278 |
| 279 // Notify all child processes. | 279 // Notify all child processes. |
| 280 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); | 280 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); |
| 281 it != trace_message_filters_.end(); ++it) { | 281 it != trace_message_filters_.end(); ++it) { |
| 282 it->get()->SendBeginTracing(category_filter, trace_options); | 282 it->get()->SendBeginTracing(category_filter, trace_options); |
| 283 } | 283 } |
| 284 | 284 |
| 285 if (!callback.is_null()) | 285 if (!callback.is_null()) |
| 286 callback.Run(); | 286 callback.Run(); |
| 287 } | 287 } |
| 288 | 288 |
| 289 bool TracingControllerImpl::DisableRecording( | 289 bool TracingControllerImpl::DisableRecording( |
| 290 const scoped_refptr<TraceDataSink>& trace_data_sink) { | 290 const scoped_refptr<TraceDataSink>& trace_data_sink) { |
| 291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 291 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 292 | 292 |
| 293 if (!can_disable_recording()) | 293 if (!can_disable_recording()) |
| 294 return false; | 294 return false; |
| 295 | 295 |
| 296 trace_data_sink_ = trace_data_sink; | 296 trace_data_sink_ = trace_data_sink; |
| 297 trace_options_ = TraceOptions(); | 297 trace_options_ = TraceOptions(); |
| 298 // Disable local trace early to avoid traces during end-tracing process from | 298 // Disable local trace early to avoid traces during end-tracing process from |
| 299 // interfering with the process. | 299 // interfering with the process. |
| 300 base::Closure on_disable_recording_done_callback = base::Bind( | 300 base::Closure on_disable_recording_done_callback = base::Bind( |
| 301 &TracingControllerImpl::OnDisableRecordingDone, base::Unretained(this)); | 301 &TracingControllerImpl::OnDisableRecordingDone, base::Unretained(this)); |
| 302 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 302 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 303 base::Bind(&TracingControllerImpl::SetDisabledOnFileThread, | 303 base::Bind(&TracingControllerImpl::SetDisabledOnFileThread, |
| 304 base::Unretained(this), | 304 base::Unretained(this), |
| 305 on_disable_recording_done_callback)); | 305 on_disable_recording_done_callback)); |
| 306 return true; | 306 return true; |
| 307 } | 307 } |
| 308 | 308 |
| 309 void TracingControllerImpl::OnDisableRecordingDone() { | 309 void TracingControllerImpl::OnDisableRecordingDone() { |
| 310 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 310 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 311 | 311 |
| 312 #if defined(OS_ANDROID) | 312 #if defined(OS_ANDROID) |
| 313 if (pending_get_categories_done_callback_.is_null()) | 313 if (pending_get_categories_done_callback_.is_null()) |
| 314 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); | 314 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); |
| 315 #endif | 315 #endif |
| 316 | 316 |
| 317 // Count myself (local trace) in pending_disable_recording_ack_count_, | 317 // Count myself (local trace) in pending_disable_recording_ack_count_, |
| 318 // acked below. | 318 // acked below. |
| 319 pending_disable_recording_ack_count_ = trace_message_filters_.size() + 1; | 319 pending_disable_recording_ack_count_ = trace_message_filters_.size() + 1; |
| 320 pending_disable_recording_filters_ = trace_message_filters_; | 320 pending_disable_recording_filters_ = trace_message_filters_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); | 356 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); |
| 357 it != trace_message_filters_.end(); ++it) { | 357 it != trace_message_filters_.end(); ++it) { |
| 358 it->get()->SendEndTracing(); | 358 it->get()->SendEndTracing(); |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 bool TracingControllerImpl::EnableMonitoring( | 362 bool TracingControllerImpl::EnableMonitoring( |
| 363 const CategoryFilter& category_filter, | 363 const CategoryFilter& category_filter, |
| 364 const TraceOptions& trace_options, | 364 const TraceOptions& trace_options, |
| 365 const EnableMonitoringDoneCallback& callback) { | 365 const EnableMonitoringDoneCallback& callback) { |
| 366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 366 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 367 | 367 |
| 368 if (!can_enable_monitoring()) | 368 if (!can_enable_monitoring()) |
| 369 return false; | 369 return false; |
| 370 OnMonitoringStateChanged(true); | 370 OnMonitoringStateChanged(true); |
| 371 | 371 |
| 372 #if defined(OS_ANDROID) | 372 #if defined(OS_ANDROID) |
| 373 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); | 373 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); |
| 374 #endif | 374 #endif |
| 375 | 375 |
| 376 trace_options_ = trace_options; | 376 trace_options_ = trace_options; |
| 377 | 377 |
| 378 base::Closure on_enable_monitoring_done_callback = | 378 base::Closure on_enable_monitoring_done_callback = |
| 379 base::Bind(&TracingControllerImpl::OnEnableMonitoringDone, | 379 base::Bind(&TracingControllerImpl::OnEnableMonitoringDone, |
| 380 base::Unretained(this), | 380 base::Unretained(this), |
| 381 category_filter, trace_options, callback); | 381 category_filter, trace_options, callback); |
| 382 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 382 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 383 base::Bind(&TracingControllerImpl::SetEnabledOnFileThread, | 383 base::Bind(&TracingControllerImpl::SetEnabledOnFileThread, |
| 384 base::Unretained(this), | 384 base::Unretained(this), |
| 385 category_filter, | 385 category_filter, |
| 386 base::trace_event::TraceLog::MONITORING_MODE, | 386 base::trace_event::TraceLog::MONITORING_MODE, |
| 387 trace_options, | 387 trace_options, |
| 388 on_enable_monitoring_done_callback)); | 388 on_enable_monitoring_done_callback)); |
| 389 return true; | 389 return true; |
| 390 } | 390 } |
| 391 | 391 |
| 392 void TracingControllerImpl::OnEnableMonitoringDone( | 392 void TracingControllerImpl::OnEnableMonitoringDone( |
| 393 const CategoryFilter& category_filter, | 393 const CategoryFilter& category_filter, |
| 394 const TraceOptions& trace_options, | 394 const TraceOptions& trace_options, |
| 395 const EnableMonitoringDoneCallback& callback) { | 395 const EnableMonitoringDoneCallback& callback) { |
| 396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 396 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 397 | 397 |
| 398 // Notify all child processes. | 398 // Notify all child processes. |
| 399 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); | 399 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); |
| 400 it != trace_message_filters_.end(); ++it) { | 400 it != trace_message_filters_.end(); ++it) { |
| 401 it->get()->SendEnableMonitoring(category_filter, trace_options); | 401 it->get()->SendEnableMonitoring(category_filter, trace_options); |
| 402 } | 402 } |
| 403 | 403 |
| 404 if (!callback.is_null()) | 404 if (!callback.is_null()) |
| 405 callback.Run(); | 405 callback.Run(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 bool TracingControllerImpl::DisableMonitoring( | 408 bool TracingControllerImpl::DisableMonitoring( |
| 409 const DisableMonitoringDoneCallback& callback) { | 409 const DisableMonitoringDoneCallback& callback) { |
| 410 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 410 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 411 | 411 |
| 412 if (!can_disable_monitoring()) | 412 if (!can_disable_monitoring()) |
| 413 return false; | 413 return false; |
| 414 | 414 |
| 415 trace_options_ = TraceOptions(); | 415 trace_options_ = TraceOptions(); |
| 416 base::Closure on_disable_monitoring_done_callback = | 416 base::Closure on_disable_monitoring_done_callback = |
| 417 base::Bind(&TracingControllerImpl::OnDisableMonitoringDone, | 417 base::Bind(&TracingControllerImpl::OnDisableMonitoringDone, |
| 418 base::Unretained(this), callback); | 418 base::Unretained(this), callback); |
| 419 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 419 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 420 base::Bind(&TracingControllerImpl::SetDisabledOnFileThread, | 420 base::Bind(&TracingControllerImpl::SetDisabledOnFileThread, |
| 421 base::Unretained(this), | 421 base::Unretained(this), |
| 422 on_disable_monitoring_done_callback)); | 422 on_disable_monitoring_done_callback)); |
| 423 return true; | 423 return true; |
| 424 } | 424 } |
| 425 | 425 |
| 426 scoped_refptr<TracingController::TraceDataSink> | 426 scoped_refptr<TracingController::TraceDataSink> |
| 427 TracingController::CreateStringSink( | 427 TracingController::CreateStringSink( |
| 428 const base::Callback<void(base::RefCountedString*)>& callback) { | 428 const base::Callback<void(base::RefCountedString*)>& callback) { |
| 429 return new StringTraceDataSink(callback); | 429 return new StringTraceDataSink(callback); |
| 430 } | 430 } |
| 431 | 431 |
| 432 scoped_refptr<TracingController::TraceDataSink> | 432 scoped_refptr<TracingController::TraceDataSink> |
| 433 TracingController::CreateFileSink(const base::FilePath& file_path, | 433 TracingController::CreateFileSink(const base::FilePath& file_path, |
| 434 const base::Closure& callback) { | 434 const base::Closure& callback) { |
| 435 return new FileTraceDataSink(file_path, callback); | 435 return new FileTraceDataSink(file_path, callback); |
| 436 } | 436 } |
| 437 | 437 |
| 438 void TracingControllerImpl::OnDisableMonitoringDone( | 438 void TracingControllerImpl::OnDisableMonitoringDone( |
| 439 const DisableMonitoringDoneCallback& callback) { | 439 const DisableMonitoringDoneCallback& callback) { |
| 440 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 440 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 441 | 441 |
| 442 OnMonitoringStateChanged(false); | 442 OnMonitoringStateChanged(false); |
| 443 | 443 |
| 444 // Notify all child processes. | 444 // Notify all child processes. |
| 445 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); | 445 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); |
| 446 it != trace_message_filters_.end(); ++it) { | 446 it != trace_message_filters_.end(); ++it) { |
| 447 it->get()->SendDisableMonitoring(); | 447 it->get()->SendDisableMonitoring(); |
| 448 } | 448 } |
| 449 if (!callback.is_null()) | 449 if (!callback.is_null()) |
| 450 callback.Run(); | 450 callback.Run(); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void TracingControllerImpl::GetMonitoringStatus( | 453 void TracingControllerImpl::GetMonitoringStatus( |
| 454 bool* out_enabled, | 454 bool* out_enabled, |
| 455 CategoryFilter* out_category_filter, | 455 CategoryFilter* out_category_filter, |
| 456 TraceOptions* out_trace_options) { | 456 TraceOptions* out_trace_options) { |
| 457 *out_enabled = is_monitoring_; | 457 *out_enabled = is_monitoring_; |
| 458 *out_category_filter = TraceLog::GetInstance()->GetCurrentCategoryFilter(); | 458 *out_category_filter = TraceLog::GetInstance()->GetCurrentCategoryFilter(); |
| 459 *out_trace_options = trace_options_; | 459 *out_trace_options = trace_options_; |
| 460 } | 460 } |
| 461 | 461 |
| 462 bool TracingControllerImpl::CaptureMonitoringSnapshot( | 462 bool TracingControllerImpl::CaptureMonitoringSnapshot( |
| 463 const scoped_refptr<TraceDataSink>& monitoring_data_sink) { | 463 const scoped_refptr<TraceDataSink>& monitoring_data_sink) { |
| 464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 464 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 465 | 465 |
| 466 if (!can_disable_monitoring()) | 466 if (!can_disable_monitoring()) |
| 467 return false; | 467 return false; |
| 468 | 468 |
| 469 if (!monitoring_data_sink.get()) | 469 if (!monitoring_data_sink.get()) |
| 470 return false; | 470 return false; |
| 471 | 471 |
| 472 monitoring_data_sink_ = monitoring_data_sink; | 472 monitoring_data_sink_ = monitoring_data_sink; |
| 473 | 473 |
| 474 // Count myself in pending_capture_monitoring_snapshot_ack_count_, | 474 // Count myself in pending_capture_monitoring_snapshot_ack_count_, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 495 | 495 |
| 496 #if defined(OS_ANDROID) | 496 #if defined(OS_ANDROID) |
| 497 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); | 497 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); |
| 498 #endif | 498 #endif |
| 499 | 499 |
| 500 return true; | 500 return true; |
| 501 } | 501 } |
| 502 | 502 |
| 503 bool TracingControllerImpl::GetTraceBufferUsage( | 503 bool TracingControllerImpl::GetTraceBufferUsage( |
| 504 const GetTraceBufferUsageCallback& callback) { | 504 const GetTraceBufferUsageCallback& callback) { |
| 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 505 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 506 | 506 |
| 507 if (!can_get_trace_buffer_usage() || callback.is_null()) | 507 if (!can_get_trace_buffer_usage() || callback.is_null()) |
| 508 return false; | 508 return false; |
| 509 | 509 |
| 510 pending_trace_buffer_usage_callback_ = callback; | 510 pending_trace_buffer_usage_callback_ = callback; |
| 511 | 511 |
| 512 // Count myself in pending_trace_log_status_ack_count_, acked below. | 512 // Count myself in pending_trace_log_status_ack_count_, acked below. |
| 513 pending_trace_log_status_ack_count_ = trace_message_filters_.size() + 1; | 513 pending_trace_log_status_ack_count_ = trace_message_filters_.size() + 1; |
| 514 pending_trace_log_status_filters_ = trace_message_filters_; | 514 pending_trace_log_status_filters_ = trace_message_filters_; |
| 515 maximum_trace_buffer_usage_ = 0; | 515 maximum_trace_buffer_usage_ = 0; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 531 it != trace_message_filters_.end(); ++it) { | 531 it != trace_message_filters_.end(); ++it) { |
| 532 it->get()->SendGetTraceLogStatus(); | 532 it->get()->SendGetTraceLogStatus(); |
| 533 } | 533 } |
| 534 return true; | 534 return true; |
| 535 } | 535 } |
| 536 | 536 |
| 537 bool TracingControllerImpl::SetWatchEvent( | 537 bool TracingControllerImpl::SetWatchEvent( |
| 538 const std::string& category_name, | 538 const std::string& category_name, |
| 539 const std::string& event_name, | 539 const std::string& event_name, |
| 540 const WatchEventCallback& callback) { | 540 const WatchEventCallback& callback) { |
| 541 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 541 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 542 | 542 |
| 543 if (callback.is_null()) | 543 if (callback.is_null()) |
| 544 return false; | 544 return false; |
| 545 | 545 |
| 546 watch_category_name_ = category_name; | 546 watch_category_name_ = category_name; |
| 547 watch_event_name_ = event_name; | 547 watch_event_name_ = event_name; |
| 548 watch_event_callback_ = callback; | 548 watch_event_callback_ = callback; |
| 549 | 549 |
| 550 TraceLog::GetInstance()->SetWatchEvent( | 550 TraceLog::GetInstance()->SetWatchEvent( |
| 551 category_name, event_name, | 551 category_name, event_name, |
| 552 base::Bind(&TracingControllerImpl::OnWatchEventMatched, | 552 base::Bind(&TracingControllerImpl::OnWatchEventMatched, |
| 553 base::Unretained(this))); | 553 base::Unretained(this))); |
| 554 | 554 |
| 555 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); | 555 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); |
| 556 it != trace_message_filters_.end(); ++it) { | 556 it != trace_message_filters_.end(); ++it) { |
| 557 it->get()->SendSetWatchEvent(category_name, event_name); | 557 it->get()->SendSetWatchEvent(category_name, event_name); |
| 558 } | 558 } |
| 559 return true; | 559 return true; |
| 560 } | 560 } |
| 561 | 561 |
| 562 bool TracingControllerImpl::CancelWatchEvent() { | 562 bool TracingControllerImpl::CancelWatchEvent() { |
| 563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 563 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 564 | 564 |
| 565 if (!can_cancel_watch_event()) | 565 if (!can_cancel_watch_event()) |
| 566 return false; | 566 return false; |
| 567 | 567 |
| 568 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); | 568 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); |
| 569 it != trace_message_filters_.end(); ++it) { | 569 it != trace_message_filters_.end(); ++it) { |
| 570 it->get()->SendCancelWatchEvent(); | 570 it->get()->SendCancelWatchEvent(); |
| 571 } | 571 } |
| 572 | 572 |
| 573 watch_event_callback_.Reset(); | 573 watch_event_callback_.Reset(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 pending_get_categories_done_callback_.Reset(); | 699 pending_get_categories_done_callback_.Reset(); |
| 700 } else if (trace_data_sink_.get()) { | 700 } else if (trace_data_sink_.get()) { |
| 701 trace_data_sink_->Close(); | 701 trace_data_sink_->Close(); |
| 702 trace_data_sink_ = NULL; | 702 trace_data_sink_ = NULL; |
| 703 } | 703 } |
| 704 } | 704 } |
| 705 | 705 |
| 706 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 706 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 707 void TracingControllerImpl::OnEndSystemTracingAcked( | 707 void TracingControllerImpl::OnEndSystemTracingAcked( |
| 708 const scoped_refptr<base::RefCountedString>& events_str_ptr) { | 708 const scoped_refptr<base::RefCountedString>& events_str_ptr) { |
| 709 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 709 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 710 | 710 |
| 711 if (trace_data_sink_.get()) { | 711 if (trace_data_sink_.get()) { |
| 712 #if defined(OS_WIN) | 712 #if defined(OS_WIN) |
| 713 // The Windows kernel events are kept into a JSon format stored as string | 713 // The Windows kernel events are kept into a JSon format stored as string |
| 714 // and must not be escaped. | 714 // and must not be escaped. |
| 715 std::string json_string = events_str_ptr->data(); | 715 std::string json_string = events_str_ptr->data(); |
| 716 #else | 716 #else |
| 717 std::string json_string = | 717 std::string json_string = |
| 718 base::GetQuotedJSONString(events_str_ptr->data()); | 718 base::GetQuotedJSONString(events_str_ptr->data()); |
| 719 #endif | 719 #endif |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 is_monitoring_ = is_monitoring; | 884 is_monitoring_ = is_monitoring; |
| 885 #if !defined(OS_ANDROID) | 885 #if !defined(OS_ANDROID) |
| 886 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); | 886 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); |
| 887 it != tracing_uis_.end(); it++) { | 887 it != tracing_uis_.end(); it++) { |
| 888 (*it)->OnMonitoringStateChanged(is_monitoring); | 888 (*it)->OnMonitoringStateChanged(is_monitoring); |
| 889 } | 889 } |
| 890 #endif | 890 #endif |
| 891 } | 891 } |
| 892 | 892 |
| 893 } // namespace content | 893 } // namespace content |
| OLD | NEW |