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 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
| |
44 // TODO(grunell): Handle or disallow. | |
45 NOTIMPLEMENTED(); | |
46 | |
47 if (!shared_memory_.CreateAndMapAnonymous(kWebRtcLogSize)) { | |
48 LOG(ERROR) << "Failed to create shared memory."; | |
49 Send(new WebRtcLoggingMsg_OpenLogFailed()); | |
50 return; | |
51 } | |
52 | |
53 base::SharedMemoryHandle foreign_memory_handle; | |
54 if (!shared_memory_.ShareToProcess(peer_handle(), | |
55 &foreign_memory_handle)) { | |
56 // TODO(grunell): Handle error. (E.g. close, unmap and send fail msg.) | |
57 return; | |
58 } | |
59 | |
60 Send(new WebRtcLoggingMsg_LogOpened(foreign_memory_handle, kWebRtcLogSize)); | |
61 } | |
62 | |
63 } // namespace content | |
OLD | NEW |