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

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

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: Done 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>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/containers/stack_container.h"
13 #include "base/cpu.h" 14 #include "base/cpu.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/sys_info.h" 18 #include "base/sys_info.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "chrome/browser/media/webrtc/webrtc_log_uploader.h" 20 #include "chrome/browser/media/webrtc/webrtc_log_uploader.h"
20 #include "chrome/common/channel_info.h" 21 #include "chrome/common/channel_info.h"
21 #include "chrome/common/media/webrtc_logging_messages.h" 22 #include "chrome/common/media/webrtc_logging_messages.h"
22 #include "components/version_info/version_info.h" 23 #include "components/version_info/version_info.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 size_t find_pos = sensitive_address.rfind('.'); 71 size_t find_pos = sensitive_address.rfind('.');
71 if (find_pos == std::string::npos) 72 if (find_pos == std::string::npos)
72 return std::string(); 73 return std::string();
73 sensitive_address.resize(find_pos); 74 sensitive_address.resize(find_pos);
74 sensitive_address += ".x"; 75 sensitive_address += ".x";
75 break; 76 break;
76 } 77 }
77 case net::IPAddress::kIPv6AddressSize: { 78 case net::IPAddress::kIPv6AddressSize: {
78 // TODO(grunell): Create a string of format "1:2:3:x:x:x:x:x" to clarify 79 // 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. 80 // that the end has been stripped out.
80 std::vector<uint8_t> bytes = address.bytes(); 81 base::StackVector<uint8_t, 16> bytes;
eroman 2017/05/19 22:00:07 How about without StackVector: net::IPAddressByte
Ryan Hamilton 2017/05/20 03:21:44 Done. (With minor modifications)
eroman 2017/05/22 18:06:44 Let's worry about that later (Was just an observat
81 std::fill(bytes.begin() + 6, bytes.end(), 0); 82 for (uint8_t byte : address.bytes())
82 net::IPAddress stripped_address(bytes); 83 bytes->push_back(byte);
84 std::fill(bytes->begin() + 6, bytes->end(), 0);
85 net::IPAddress stripped_address(bytes->data(), bytes->size());
83 sensitive_address = stripped_address.ToString(); 86 sensitive_address = stripped_address.ToString();
84 break; 87 break;
85 } 88 }
86 default: { break; } 89 default: { break; }
87 } 90 }
88 return sensitive_address; 91 return sensitive_address;
89 #else 92 #else
90 return address.ToString(); 93 return address.ToString();
91 #endif 94 #endif
92 } 95 }
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 508 }
506 } 509 }
507 510
508 void WebRtcTextLogHandler::DisableBrowserProcessLoggingOnUIThread() { 511 void WebRtcTextLogHandler::DisableBrowserProcessLoggingOnUIThread() {
509 DCHECK_CURRENTLY_ON(BrowserThread::UI); 512 DCHECK_CURRENTLY_ON(BrowserThread::UI);
510 content::RenderProcessHost* host = 513 content::RenderProcessHost* host =
511 content::RenderProcessHost::FromID(render_process_id_); 514 content::RenderProcessHost::FromID(render_process_id_);
512 if (host) 515 if (host)
513 host->ClearWebRtcLogMessageCallback(); 516 host->ClearWebRtcLogMessageCallback();
514 } 517 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/pepper/pepper_socket_utils.cc » ('j') | net/base/ip_address.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698