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

Side by Side Diff: net/http/http_server_properties_impl.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_impl.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/stl_util.h"
9 #include "base/stringprintf.h"
10
11 namespace {
12
13 // Flattens the |host_port_pair| into the |spdy_server| string.
14 std::string GetFlattenedSpdyServer(const net::HostPortPair& host_port_pair) {
15 std::string spdy_server;
16 spdy_server.append(host_port_pair.host());
17 spdy_server.append(":");
18 base::StringAppendF(&spdy_server, "%d", host_port_pair.port());
19 return spdy_server;
20 }
21
22 } // namespace
23
24 namespace net {
25
26 HttpServerPropertiesImpl::HttpServerPropertiesImpl() {
27 }
28
29 HttpServerPropertiesImpl::~HttpServerPropertiesImpl() {
30 }
31
32 void HttpServerPropertiesImpl::Initialize(StringVector* spdy_servers,
33 bool support_spdy) {
34 spdy_servers_table_.clear();
35 scoped_ptr<StringVector> scoped_spdy_servers(spdy_servers);
36 for (StringVector::iterator it = spdy_servers->begin();
37 it != spdy_servers->end(); ++it) {
38 spdy_servers_table_[*it] = support_spdy;
39 }
40 }
41
42 bool HttpServerPropertiesImpl::SupportsSpdy(
43 const net::HostPortPair& host_port_pair) const {
44 if (host_port_pair.host().empty())
45 return false;
46 std::string spdy_server = GetFlattenedSpdyServer(host_port_pair);
47
48 SpdyServerHostPortTable::const_iterator spdy_host_port =
49 spdy_servers_table_.find(spdy_server);
50 if (spdy_host_port != spdy_servers_table_.end())
51 return spdy_host_port->second;
52 return false;
53 }
54
55 void HttpServerPropertiesImpl::SetSupportsSpdy(
56 const net::HostPortPair& host_port_pair,
57 bool support_spdy) {
58 std::string spdy_server = GetFlattenedSpdyServer(host_port_pair);
59
60 SpdyServerHostPortTable::iterator spdy_host_port =
61 spdy_servers_table_.find(spdy_server);
62 if ((spdy_host_port != spdy_servers_table_.end()) &&
63 (spdy_host_port->second == support_spdy)) {
64 return;
65 }
66 // Cache the data.
67 spdy_servers_table_[spdy_server] = support_spdy;
68 }
69
70 void HttpServerPropertiesImpl::GetSpdyServerList(
71 base::ListValue* spdy_server_list) {
willchan no longer on Chromium 2011/10/04 05:55:02 This should probably be a const member function. U
ramant (doing other things) 2011/10/06 06:17:52 Done.
72 // Get the list of servers (host/port) that support SPDY.
73 for (SpdyServerHostPortTable::iterator it = spdy_servers_table_.begin();
74 it != spdy_servers_table_.end(); ++it) {
75 const std::string spdy_server_host_port = it->first;
76 if (it->second)
77 spdy_server_list->Append(new StringValue(spdy_server_host_port));
78 }
79 }
80
81 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698