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