OLD | NEW |
---|---|
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/http/http_server_properties_impl.h" | 5 #include "net/http/http_server_properties_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/string_number_conversions.h" | |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 const uint64 kBrokenAlternateProtocolDelaySecs = 300; | 20 const uint64 kBrokenAlternateProtocolDelaySecs = 300; |
20 | 21 |
21 } // namespace | 22 } // namespace |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 spdy_server_list->Append(new base::StringValue(spdy_server_host_port)); | 125 spdy_server_list->Append(new base::StringValue(spdy_server_host_port)); |
125 ++count; | 126 ++count; |
126 } | 127 } |
127 } | 128 } |
128 } | 129 } |
129 | 130 |
130 // static | 131 // static |
131 std::string HttpServerPropertiesImpl::GetFlattenedSpdyServer( | 132 std::string HttpServerPropertiesImpl::GetFlattenedSpdyServer( |
132 const net::HostPortPair& host_port_pair) { | 133 const net::HostPortPair& host_port_pair) { |
133 std::string spdy_server; | 134 std::string spdy_server; |
134 spdy_server.append(host_port_pair.host()); | 135 spdy_server.reserve(host_port_pair.host().length() + 7); |
136 spdy_server.assign(host_port_pair.host()); | |
135 spdy_server.append(":"); | 137 spdy_server.append(":"); |
136 base::StringAppendF(&spdy_server, "%d", host_port_pair.port()); | 138 spdy_server.append(base::IntToString(host_port_pair.port())); |
Ryan Sleevi
2014/12/01 16:28:51
Not LGTM.
I don't like line 135 because, as a pro
Ryan Hamilton
2014/12/01 20:14:53
I agree with everything sleevi said. I'd be inclin
| |
137 return spdy_server; | 139 return spdy_server; |
138 } | 140 } |
139 | 141 |
140 static const AlternateProtocolInfo* g_forced_alternate_protocol = NULL; | 142 static const AlternateProtocolInfo* g_forced_alternate_protocol = NULL; |
141 | 143 |
142 // static | 144 // static |
143 void HttpServerPropertiesImpl::ForceAlternateProtocol( | 145 void HttpServerPropertiesImpl::ForceAlternateProtocol( |
144 const AlternateProtocolInfo& info) { | 146 const AlternateProtocolInfo& info) { |
145 // Note: we're going to leak this. | 147 // Note: we're going to leak this. |
146 if (g_forced_alternate_protocol) | 148 if (g_forced_alternate_protocol) |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); | 499 base::TimeDelta delay = when > now ? when - now : base::TimeDelta(); |
498 base::MessageLoop::current()->PostDelayedTask( | 500 base::MessageLoop::current()->PostDelayedTask( |
499 FROM_HERE, | 501 FROM_HERE, |
500 base::Bind( | 502 base::Bind( |
501 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, | 503 &HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings, |
502 weak_ptr_factory_.GetWeakPtr()), | 504 weak_ptr_factory_.GetWeakPtr()), |
503 delay); | 505 delay); |
504 } | 506 } |
505 | 507 |
506 } // namespace net | 508 } // namespace net |
OLD | NEW |