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

Side by Side Diff: chrome/browser/media/webrtc_logging_handler_host.cc

Issue 142923005: Allow MessageFilters to restrict listening to specific message classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK valid message class OR special message type Created 6 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/media/webrtc_logging_handler_host.h" 5 #include "chrome/browser/media/webrtc_logging_handler_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const size_t kWebRtcLogSize = 1 * 1024 * 1024; // 1 MB 51 const size_t kWebRtcLogSize = 1 * 1024 * 1024; // 1 MB
52 #else 52 #else
53 const size_t kWebRtcLogSize = 6 * 1024 * 1024; // 6 MB 53 const size_t kWebRtcLogSize = 6 * 1024 * 1024; // 6 MB
54 #endif 54 #endif
55 55
56 namespace { 56 namespace {
57 57
58 const char kLogNotStoppedOrNoLogOpen[] = 58 const char kLogNotStoppedOrNoLogOpen[] =
59 "Logging not stopped or no log open."; 59 "Logging not stopped or no log open.";
60 60
61 const uint32 kFilteredMessageClasses[] = {
62 MessagePortMsgStart,
63 };
64
61 // For privacy reasons when logging IP addresses. The returned "sensitive 65 // For privacy reasons when logging IP addresses. The returned "sensitive
62 // string" is for release builds a string with the end stripped away. Last 66 // string" is for release builds a string with the end stripped away. Last
63 // octet for IPv4 and last 80 bits (5 groups) for IPv6. String will be 67 // octet for IPv4 and last 80 bits (5 groups) for IPv6. String will be
64 // "1.2.3.x" and "1.2.3::" respectively. For debug builds, the string is 68 // "1.2.3.x" and "1.2.3::" respectively. For debug builds, the string is
65 // not stripped. 69 // not stripped.
66 std::string IPAddressToSensitiveString(const net::IPAddressNumber& address) { 70 std::string IPAddressToSensitiveString(const net::IPAddressNumber& address) {
67 #if defined(NDEBUG) 71 #if defined(NDEBUG)
68 std::string sensitive_address; 72 std::string sensitive_address;
69 switch (net::GetAddressFamily(address)) { 73 switch (net::GetAddressFamily(address)) {
70 case net::ADDRESS_FAMILY_IPV4: { 74 case net::ADDRESS_FAMILY_IPV4: {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 it != meta_data.end(); ++it) { 106 it != meta_data.end(); ++it) {
103 *message += it->first + ": " + it->second + '\n'; 107 *message += it->first + ": " + it->second + '\n';
104 } 108 }
105 // Remove last '\n'. 109 // Remove last '\n'.
106 message->resize(message->size() - 1); 110 message->resize(message->size() - 1);
107 } 111 }
108 112
109 } // namespace 113 } // namespace
110 114
111 WebRtcLoggingHandlerHost::WebRtcLoggingHandlerHost(Profile* profile) 115 WebRtcLoggingHandlerHost::WebRtcLoggingHandlerHost(Profile* profile)
112 : profile_(profile), 116 : BrowserMessageFilter(
117 kFilteredMessageClasses, arraysize(kFilteredMessageClasses)),
118 profile_(profile),
113 logging_state_(CLOSED), 119 logging_state_(CLOSED),
114 upload_log_on_render_close_(false) { 120 upload_log_on_render_close_(false) {
115 DCHECK(profile_); 121 DCHECK(profile_);
116 } 122 }
117 123
118 WebRtcLoggingHandlerHost::~WebRtcLoggingHandlerHost() {} 124 WebRtcLoggingHandlerHost::~WebRtcLoggingHandlerHost() {}
119 125
120 void WebRtcLoggingHandlerHost::SetMetaData( 126 void WebRtcLoggingHandlerHost::SetMetaData(
121 const MetaDataMap& meta_data, 127 const MetaDataMap& meta_data,
122 const GenericDoneCallback& callback) { 128 const GenericDoneCallback& callback) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 void WebRtcLoggingHandlerHost::FireGenericDoneCallback( 424 void WebRtcLoggingHandlerHost::FireGenericDoneCallback(
419 GenericDoneCallback* callback, bool success, 425 GenericDoneCallback* callback, bool success,
420 const std::string& error_message) { 426 const std::string& error_message) {
421 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 427 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
422 DCHECK(!(*callback).is_null()); 428 DCHECK(!(*callback).is_null());
423 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 429 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
424 base::Bind(*callback, success, 430 base::Bind(*callback, success,
425 error_message)); 431 error_message));
426 (*callback).Reset(); 432 (*callback).Reset();
427 } 433 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698