blob: 9545b9d6a82695ef8086db10dcfab162633a4822 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// 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 "content/browser/media/webrtc_internals_message_handler.h"
#include "content/browser/media/webrtc_internals.h"
#include "content/common/media/peer_connection_tracker_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
using base::ListValue;
namespace content {
WebRTCInternalsMessageHandler::WebRTCInternalsMessageHandler() {
WebRTCInternals::GetInstance()->AddObserver(this);
}
WebRTCInternalsMessageHandler::~WebRTCInternalsMessageHandler() {
WebRTCInternals::GetInstance()->RemoveObserver(this);
}
void WebRTCInternalsMessageHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("getAllUpdates",
base::Bind(&WebRTCInternalsMessageHandler::OnGetAllUpdates,
base::Unretained(this)));
web_ui()->RegisterMessageCallback("getAllStats",
base::Bind(&WebRTCInternalsMessageHandler::OnGetAllStats,
base::Unretained(this)));
}
void WebRTCInternalsMessageHandler::OnGetAllUpdates(
const base::ListValue* list) {
WebRTCInternals::GetInstance()->SendAllUpdates();
}
void WebRTCInternalsMessageHandler::OnGetAllStats(const ListValue* list) {
for (RenderProcessHost::iterator i(
content::RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance()) {
i.GetCurrentValue()->Send(new PeerConnectionTracker_GetAllStats());
}
}
void WebRTCInternalsMessageHandler::OnUpdate(const std::string& command,
const base::Value* args) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
std::vector<const Value*> args_vector;
args_vector.push_back(args);
string16 update = WebUI::GetJavascriptCall(command, args_vector);
RenderViewHost* host = web_ui()->GetWebContents()->GetRenderViewHost();
if (host)
host->ExecuteJavascriptInWebFrame(string16(), update);
}
} // namespace content
|