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/renderer/media/webrtc_logging_handler_impl.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/message_loop_proxy.h" | |
9 #include "content/common/partial_circular_buffer.h" | |
10 #include "content/renderer/media/webrtc_logging_message_filter.h" | |
11 #include "third_party/libjingle/overrides/talk/base/logging.h" | |
12 | |
13 namespace content { | |
14 | |
15 WebRtcLoggingHandlerImpl::WebRtcLoggingHandlerImpl( | |
16 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) | |
17 : io_message_loop_(io_message_loop) { | |
18 } | |
19 | |
20 WebRtcLoggingHandlerImpl::~WebRtcLoggingHandlerImpl() { | |
21 DCHECK(CalledOnValidThread()); | |
22 } | |
23 | |
24 void WebRtcLoggingHandlerImpl::LogMessage(const std::string& message) { | |
25 if (!io_message_loop_->BelongsToCurrentThread()) { | |
26 io_message_loop_->PostTask( | |
27 FROM_HERE, base::Bind( | |
28 &WebRtcLoggingHandlerImpl::LogMessage, | |
29 base::Unretained(this), | |
30 message)); | |
31 return; | |
32 } | |
33 | |
34 circular_buffer_->Write(message.c_str(), message.length()); | |
35 const char eol = '\n'; | |
36 circular_buffer_->Write(&eol, 1); | |
37 } | |
38 | |
39 void WebRtcLoggingHandlerImpl::OnFilterRemoved() { | |
40 DCHECK(CalledOnValidThread()); | |
41 } | |
42 | |
43 void WebRtcLoggingHandlerImpl::OnLogOpened( | |
44 base::SharedMemoryHandle handle, | |
45 uint32 length) { | |
46 DCHECK(CalledOnValidThread()); | |
47 | |
48 shared_memory_.reset(new base::SharedMemory(handle, false)); | |
49 CHECK(shared_memory_->Map(length)); | |
50 circular_buffer_.reset( | |
51 new content::PartialCircularBuffer(shared_memory_->memory(), | |
52 length, | |
53 length / 2)); | |
54 | |
55 talk_base::InitDiagnosticLoggingDelegate(this); | |
56 } | |
57 | |
58 void WebRtcLoggingHandlerImpl::OnOpenLogFailed() { | |
59 DCHECK(CalledOnValidThread()); | |
60 DLOG(ERROR) << "Could not open log."; | |
61 // TODO(grunell): Implement. | |
62 NOTIMPLEMENTED(); | |
63 } | |
64 | |
65 } // namespace content | |
OLD | NEW |