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

Side by Side Diff: chrome/browser/media/webrtc/webrtc_text_log_handler.cc

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: Address comments Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/webrtc_text_log_handler.h" 5 #include "chrome/browser/media/webrtc/webrtc_text_log_handler.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 size_t find_pos = sensitive_address.rfind('.'); 70 size_t find_pos = sensitive_address.rfind('.');
71 if (find_pos == std::string::npos) 71 if (find_pos == std::string::npos)
72 return std::string(); 72 return std::string();
73 sensitive_address.resize(find_pos); 73 sensitive_address.resize(find_pos);
74 sensitive_address += ".x"; 74 sensitive_address += ".x";
75 break; 75 break;
76 } 76 }
77 case net::IPAddress::kIPv6AddressSize: { 77 case net::IPAddress::kIPv6AddressSize: {
78 // TODO(grunell): Create a string of format "1:2:3:x:x:x:x:x" to clarify 78 // TODO(grunell): Create a string of format "1:2:3:x:x:x:x:x" to clarify
79 // that the end has been stripped out. 79 // that the end has been stripped out.
80 std::vector<uint8_t> bytes = address.bytes(); 80 std::vector<uint8_t> bytes = address.BytesAsVector();
81 std::fill(bytes.begin() + 6, bytes.end(), 0); 81 std::fill(bytes.begin() + 6, bytes.end(), 0);
82 net::IPAddress stripped_address(bytes); 82 net::IPAddress stripped_address(bytes);
83 sensitive_address = stripped_address.ToString(); 83 sensitive_address = stripped_address.ToString();
84 break; 84 break;
85 } 85 }
86 default: { break; } 86 default: { break; }
87 } 87 }
88 return sensitive_address; 88 return sensitive_address;
89 #else 89 #else
90 return address.ToString(); 90 return address.ToString();
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 505 }
506 } 506 }
507 507
508 void WebRtcTextLogHandler::DisableBrowserProcessLoggingOnUIThread() { 508 void WebRtcTextLogHandler::DisableBrowserProcessLoggingOnUIThread() {
509 DCHECK_CURRENTLY_ON(BrowserThread::UI); 509 DCHECK_CURRENTLY_ON(BrowserThread::UI);
510 content::RenderProcessHost* host = 510 content::RenderProcessHost* host =
511 content::RenderProcessHost::FromID(render_process_id_); 511 content::RenderProcessHost::FromID(render_process_id_);
512 if (host) 512 if (host)
513 host->ClearWebRtcLogMessageCallback(); 513 host->ClearWebRtcLogMessageCallback();
514 } 514 }
OLDNEW
« no previous file with comments | « no previous file | content/public/common/common_param_traits.cc » ('j') | content/public/common/common_param_traits.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698