Chromium Code Reviews| Index: content/browser/renderer_host/webrtc_logging_handler_host.cc |
| diff --git a/content/browser/renderer_host/webrtc_logging_handler_host.cc b/content/browser/renderer_host/webrtc_logging_handler_host.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2efb8d86f6380650bd48d83b7e8968053fe86654 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/webrtc_logging_handler_host.cc |
| @@ -0,0 +1,63 @@ |
| +// 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/renderer_host/webrtc_logging_handler_host.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/logging.h" |
| +#include "content/common/webrtc_logging_messages.h" |
| + |
| +namespace content { |
| + |
| +const size_t kWebRtcLogSize = 6 * 1024 * 1024; // 6 MB |
| + |
| +WebRtcLoggingHandlerHost::WebRtcLoggingHandlerHost() { |
| +} |
| + |
| +WebRtcLoggingHandlerHost::~WebRtcLoggingHandlerHost() { |
| +} |
| + |
| +void WebRtcLoggingHandlerHost::OnChannelClosing() { |
| + BrowserMessageFilter::OnChannelClosing(); |
| +} |
| + |
| +void WebRtcLoggingHandlerHost::OnDestruct() const { |
| + BrowserThread::DeleteOnIOThread::Destruct(this); |
| +} |
| + |
| +bool WebRtcLoggingHandlerHost::OnMessageReceived(const IPC::Message& message, |
| + bool* message_was_ok) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| + bool handled = true; |
| + IPC_BEGIN_MESSAGE_MAP_EX(WebRtcLoggingHandlerHost, message, *message_was_ok) |
| + IPC_MESSAGE_HANDLER(WebRtcLoggingMsg_OpenLog, OnOpenLog) |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP_EX() |
| + |
| + return handled; |
| +} |
| + |
| +void WebRtcLoggingHandlerHost::OnOpenLog() { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| + if (base::SharedMemory::IsHandleValid(shared_memory_.handle())) |
|
tommi (sloooow) - chröme
2013/03/28 11:00:10
{}
Maybe just be a DCHECK for now (until we suppo
Henrik Grunell
2013/04/02 10:06:40
Yep, sgtm. The handler in the render process can e
|
| + // TODO(grunell): Handle or disallow. |
| + NOTIMPLEMENTED(); |
| + |
| + if (!shared_memory_.CreateAndMapAnonymous(kWebRtcLogSize)) { |
| + LOG(ERROR) << "Failed to create shared memory."; |
| + Send(new WebRtcLoggingMsg_OpenLogFailed()); |
| + return; |
| + } |
| + |
| + base::SharedMemoryHandle foreign_memory_handle; |
| + if (!shared_memory_.ShareToProcess(peer_handle(), |
| + &foreign_memory_handle)) { |
| + // TODO(grunell): Handle error. (E.g. close, unmap and send fail msg.) |
| + return; |
| + } |
| + |
| + Send(new WebRtcLoggingMsg_LogOpened(foreign_memory_handle, kWebRtcLogSize)); |
| +} |
| + |
| +} // namespace content |