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

Side by Side Diff: chrome/browser/ui/webui/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: 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/webrtc_internals_proxy.h"
6
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/media/webrtc_internals.h"
9 #include "chrome/browser/ui/webui/webrtc_internals_message_handler.h"
10 #include "content/public/browser/web_ui.h"
11
12 using content::BrowserThread;
13
14 WebRTCInternalsProxy::WebRTCInternalsProxy() {}
15
16 void WebRTCInternalsProxy::OnUpdate(const std::string& command,
17 const base::Value* args) {
18 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
19 std::vector<const Value*> args_vector;
20 args_vector.push_back(args);
21 string16 update = content::WebUI::GetJavascriptCall(command, args_vector);
22
23 BrowserThread::PostTask(
24 BrowserThread::UI, FROM_HERE,
25 base::Bind(&WebRTCInternalsProxy::UpdateOnUIThread, this, update));
26 }
27
28 void WebRTCInternalsProxy::Attach(WebRTCInternalsMessageHandler* handler) {
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
30 handler_ = handler;
31 BrowserThread::PostTask(
32 BrowserThread::IO, FROM_HERE,
33 base::Bind(&WebRTCInternalsProxy::ObserveWebRTCInternalsOnIOThread,
34 this));
35 }
36
37 void WebRTCInternalsProxy::Detach() {
38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
39 handler_ = NULL;
40 BrowserThread::PostTask(
41 BrowserThread::IO, FROM_HERE,
42 base::Bind(
43 &WebRTCInternalsProxy::StopObservingWebRTCInternalsOnIOThread, this));
44 }
45
46 WebRTCInternalsProxy::~WebRTCInternalsProxy() {}
47
48 void WebRTCInternalsProxy::ObserveWebRTCInternalsOnIOThread() {
49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
50 WebRTCInternals::GetInstance()->AddObserver(this);
51 }
52
53 void WebRTCInternalsProxy::StopObservingWebRTCInternalsOnIOThread() {
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
55 WebRTCInternals::GetInstance()->RemoveObserver(this);
56 }
57
58 void WebRTCInternalsProxy::UpdateOnUIThread(const string16& update) {
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
60 if (handler_)
61 handler_->OnUpdate(update);
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698