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

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: Rebase 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"
12
13 namespace content {
14 11
15 WebRtcLoggingHandlerImpl::WebRtcLoggingHandlerImpl( 12 WebRtcLoggingHandlerImpl::WebRtcLoggingHandlerImpl(
16 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) 13 const scoped_refptr<base::MessageLoopProxy>& io_message_loop,
17 : io_message_loop_(io_message_loop) { 14 WebRtcLoggingMessageFilter* message_filter)
15 : io_message_loop_(io_message_loop),
16 message_filter_(message_filter),
17 log_initialized_(false) {
18 content::InitWebRtcLoggingDelegate(this);
18 } 19 }
19 20
20 WebRtcLoggingHandlerImpl::~WebRtcLoggingHandlerImpl() { 21 WebRtcLoggingHandlerImpl::~WebRtcLoggingHandlerImpl() {
21 DCHECK(CalledOnValidThread()); 22 DCHECK(CalledOnValidThread());
22 } 23 }
23 24
25 void WebRtcLoggingHandlerImpl::InitLogging(const std::string& app_session_id,
26 const std::string& app_url) {
27 DCHECK(CalledOnValidThread());
28
29 if (!log_initialized_) {
30 log_initialized_ = true;
31 message_filter_->InitLogging(app_session_id, app_url);
32 }
33 }
34
24 void WebRtcLoggingHandlerImpl::LogMessage(const std::string& message) { 35 void WebRtcLoggingHandlerImpl::LogMessage(const std::string& message) {
25 if (!io_message_loop_->BelongsToCurrentThread()) { 36 if (!CalledOnValidThread()) {
26 io_message_loop_->PostTask( 37 io_message_loop_->PostTask(
27 FROM_HERE, base::Bind( 38 FROM_HERE, base::Bind(
28 &WebRtcLoggingHandlerImpl::LogMessage, 39 &WebRtcLoggingHandlerImpl::LogMessage,
29 base::Unretained(this), 40 base::Unretained(this),
30 message)); 41 message));
31 return; 42 return;
32 } 43 }
33 44
34 circular_buffer_->Write(message.c_str(), message.length()); 45 if (circular_buffer_) {
35 const char eol = '\n'; 46 circular_buffer_->Write(message.c_str(), message.length());
36 circular_buffer_->Write(&eol, 1); 47 const char eol = '\n';
48 circular_buffer_->Write(&eol, 1);
49 }
37 } 50 }
38 51
39 void WebRtcLoggingHandlerImpl::OnFilterRemoved() { 52 void WebRtcLoggingHandlerImpl::OnFilterRemoved() {
40 DCHECK(CalledOnValidThread()); 53 DCHECK(CalledOnValidThread());
54 message_filter_ = NULL;
41 } 55 }
42 56
43 void WebRtcLoggingHandlerImpl::OnLogOpened( 57 void WebRtcLoggingHandlerImpl::OnLogOpened(
44 base::SharedMemoryHandle handle, 58 base::SharedMemoryHandle handle,
45 uint32 length) { 59 uint32 length) {
46 DCHECK(CalledOnValidThread()); 60 DCHECK(CalledOnValidThread());
47 61
48 shared_memory_.reset(new base::SharedMemory(handle, false)); 62 shared_memory_.reset(new base::SharedMemory(handle, false));
49 CHECK(shared_memory_->Map(length)); 63 CHECK(shared_memory_->Map(length));
50 circular_buffer_.reset( 64 circular_buffer_.reset(
51 new content::PartialCircularBuffer(shared_memory_->memory(), 65 new PartialCircularBuffer(shared_memory_->memory(),
52 length, 66 length,
53 length / 2)); 67 length / 2));
54
55 talk_base::InitDiagnosticLoggingDelegate(this);
56 } 68 }
57 69
58 void WebRtcLoggingHandlerImpl::OnOpenLogFailed() { 70 void WebRtcLoggingHandlerImpl::OnOpenLogFailed() {
59 DCHECK(CalledOnValidThread()); 71 DCHECK(CalledOnValidThread());
60 DLOG(ERROR) << "Could not open log."; 72 DLOG(ERROR) << "Could not open log.";
61 // TODO(grunell): Implement. 73 // TODO(grunell): Implement.
62 NOTIMPLEMENTED(); 74 NOTIMPLEMENTED();
63 } 75 }
64
65 } // namespace content
OLDNEW
« no previous file with comments | « chrome/renderer/media/webrtc_logging_handler_impl.h ('k') | chrome/renderer/media/webrtc_logging_handler_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698