Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chrome/renderer/media/webrtc_logging_handler_impl.cc

Issue 15741003: Moving WebRTC logging related files from content to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changing log message delegation path to go via content. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/webrtc_logging_handler_impl.h" 5 #include "chrome/renderer/media/webrtc_logging_handler_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "content/common/partial_circular_buffer.h" 9 #include "chrome/common/partial_circular_buffer.h"
10 #include "content/renderer/media/webrtc_logging_message_filter.h" 10 #include "chrome/renderer/media/webrtc_logging_message_filter.h"
11 #include "third_party/libjingle/overrides/talk/base/logging.h" 11 #include "content/public/renderer/media/webrtc_logging_initializer.h"
12 12
13 namespace content { 13 namespace chrome {
14 14
15 WebRtcLoggingHandlerImpl::WebRtcLoggingHandlerImpl( 15 WebRtcLoggingHandlerImpl::WebRtcLoggingHandlerImpl(
16 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) 16 const scoped_refptr<base::MessageLoopProxy>& io_message_loop,
17 : io_message_loop_(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);
18 } 22 }
19 23
20 WebRtcLoggingHandlerImpl::~WebRtcLoggingHandlerImpl() { 24 WebRtcLoggingHandlerImpl::~WebRtcLoggingHandlerImpl() {
21 DCHECK(CalledOnValidThread()); 25 DCHECK(CalledOnValidThread());
22 } 26 }
23 27
28 void WebRtcLoggingHandlerImpl::InitLogging(const std::string& app_session_id,
29 const std::string& app_url) {
30 DCHECK(CalledOnValidThread());
31
32 if (!log_initialized_) {
33 log_initialized_ = true;
34 message_filter_->InitLogging(app_session_id, app_url);
35 }
36 }
37
24 void WebRtcLoggingHandlerImpl::LogMessage(const std::string& message) { 38 void WebRtcLoggingHandlerImpl::LogMessage(const std::string& message) {
25 if (!io_message_loop_->BelongsToCurrentThread()) { 39 if (!CalledOnValidThread()) {
26 io_message_loop_->PostTask( 40 io_message_loop_->PostTask(
27 FROM_HERE, base::Bind( 41 FROM_HERE, base::Bind(
28 &WebRtcLoggingHandlerImpl::LogMessage, 42 &WebRtcLoggingHandlerImpl::LogMessage,
29 base::Unretained(this), 43 base::Unretained(this),
30 message)); 44 message));
31 return; 45 return;
32 } 46 }
33 47
34 circular_buffer_->Write(message.c_str(), message.length()); 48 if (circular_buffer_) {
35 const char eol = '\n'; 49 circular_buffer_->Write(message.c_str(), message.length());
36 circular_buffer_->Write(&eol, 1); 50 const char eol = '\n';
51 circular_buffer_->Write(&eol, 1);
52 }
37 } 53 }
38 54
39 void WebRtcLoggingHandlerImpl::OnFilterRemoved() { 55 void WebRtcLoggingHandlerImpl::OnFilterRemoved() {
40 DCHECK(CalledOnValidThread()); 56 DCHECK(CalledOnValidThread());
57 message_filter_ = NULL;
41 } 58 }
42 59
43 void WebRtcLoggingHandlerImpl::OnLogOpened( 60 void WebRtcLoggingHandlerImpl::OnLogOpened(
44 base::SharedMemoryHandle handle, 61 base::SharedMemoryHandle handle,
45 uint32 length) { 62 uint32 length) {
46 DCHECK(CalledOnValidThread()); 63 DCHECK(CalledOnValidThread());
47 64
48 shared_memory_.reset(new base::SharedMemory(handle, false)); 65 shared_memory_.reset(new base::SharedMemory(handle, false));
49 CHECK(shared_memory_->Map(length)); 66 CHECK(shared_memory_->Map(length));
50 circular_buffer_.reset( 67 circular_buffer_.reset(
51 new content::PartialCircularBuffer(shared_memory_->memory(), 68 new chrome::PartialCircularBuffer(shared_memory_->memory(),
52 length, 69 length,
53 length / 2)); 70 length / 2));
54
55 talk_base::InitDiagnosticLoggingDelegate(this);
56 } 71 }
57 72
58 void WebRtcLoggingHandlerImpl::OnOpenLogFailed() { 73 void WebRtcLoggingHandlerImpl::OnOpenLogFailed() {
59 DCHECK(CalledOnValidThread()); 74 DCHECK(CalledOnValidThread());
60 DLOG(ERROR) << "Could not open log."; 75 DLOG(ERROR) << "Could not open log.";
61 // TODO(grunell): Implement. 76 // TODO(grunell): Implement.
62 NOTIMPLEMENTED(); 77 NOTIMPLEMENTED();
63 } 78 }
64 79
65 } // namespace content 80 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698