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 "chrome/renderer/media/webrtc_logging_handler_impl.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/message_loop_proxy.h" | |
9 #include "chrome/common/partial_circular_buffer.h" | |
10 #include "chrome/renderer/media/webrtc_logging_message_filter.h" | |
11 #include "content/public/renderer/webrtc_logging_initializer.h" | |
12 | |
13 namespace chrome { | |
14 | |
15 WebRtcLoggingHandlerImpl::WebRtcLoggingHandlerImpl( | |
16 const scoped_refptr<base::MessageLoopProxy>& io_message_loop, | |
17 WebRtcLoggingMessageFilter* message_filter) | |
18 : io_message_loop_(io_message_loop), | |
19 message_filter_(message_filter), | |
20 log_initialized_(false) { | |
21 content::InitWebRtcLoggingDelegate(this); | |
22 } | |
23 | |
24 WebRtcLoggingHandlerImpl::~WebRtcLoggingHandlerImpl() { | |
25 DCHECK(io_message_loop_->BelongsToCurrentThread()); | |
26 } | |
27 | |
28 void WebRtcLoggingHandlerImpl::InitLogging(const std::string& app_session_id, | |
29 const std::string& app_url) { | |
30 if (!io_message_loop_->BelongsToCurrentThread()) { | |
31 io_message_loop_->PostTask( | |
32 FROM_HERE, base::Bind( | |
33 &WebRtcLoggingHandlerImpl::InitLogging, | |
34 base::Unretained(this), | |
35 app_session_id, | |
36 app_url)); | |
37 return; | |
38 } | |
39 | |
40 if (!log_initialized_) { | |
41 log_initialized_ = true; | |
42 message_filter_->InitLogging(app_session_id); | |
43 } | |
44 } | |
45 | |
46 void WebRtcLoggingHandlerImpl::LogMessage(const std::string& message) { | |
47 if (!io_message_loop_->BelongsToCurrentThread()) { | |
48 io_message_loop_->PostTask( | |
49 FROM_HERE, base::Bind( | |
50 &WebRtcLoggingHandlerImpl::LogMessage, | |
51 base::Unretained(this), | |
52 message)); | |
53 return; | |
54 } | |
55 | |
56 if (circular_buffer_) { | |
57 circular_buffer_->Write(message.c_str(), message.length()); | |
58 const char eol = '\n'; | |
59 circular_buffer_->Write(&eol, 1); | |
60 } | |
61 } | |
62 | |
63 void WebRtcLoggingHandlerImpl::OnFilterRemoved() { | |
64 DCHECK(io_message_loop_->BelongsToCurrentThread()); | |
65 message_filter_ = NULL; | |
66 } | |
67 | |
68 void WebRtcLoggingHandlerImpl::OnLogOpened( | |
69 base::SharedMemoryHandle handle, | |
70 uint32 length) { | |
71 DCHECK(io_message_loop_->BelongsToCurrentThread()); | |
72 | |
73 shared_memory_.reset(new base::SharedMemory(handle, false)); | |
74 CHECK(shared_memory_->Map(length)); | |
75 circular_buffer_.reset( | |
76 new chrome::PartialCircularBuffer(shared_memory_->memory(), | |
77 length, | |
78 length / 2)); | |
79 } | |
80 | |
81 void WebRtcLoggingHandlerImpl::OnOpenLogFailed() { | |
82 DCHECK(io_message_loop_->BelongsToCurrentThread()); | |
83 DLOG(ERROR) << "Could not open log."; | |
84 // TODO(grunell): Implement. | |
Jói
2013/05/27 17:50:03
Is this not needed for the current change?
Henrik Grunell
2013/05/28 06:04:30
No it isn't.
| |
85 NOTIMPLEMENTED(); | |
86 } | |
87 | |
88 } // namespace chrome | |
OLD | NEW |