OLD | NEW |
| (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 "content/browser/renderer_host/media/webrtc_logging_handler_host.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/logging.h" | |
9 #include "content/common/media/webrtc_logging_messages.h" | |
10 | |
11 namespace content { | |
12 | |
13 #if defined(OS_ANDROID) | |
14 const size_t kWebRtcLogSize = 1 * 1024 * 1024; // 1 MB | |
15 #else | |
16 const size_t kWebRtcLogSize = 6 * 1024 * 1024; // 6 MB | |
17 #endif | |
18 | |
19 WebRtcLoggingHandlerHost::WebRtcLoggingHandlerHost() { | |
20 } | |
21 | |
22 WebRtcLoggingHandlerHost::~WebRtcLoggingHandlerHost() { | |
23 } | |
24 | |
25 void WebRtcLoggingHandlerHost::OnChannelClosing() { | |
26 BrowserMessageFilter::OnChannelClosing(); | |
27 } | |
28 | |
29 void WebRtcLoggingHandlerHost::OnDestruct() const { | |
30 BrowserThread::DeleteOnIOThread::Destruct(this); | |
31 } | |
32 | |
33 bool WebRtcLoggingHandlerHost::OnMessageReceived(const IPC::Message& message, | |
34 bool* message_was_ok) { | |
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
36 bool handled = true; | |
37 IPC_BEGIN_MESSAGE_MAP_EX(WebRtcLoggingHandlerHost, message, *message_was_ok) | |
38 IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_OpenLog, OnOpenLog) | |
39 IPC_MESSAGE_UNHANDLED(handled = false) | |
40 IPC_END_MESSAGE_MAP_EX() | |
41 | |
42 return handled; | |
43 } | |
44 | |
45 void WebRtcLoggingHandlerHost::OnOpenLog(const std::string& app_session_id, | |
46 const std::string& app_url) { | |
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
48 DCHECK(!base::SharedMemory::IsHandleValid(shared_memory_.handle())); | |
49 | |
50 if (!shared_memory_.CreateAndMapAnonymous(kWebRtcLogSize)) { | |
51 DLOG(ERROR) << "Failed to create shared memory."; | |
52 Send(new WebRtcLoggingMsg_OpenLogFailed()); | |
53 return; | |
54 } | |
55 | |
56 base::SharedMemoryHandle foreign_memory_handle; | |
57 if (!shared_memory_.ShareToProcess(peer_handle(), | |
58 &foreign_memory_handle)) { | |
59 Send(new WebRtcLoggingMsg_OpenLogFailed()); | |
60 return; | |
61 } | |
62 | |
63 app_session_id_ = app_session_id; | |
64 app_url_ = app_url; | |
65 Send(new WebRtcLoggingMsg_LogOpened(foreign_memory_handle, kWebRtcLogSize)); | |
66 } | |
67 | |
68 } // namespace content | |
OLD | NEW |