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

Unified Diff: chrome/browser/ui/webui/media/webrtc_internals_proxy.cc

Issue 11876007: Connecting webrtc-internals WebUI frontend with the backend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@main
Patch Set: fix vrk's comment Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/media/webrtc_internals_proxy.cc
diff --git a/chrome/browser/ui/webui/media/webrtc_internals_proxy.cc b/chrome/browser/ui/webui/media/webrtc_internals_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a48a7acc08155883d178b6a3c26231b109818f0f
--- /dev/null
+++ b/chrome/browser/ui/webui/media/webrtc_internals_proxy.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/media/webrtc_internals_proxy.h"
+
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/media/webrtc_internals.h"
+#include "chrome/browser/ui/webui/media/webrtc_internals_message_handler.h"
+#include "content/public/browser/web_ui.h"
+
+using content::BrowserThread;
+using media::WebRTCInternals;
+
+WebRTCInternalsProxy::WebRTCInternalsProxy() {}
+
+void WebRTCInternalsProxy::OnUpdate(const std::string& command,
+ const base::Value* args) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ std::vector<const Value*> args_vector;
+ args_vector.push_back(args);
+ string16 update = content::WebUI::GetJavascriptCall(command, args_vector);
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&WebRTCInternalsProxy::UpdateOnUIThread, this, update));
+}
+
+void WebRTCInternalsProxy::Attach(WebRTCInternalsMessageHandler* handler) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ handler_ = handler;
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&WebRTCInternalsProxy::ObserveWebRTCInternalsOnIOThread,
+ this));
+}
+
+void WebRTCInternalsProxy::Detach() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ handler_ = NULL;
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(
+ &WebRTCInternalsProxy::StopObservingWebRTCInternalsOnIOThread, this));
+}
+
+WebRTCInternalsProxy::~WebRTCInternalsProxy() {}
+
+void WebRTCInternalsProxy::ObserveWebRTCInternalsOnIOThread() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ WebRTCInternals::GetInstance()->AddObserver(this);
+}
+
+void WebRTCInternalsProxy::StopObservingWebRTCInternalsOnIOThread() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ WebRTCInternals::GetInstance()->RemoveObserver(this);
+}
+
+void WebRTCInternalsProxy::UpdateOnUIThread(const string16& update) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (handler_)
+ handler_->OnUpdate(update);
+}

Powered by Google App Engine
This is Rietveld 408576698