summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/tracing/tracing_controller_impl.cc33
-rw-r--r--content/browser/tracing/tracing_controller_impl.h7
-rw-r--r--content/browser/tracing/tracing_ui.cc11
-rw-r--r--content/browser/tracing/tracing_ui.h4
4 files changed, 52 insertions, 3 deletions
diff --git a/content/browser/tracing/tracing_controller_impl.cc b/content/browser/tracing/tracing_controller_impl.cc
index 8bca4a0..185eb98 100644
--- a/content/browser/tracing/tracing_controller_impl.cc
+++ b/content/browser/tracing/tracing_controller_impl.cc
@@ -10,6 +10,7 @@
#include "base/json/string_escape.h"
#include "base/strings/string_number_conversions.h"
#include "content/browser/tracing/trace_message_filter.h"
+#include "content/browser/tracing/tracing_ui.h"
#include "content/common/child_process_messages.h"
#include "content/public/browser/browser_message_filter.h"
#include "content/public/common/content_switches.h"
@@ -291,7 +292,7 @@ bool TracingControllerImpl::EnableMonitoring(
if (!can_enable_monitoring())
return false;
- is_monitoring_ = true;
+ OnMonitoringStateChanged(true);
#if defined(OS_ANDROID)
TraceLog::GetInstance()->AddClockSyncMetadataEvent();
@@ -353,7 +354,7 @@ void TracingControllerImpl::OnDisableMonitoringDone(
const DisableMonitoringDoneCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- is_monitoring_ = false;
+ OnMonitoringStateChanged(false);
// Notify all child processes.
for (TraceMessageFilterSet::iterator it = trace_message_filters_.begin();
@@ -782,4 +783,32 @@ void TracingControllerImpl::OnWatchEventMatched() {
watch_event_callback_.Run();
}
+void TracingControllerImpl::RegisterTracingUI(TracingUI* tracing_ui)
+{
+ DCHECK(tracing_uis_.find(tracing_ui) == tracing_uis_.end());
+ tracing_uis_.insert(tracing_ui);
+ tracing_ui->OnMonitoringStateChanged(is_monitoring_);
+}
+
+void TracingControllerImpl::UnregisterTracingUI(TracingUI* tracing_ui)
+{
+ std::set<TracingUI*>::iterator it = tracing_uis_.find(tracing_ui);
+ DCHECK(it != tracing_uis_.end());
+ tracing_uis_.erase(it);
+}
+
+void TracingControllerImpl::OnMonitoringStateChanged(bool is_monitoring)
+{
+ if (is_monitoring_ == is_monitoring)
+ return;
+
+ is_monitoring_ = is_monitoring;
+#if !defined(OS_ANDROID)
+ for (std::set<TracingUI*>::iterator it = tracing_uis_.begin();
+ it != tracing_uis_.end(); it++) {
+ (*it)->OnMonitoringStateChanged(is_monitoring);
+ }
+#endif
+}
+
} // namespace content
diff --git a/content/browser/tracing/tracing_controller_impl.h b/content/browser/tracing/tracing_controller_impl.h
index 0684373..da6039d 100644
--- a/content/browser/tracing/tracing_controller_impl.h
+++ b/content/browser/tracing/tracing_controller_impl.h
@@ -20,6 +20,7 @@ class RefCountedString;
namespace content {
class TraceMessageFilter;
+class TracingUI;
class TracingControllerImpl : public TracingController {
public:
@@ -54,6 +55,9 @@ class TracingControllerImpl : public TracingController {
const WatchEventCallback& callback) OVERRIDE;
virtual bool CancelWatchEvent() OVERRIDE;
+ void RegisterTracingUI(TracingUI* tracing_ui);
+ void UnregisterTracingUI(TracingUI* tracing_ui);
+
private:
typedef std::set<scoped_refptr<TraceMessageFilter> > TraceMessageFilterSet;
class ResultFile;
@@ -136,6 +140,8 @@ class TracingControllerImpl : public TracingController {
const EnableMonitoringDoneCallback& callback);
void OnDisableMonitoringDone(const DisableMonitoringDoneCallback& callback);
+ void OnMonitoringStateChanged(bool is_monitoring);
+
TraceMessageFilterSet trace_message_filters_;
// Pending acks for DisableRecording.
@@ -162,6 +168,7 @@ class TracingControllerImpl : public TracingController {
WatchEventCallback watch_event_callback_;
std::set<std::string> known_category_groups_;
+ std::set<TracingUI*> tracing_uis_;
scoped_ptr<ResultFile> result_file_;
scoped_ptr<ResultFile> monitoring_snapshot_file_;
DISALLOW_COPY_AND_ASSIGN(TracingControllerImpl);
diff --git a/content/browser/tracing/tracing_ui.cc b/content/browser/tracing/tracing_ui.cc
index 6b541f8..2f71e71 100644
--- a/content/browser/tracing/tracing_ui.cc
+++ b/content/browser/tracing/tracing_ui.cc
@@ -16,6 +16,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/values.h"
+#include "content/browser/tracing/tracing_controller_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/tracing_controller.h"
#include "content/public/browser/web_contents.h"
@@ -243,6 +244,16 @@ TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) {
source->AddResourcePath("tracing.js", IDR_TRACING_JS);
source->SetRequestFilter(base::Bind(OnTracingRequest));
WebUIDataSource::Add(browser_context, source);
+ TracingControllerImpl::GetInstance()->RegisterTracingUI(this);
+}
+
+TracingUI::~TracingUI() {
+ TracingControllerImpl::GetInstance()->UnregisterTracingUI(this);
+}
+
+void TracingUI::OnMonitoringStateChanged(bool is_monitoring) {
+ web_ui()->CallJavascriptFunction(
+ "onMonitoringStateChanged", base::FundamentalValue(is_monitoring));
}
} // namespace content
diff --git a/content/browser/tracing/tracing_ui.h b/content/browser/tracing/tracing_ui.h
index 85bbce1..40ce082 100644
--- a/content/browser/tracing/tracing_ui.h
+++ b/content/browser/tracing/tracing_ui.h
@@ -10,9 +10,11 @@
namespace content {
// The C++ back-end for the chrome://tracing webui page.
-class TracingUI : public WebUIController {
+class CONTENT_EXPORT TracingUI : public WebUIController {
public:
explicit TracingUI(WebUI* web_ui);
+ virtual ~TracingUI();
+ void OnMonitoringStateChanged(bool is_monitoring);
private:
DISALLOW_COPY_AND_ASSIGN(TracingUI);