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

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

Issue 127703002: Add a mechanism to let TracingController invoke JavaScript via TracingUI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/tracing/tracing_controller_impl.h ('k') | content/browser/tracing/tracing_ui.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 4
5 #include "content/browser/tracing/tracing_controller_impl.h" 5 #include "content/browser/tracing/tracing_controller_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/json/string_escape.h" 10 #include "base/json/string_escape.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "content/browser/tracing/trace_message_filter.h" 12 #include "content/browser/tracing/trace_message_filter.h"
13 #include "content/browser/tracing/tracing_ui.h"
13 #include "content/common/child_process_messages.h" 14 #include "content/common/child_process_messages.h"
14 #include "content/public/browser/browser_message_filter.h" 15 #include "content/public/browser/browser_message_filter.h"
15 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
16 17
17 using base::debug::TraceLog; 18 using base::debug::TraceLog;
18 19
19 namespace content { 20 namespace content {
20 21
21 namespace { 22 namespace {
22 23
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 285 }
285 286
286 bool TracingControllerImpl::EnableMonitoring( 287 bool TracingControllerImpl::EnableMonitoring(
287 const std::string& category_filter, 288 const std::string& category_filter,
288 TracingController::Options options, 289 TracingController::Options options,
289 const EnableMonitoringDoneCallback& callback) { 290 const EnableMonitoringDoneCallback& callback) {
290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
291 292
292 if (!can_enable_monitoring()) 293 if (!can_enable_monitoring())
293 return false; 294 return false;
294 is_monitoring_ = true; 295 OnMonitoringStateChanged(true);
295 296
296 #if defined(OS_ANDROID) 297 #if defined(OS_ANDROID)
297 TraceLog::GetInstance()->AddClockSyncMetadataEvent(); 298 TraceLog::GetInstance()->AddClockSyncMetadataEvent();
298 #endif 299 #endif
299 300
300 int trace_options = 0; 301 int trace_options = 0;
301 if (options & ENABLE_SAMPLING) 302 if (options & ENABLE_SAMPLING)
302 trace_options |= TraceLog::ENABLE_SAMPLING; 303 trace_options |= TraceLog::ENABLE_SAMPLING;
303 304
304 base::Closure on_enable_monitoring_done_callback = 305 base::Closure on_enable_monitoring_done_callback =
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 base::Bind(&TracingControllerImpl::SetDisabledOnFileThread, 347 base::Bind(&TracingControllerImpl::SetDisabledOnFileThread,
347 base::Unretained(this), 348 base::Unretained(this),
348 on_disable_monitoring_done_callback)); 349 on_disable_monitoring_done_callback));
349 return true; 350 return true;
350 } 351 }
351 352
352 void TracingControllerImpl::OnDisableMonitoringDone( 353 void TracingControllerImpl::OnDisableMonitoringDone(
353 const DisableMonitoringDoneCallback& callback) { 354 const DisableMonitoringDoneCallback& callback) {
354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
355 356
356 is_monitoring_ = false; 357 OnMonitoringStateChanged(false);
357 358
358 // Notify all child processes. 359 // Notify all child processes.
359 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin(); 360 for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin();
360 it != trace_message_filters_.end(); ++it) { 361 it != trace_message_filters_.end(); ++it) {
361 it->get()->SendDisableMonitoring(); 362 it->get()->SendDisableMonitoring();
362 } 363 }
363 364
364 if (!callback.is_null()) 365 if (!callback.is_null())
365 callback.Run(); 366 callback.Run();
366 } 367 }
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 776 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
776 base::Bind(&TracingControllerImpl::OnWatchEventMatched, 777 base::Bind(&TracingControllerImpl::OnWatchEventMatched,
777 base::Unretained(this))); 778 base::Unretained(this)));
778 return; 779 return;
779 } 780 }
780 781
781 if (!watch_event_callback_.is_null()) 782 if (!watch_event_callback_.is_null())
782 watch_event_callback_.Run(); 783 watch_event_callback_.Run();
783 } 784 }
784 785
786 void TracingControllerImpl::RegisterTracingUI(TracingUI* tracing_ui)
787 {
788 DCHECK(tracing_uis_.find(tracing_ui) == tracing_uis_.end());
789 tracing_uis_.insert(tracing_ui);
790 tracing_ui->OnMonitoringStateChanged(is_monitoring_);
791 }
792
793 void TracingControllerImpl::UnregisterTracingUI(TracingUI* tracing_ui)
794 {
795 std::set<TracingUI*>::iterator it = tracing_uis_.find(tracing_ui);
796 DCHECK(it != tracing_uis_.end());
797 tracing_uis_.erase(it);
798 }
799
800 void TracingControllerImpl::OnMonitoringStateChanged(bool is_monitoring)
801 {
802 if (is_monitoring_ == is_monitoring)
803 return;
804
805 is_monitoring_ = is_monitoring;
806 #if !defined(OS_ANDROID)
807 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin();
808 it != tracing_uis_.end(); it++) {
809 (*it)->OnMonitoringStateChanged(is_monitoring);
810 }
811 #endif
812 }
813
785 } // namespace content 814 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/tracing/tracing_controller_impl.h ('k') | content/browser/tracing/tracing_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698