OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" | 4 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" |
5 | 5 |
6 #include "base/process_util.h" | 6 #include "base/process_util.h" |
7 #include "content/browser/media/webrtc_internals.h" | |
8 #include "content/common/media/peer_connection_tracker_messages.h" | 7 #include "content/common/media/peer_connection_tracker_messages.h" |
9 #include "content/public/browser/content_browser_client.h" | 8 #include "content/public/browser/content_browser_client.h" |
| 9 #include "content/public/browser/webrtc_internals.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 PeerConnectionTrackerHost::PeerConnectionTrackerHost() { | 13 PeerConnectionTrackerHost::PeerConnectionTrackerHost() { |
14 } | 14 } |
15 | 15 |
16 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message, | 16 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message, |
17 bool* message_was_ok) { | 17 bool* message_was_ok) { |
18 bool handled = true; | 18 bool handled = true; |
| 19 |
19 IPC_BEGIN_MESSAGE_MAP_EX(PeerConnectionTrackerHost, message, *message_was_ok) | 20 IPC_BEGIN_MESSAGE_MAP_EX(PeerConnectionTrackerHost, message, *message_was_ok) |
20 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, | 21 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, |
21 OnAddPeerConnection) | 22 OnAddPeerConnection) |
22 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_RemovePeerConnection, | 23 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_RemovePeerConnection, |
23 OnRemovePeerConnection) | 24 OnRemovePeerConnection) |
24 IPC_MESSAGE_UNHANDLED(handled = false) | 25 IPC_MESSAGE_UNHANDLED(handled = false) |
25 IPC_END_MESSAGE_MAP_EX() | 26 IPC_END_MESSAGE_MAP_EX() |
26 return handled; | 27 return handled; |
27 } | 28 } |
28 | 29 |
| 30 void PeerConnectionTrackerHost::OverrideThreadForMessage( |
| 31 const IPC::Message& message, BrowserThread::ID* thread) { |
| 32 if (IPC_MESSAGE_CLASS(message) == PeerConnectionTrackerMsgStart) |
| 33 *thread = BrowserThread::UI; |
| 34 } |
| 35 |
29 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() { | 36 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() { |
30 } | 37 } |
31 | 38 |
32 void PeerConnectionTrackerHost::OnAddPeerConnection( | 39 void PeerConnectionTrackerHost::OnAddPeerConnection( |
33 const PeerConnectionInfo& info) { | 40 const PeerConnectionInfo& info) { |
34 WebRTCInternals::GetInstance()->AddPeerConnection( | 41 if (!GetContentClient()->browser()->GetWebRTCInternals()) |
35 base::GetProcId(peer_handle()), info); | 42 return; |
| 43 |
| 44 GetContentClient()->browser()->GetWebRTCInternals()-> |
| 45 AddPeerConnection(base::GetProcId(peer_handle()), |
| 46 info.lid, |
| 47 info.url, |
| 48 info.servers, |
| 49 info.constraints); |
36 } | 50 } |
37 | 51 |
38 void PeerConnectionTrackerHost::OnRemovePeerConnection(int lid) { | 52 void PeerConnectionTrackerHost::OnRemovePeerConnection(int lid) { |
39 WebRTCInternals::GetInstance()->RemovePeerConnection( | 53 if (!GetContentClient()->browser()->GetWebRTCInternals()) |
40 base::GetProcId(peer_handle()), lid); | 54 return; |
| 55 |
| 56 GetContentClient()->browser()->GetWebRTCInternals()-> |
| 57 RemovePeerConnection(base::GetProcId(peer_handle()), lid); |
41 } | 58 } |
42 | 59 |
43 } // namespace content | 60 } // namespace content |
OLD | NEW |