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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_server_properties_impl.cc
===================================================================
--- net/http/http_server_properties_impl.cc (revision 0)
+++ net/http/http_server_properties_impl.cc (revision 0)
@@ -0,0 +1,81 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/http/http_server_properties_impl.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/stl_util.h"
+#include "base/stringprintf.h"
+
+namespace {
+
+// Flattens the |host_port_pair| into the |spdy_server| string.
+std::string GetFlattenedSpdyServer(const net::HostPortPair& host_port_pair) {
+ std::string spdy_server;
+ spdy_server.append(host_port_pair.host());
+ spdy_server.append(":");
+ base::StringAppendF(&spdy_server, "%d", host_port_pair.port());
+ return spdy_server;
+}
+
+} // namespace
+
+namespace net {
+
+HttpServerPropertiesImpl::HttpServerPropertiesImpl() {
+}
+
+HttpServerPropertiesImpl::~HttpServerPropertiesImpl() {
+}
+
+void HttpServerPropertiesImpl::Initialize(StringVector* spdy_servers,
+ bool support_spdy) {
+ spdy_servers_table_.clear();
+ scoped_ptr<StringVector> scoped_spdy_servers(spdy_servers);
+ for (StringVector::iterator it = spdy_servers->begin();
+ it != spdy_servers->end(); ++it) {
+ spdy_servers_table_[*it] = support_spdy;
+ }
+}
+
+bool HttpServerPropertiesImpl::SupportsSpdy(
+ const net::HostPortPair& host_port_pair) const {
+ if (host_port_pair.host().empty())
+ return false;
+ std::string spdy_server = GetFlattenedSpdyServer(host_port_pair);
+
+ SpdyServerHostPortTable::const_iterator spdy_host_port =
+ spdy_servers_table_.find(spdy_server);
+ if (spdy_host_port != spdy_servers_table_.end())
+ return spdy_host_port->second;
+ return false;
+}
+
+void HttpServerPropertiesImpl::SetSupportsSpdy(
+ const net::HostPortPair& host_port_pair,
+ bool support_spdy) {
+ std::string spdy_server = GetFlattenedSpdyServer(host_port_pair);
+
+ SpdyServerHostPortTable::iterator spdy_host_port =
+ spdy_servers_table_.find(spdy_server);
+ if ((spdy_host_port != spdy_servers_table_.end()) &&
+ (spdy_host_port->second == support_spdy)) {
+ return;
+ }
+ // Cache the data.
+ spdy_servers_table_[spdy_server] = support_spdy;
+}
+
+void HttpServerPropertiesImpl::GetSpdyServerList(
+ 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.
+ // Get the list of servers (host/port) that support SPDY.
+ for (SpdyServerHostPortTable::iterator it = spdy_servers_table_.begin();
+ it != spdy_servers_table_.end(); ++it) {
+ const std::string spdy_server_host_port = it->first;
+ if (it->second)
+ spdy_server_list->Append(new StringValue(spdy_server_host_port));
+ }
+}
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698