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

Side by Side Diff: net/base/host_port_pair.cc

Issue 218923002: Merge internal change: 63891842 - QuicServerId changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | net/base/host_port_pair_unittest.cc » ('j') | net/quic/quic_server_id_test.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/base/host_port_pair.h" 5 #include "net/base/host_port_pair.h"
6 6
7 #include "base/logging.h"
7 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "net/base/ip_endpoint.h" 12 #include "net/base/ip_endpoint.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 14
14 namespace net { 15 namespace net {
15 16
16 HostPortPair::HostPortPair() : port_(0) {} 17 HostPortPair::HostPortPair() : port_(0) {}
(...skipping 23 matching lines...) Expand all
40 host_port_pair.set_host(key_port[0]); 41 host_port_pair.set_host(key_port[0]);
41 host_port_pair.set_port(port); 42 host_port_pair.set_port(port);
42 return host_port_pair; 43 return host_port_pair;
43 } 44 }
44 45
45 std::string HostPortPair::ToString() const { 46 std::string HostPortPair::ToString() const {
46 return base::StringPrintf("%s:%u", HostForURL().c_str(), port_); 47 return base::StringPrintf("%s:%u", HostForURL().c_str(), port_);
47 } 48 }
48 49
49 std::string HostPortPair::HostForURL() const { 50 std::string HostPortPair::HostForURL() const {
51 // TODO(rtenneti): Add support for |host| to have '\0'.
wtc 2014/04/01 22:10:58 Can you explain why |host| may have '\0'?
ramant (doing other things) 2014/04/02 02:34:45 avd mentioned if host is constructed in code where
52 if (host_.find('\0') != std::string::npos) {
53 LOG(DFATAL) << "Host has a null char: " << host_;
Ryan Hamilton 2014/03/31 15:45:43 nit: how about DLOG_IF(DFATAL) ...?
ramant (doing other things) 2014/03/31 18:40:32 Fixed in https://codereview.chromium.org/216713003
ramant (doing other things) 2014/04/01 03:19:56 Hi Ryan, In net/spdy and net/quic, we are using
54 }
50 // Check to see if the host is an IPv6 address. If so, added brackets. 55 // Check to see if the host is an IPv6 address. If so, added brackets.
51 if (host_.find(':') != std::string::npos) { 56 if (host_.find(':') != std::string::npos) {
52 DCHECK_NE(host_[0], '['); 57 DCHECK_NE(host_[0], '[');
53 return base::StringPrintf("[%s]", host_.c_str()); 58 return base::StringPrintf("[%s]", host_.c_str());
54 } 59 }
55 60
56 return host_; 61 return host_;
57 } 62 }
58 63
59 } // namespace net 64 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/base/host_port_pair_unittest.cc » ('j') | net/quic/quic_server_id_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698