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

Side by Side Diff: net/http/http_server_properties.cc

Issue 7827033: Introduce net::HttpServerPropertiesManager to manage server-specific properties. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/http/http_server_properties.h"
6
7 #include "base/stl_util.h"
8 #include "base/stringprintf.h"
9
10 namespace net {
11
12 HttpServerProperties::HttpServerProperties() {
13 }
14
15 HttpServerProperties::~HttpServerProperties() {
16 }
17
18 void HttpServerProperties::Initialize(StringVector* spdy_servers,
19 bool support_spdy) {
20 spdy_servers_table_.clear();
21 scoped_ptr<StringVector> scoped_spdy_servers(spdy_servers);
22 for (StringVector::iterator it = spdy_servers->begin();
23 it != spdy_servers->end(); ++it) {
24 spdy_servers_table_[*it] = support_spdy;
25 }
26 }
27
28 bool HttpServerProperties::SupportsSpdy(
29 const net::HostPortPair& host_port_pair) {
30 if (host_port_pair.host().empty())
31 return false;
32 std::string spdy_server;
33 GetFlattenedSpdyServer(host_port_pair, spdy_server);
34
35 SpdyServerHostPortTable::const_iterator spdy_host_port =
36 spdy_servers_table_.find(spdy_server);
37 if (spdy_host_port != spdy_servers_table_.end())
38 return spdy_host_port->second;
39 return false;
40 }
41
42 void HttpServerProperties::SetSupportsSpdy(
43 const net::HostPortPair& host_port_pair,
44 bool support_spdy) {
45 std::string spdy_server;
46 GetFlattenedSpdyServer(host_port_pair, spdy_server);
47
48 SpdyServerHostPortTable::iterator spdy_host_port =
49 spdy_servers_table_.find(spdy_server);
50 if ((spdy_host_port != spdy_servers_table_.end()) &&
51 (spdy_host_port->second == support_spdy)) {
52 return;
53 }
54 // Cache the data.
55 spdy_servers_table_[spdy_server] = support_spdy;
56 }
57
58 void HttpServerProperties::GetSpdyServerList(
59 base::ListValue* spdy_server_list) {
60 // Get the list of servers (host/port) that support SPDY.
61 for (SpdyServerHostPortTable::iterator it = spdy_servers_table_.begin();
62 it != spdy_servers_table_.end(); ++it) {
63 const std::string spdy_server_host_port = it->first;
64 if (it->second)
65 spdy_server_list->Append(new StringValue(spdy_server_host_port));
66 }
67 }
68
69 void HttpServerProperties::GetFlattenedSpdyServer(
70 const net::HostPortPair& host_port_pair,
71 std::string& spdy_server) {
72 spdy_server.append(host_port_pair.host());
73 spdy_server.append(":");
74 base::StringAppendF(&spdy_server, "%d", host_port_pair.port());
75 }
76
77 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698