OLD | NEW |
(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 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
| 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/hash_tables.h" |
| 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "base/values.h" |
| 15 #include "net/base/host_port_pair.h" |
| 16 #include "net/base/net_export.h" |
| 17 #include "net/http/http_server_properties.h" |
| 18 |
| 19 namespace base { |
| 20 class ListValue; |
| 21 } |
| 22 |
| 23 namespace net { |
| 24 |
| 25 // The implementation for setting/retrieving the HTTP server properties. |
| 26 class NET_EXPORT HttpServerPropertiesImpl |
| 27 : public HttpServerProperties, |
| 28 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 29 public: |
| 30 HttpServerPropertiesImpl(); |
| 31 virtual ~HttpServerPropertiesImpl(); |
| 32 |
| 33 // Initializes |spdy_servers_table_| with the servers (host/port) from |
| 34 // |spdy_servers| that either support SPDY or not. |
| 35 void Initialize(StringVector* spdy_servers, bool support_spdy); |
| 36 |
| 37 // Returns true if |server| supports SPDY. |
| 38 virtual bool SupportsSpdy(const HostPortPair& server) const OVERRIDE; |
| 39 |
| 40 // Add |server| into the persistent store. |
| 41 virtual void SetSupportsSpdy(const HostPortPair& server, |
| 42 bool support_spdy) OVERRIDE; |
| 43 |
| 44 // Deletes all data. |
| 45 virtual void DeleteAll() OVERRIDE; |
| 46 |
| 47 // Get the list of servers (host/port) that support SPDY. |
| 48 void GetSpdyServerList(base::ListValue* spdy_server_list) const; |
| 49 |
| 50 // Returns flattened string representation of the |host_port_pair|. Used by |
| 51 // unittests. |
| 52 static std::string GetFlattenedSpdyServer( |
| 53 const net::HostPortPair& host_port_pair); |
| 54 |
| 55 private: |
| 56 // |spdy_servers_table_| has flattened representation of servers (host/port |
| 57 // pair) that either support or not support SPDY protocol. |
| 58 typedef base::hash_map<std::string, bool> SpdyServerHostPortTable; |
| 59 SpdyServerHostPortTable spdy_servers_table_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); |
| 62 }; |
| 63 |
| 64 } // namespace net |
| 65 |
| 66 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
OLD | NEW |