| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
| 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // and grab a WeakPtr. | 50 // and grab a WeakPtr. |
| 51 class NET_EXPORT HttpServerPropertiesManager : public HttpServerProperties { | 51 class NET_EXPORT HttpServerPropertiesManager : public HttpServerProperties { |
| 52 public: | 52 public: |
| 53 // Create an instance of the HttpServerPropertiesManager. The lifetime of the | 53 // Create an instance of the HttpServerPropertiesManager. The lifetime of the |
| 54 // PrefService objects must be longer than that of the | 54 // PrefService objects must be longer than that of the |
| 55 // HttpServerPropertiesManager object. Must be constructed on the Pref thread. | 55 // HttpServerPropertiesManager object. Must be constructed on the Pref thread. |
| 56 HttpServerPropertiesManager( | 56 HttpServerPropertiesManager( |
| 57 PrefService* pref_service, | 57 PrefService* pref_service, |
| 58 const char* pref_path, | 58 const char* pref_path, |
| 59 scoped_refptr<base::SequencedTaskRunner> network_task_runner); | 59 scoped_refptr<base::SequencedTaskRunner> network_task_runner); |
| 60 virtual ~HttpServerPropertiesManager(); | 60 ~HttpServerPropertiesManager() override; |
| 61 | 61 |
| 62 // Initialize on Network thread. | 62 // Initialize on Network thread. |
| 63 void InitializeOnNetworkThread(); | 63 void InitializeOnNetworkThread(); |
| 64 | 64 |
| 65 // Prepare for shutdown. Must be called on the Pref thread before destruction. | 65 // Prepare for shutdown. Must be called on the Pref thread before destruction. |
| 66 void ShutdownOnPrefThread(); | 66 void ShutdownOnPrefThread(); |
| 67 | 67 |
| 68 // Helper function for unit tests to set the version in the dictionary. | 68 // Helper function for unit tests to set the version in the dictionary. |
| 69 static void SetVersion(base::DictionaryValue* http_server_properties_dict, | 69 static void SetVersion(base::DictionaryValue* http_server_properties_dict, |
| 70 int version_number); | 70 int version_number); |
| 71 | 71 |
| 72 // Deletes all data. Works asynchronously, but if a |completion| callback is | 72 // Deletes all data. Works asynchronously, but if a |completion| callback is |
| 73 // provided, it will be fired on the pref thread when everything is done. | 73 // provided, it will be fired on the pref thread when everything is done. |
| 74 void Clear(const base::Closure& completion); | 74 void Clear(const base::Closure& completion); |
| 75 | 75 |
| 76 // ---------------------------------- | 76 // ---------------------------------- |
| 77 // HttpServerProperties methods: | 77 // HttpServerProperties methods: |
| 78 // ---------------------------------- | 78 // ---------------------------------- |
| 79 | 79 |
| 80 // Gets a weak pointer for this object. | 80 // Gets a weak pointer for this object. |
| 81 virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() override; | 81 base::WeakPtr<HttpServerProperties> GetWeakPtr() override; |
| 82 | 82 |
| 83 // Deletes all data. Works asynchronously. | 83 // Deletes all data. Works asynchronously. |
| 84 virtual void Clear() override; | 84 void Clear() override; |
| 85 | 85 |
| 86 // Returns true if |server| supports SPDY. Should only be called from IO | 86 // Returns true if |server| supports SPDY. Should only be called from IO |
| 87 // thread. | 87 // thread. |
| 88 virtual bool SupportsSpdy(const HostPortPair& server) override; | 88 bool SupportsSpdy(const HostPortPair& server) override; |
| 89 | 89 |
| 90 // Add |server| as the SPDY server which supports SPDY protocol into the | 90 // Add |server| as the SPDY server which supports SPDY protocol into the |
| 91 // persisitent store. Should only be called from IO thread. | 91 // persisitent store. Should only be called from IO thread. |
| 92 virtual void SetSupportsSpdy(const HostPortPair& server, | 92 void SetSupportsSpdy(const HostPortPair& server, bool support_spdy) override; |
| 93 bool support_spdy) override; | |
| 94 | 93 |
| 95 // Returns true if |server| has an Alternate-Protocol header. | 94 // Returns true if |server| has an Alternate-Protocol header. |
| 96 virtual bool HasAlternateProtocol(const HostPortPair& server) override; | 95 bool HasAlternateProtocol(const HostPortPair& server) override; |
| 97 | 96 |
| 98 // Returns the Alternate-Protocol and port for |server|. | 97 // Returns the Alternate-Protocol and port for |server|. |
| 99 // HasAlternateProtocol(server) must be true. | 98 // HasAlternateProtocol(server) must be true. |
| 100 virtual AlternateProtocolInfo GetAlternateProtocol( | 99 AlternateProtocolInfo GetAlternateProtocol( |
| 101 const HostPortPair& server) override; | 100 const HostPortPair& server) override; |
| 102 | 101 |
| 103 // Sets the Alternate-Protocol for |server|. | 102 // Sets the Alternate-Protocol for |server|. |
| 104 virtual void SetAlternateProtocol( | 103 void SetAlternateProtocol(const HostPortPair& server, |
| 105 const HostPortPair& server, | 104 uint16 alternate_port, |
| 106 uint16 alternate_port, | 105 AlternateProtocol alternate_protocol, |
| 107 AlternateProtocol alternate_protocol, | 106 double alternate_probability) override; |
| 108 double alternate_probability) override; | |
| 109 | 107 |
| 110 // Sets the Alternate-Protocol for |server| to be BROKEN. | 108 // Sets the Alternate-Protocol for |server| to be BROKEN. |
| 111 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) override; | 109 void SetBrokenAlternateProtocol(const HostPortPair& server) override; |
| 112 | 110 |
| 113 // Returns true if Alternate-Protocol for |server| was recently BROKEN. | 111 // Returns true if Alternate-Protocol for |server| was recently BROKEN. |
| 114 virtual bool WasAlternateProtocolRecentlyBroken( | 112 bool WasAlternateProtocolRecentlyBroken(const HostPortPair& server) override; |
| 115 const HostPortPair& server) override; | |
| 116 | 113 |
| 117 // Confirms that Alternate-Protocol for |server| is working. | 114 // Confirms that Alternate-Protocol for |server| is working. |
| 118 virtual void ConfirmAlternateProtocol(const HostPortPair& server) override; | 115 void ConfirmAlternateProtocol(const HostPortPair& server) override; |
| 119 | 116 |
| 120 // Clears the Alternate-Protocol for |server|. | 117 // Clears the Alternate-Protocol for |server|. |
| 121 virtual void ClearAlternateProtocol(const HostPortPair& server) override; | 118 void ClearAlternateProtocol(const HostPortPair& server) override; |
| 122 | 119 |
| 123 // Returns all Alternate-Protocol mappings. | 120 // Returns all Alternate-Protocol mappings. |
| 124 virtual const AlternateProtocolMap& alternate_protocol_map() const override; | 121 const AlternateProtocolMap& alternate_protocol_map() const override; |
| 125 | 122 |
| 126 virtual void SetAlternateProtocolExperiment( | 123 void SetAlternateProtocolExperiment( |
| 127 AlternateProtocolExperiment experiment) override; | 124 AlternateProtocolExperiment experiment) override; |
| 128 | 125 |
| 129 virtual void SetAlternateProtocolProbabilityThreshold( | 126 void SetAlternateProtocolProbabilityThreshold(double threshold) override; |
| 130 double threshold) override; | |
| 131 | 127 |
| 132 virtual AlternateProtocolExperiment GetAlternateProtocolExperiment() | 128 AlternateProtocolExperiment GetAlternateProtocolExperiment() const override; |
| 133 const override; | |
| 134 | 129 |
| 135 // Gets a reference to the SettingsMap stored for a host. | 130 // Gets a reference to the SettingsMap stored for a host. |
| 136 // If no settings are stored, returns an empty SettingsMap. | 131 // If no settings are stored, returns an empty SettingsMap. |
| 137 virtual const SettingsMap& GetSpdySettings( | 132 const SettingsMap& GetSpdySettings( |
| 138 const HostPortPair& host_port_pair) override; | 133 const HostPortPair& host_port_pair) override; |
| 139 | 134 |
| 140 // Saves an individual SPDY setting for a host. Returns true if SPDY setting | 135 // Saves an individual SPDY setting for a host. Returns true if SPDY setting |
| 141 // is to be persisted. | 136 // is to be persisted. |
| 142 virtual bool SetSpdySetting(const HostPortPair& host_port_pair, | 137 bool SetSpdySetting(const HostPortPair& host_port_pair, |
| 143 SpdySettingsIds id, | 138 SpdySettingsIds id, |
| 144 SpdySettingsFlags flags, | 139 SpdySettingsFlags flags, |
| 145 uint32 value) override; | 140 uint32 value) override; |
| 146 | 141 |
| 147 // Clears all SPDY settings for a host. | 142 // Clears all SPDY settings for a host. |
| 148 virtual void ClearSpdySettings(const HostPortPair& host_port_pair) override; | 143 void ClearSpdySettings(const HostPortPair& host_port_pair) override; |
| 149 | 144 |
| 150 // Clears all SPDY settings for all hosts. | 145 // Clears all SPDY settings for all hosts. |
| 151 virtual void ClearAllSpdySettings() override; | 146 void ClearAllSpdySettings() override; |
| 152 | 147 |
| 153 // Returns all SPDY persistent settings. | 148 // Returns all SPDY persistent settings. |
| 154 virtual const SpdySettingsMap& spdy_settings_map() const override; | 149 const SpdySettingsMap& spdy_settings_map() const override; |
| 155 | 150 |
| 156 // Methods for SupportsQuic. | 151 // Methods for SupportsQuic. |
| 157 virtual SupportsQuic GetSupportsQuic( | 152 SupportsQuic GetSupportsQuic( |
| 158 const HostPortPair& host_port_pair) const override; | 153 const HostPortPair& host_port_pair) const override; |
| 159 | 154 |
| 160 virtual void SetSupportsQuic(const HostPortPair& host_port_pair, | 155 void SetSupportsQuic(const HostPortPair& host_port_pair, |
| 161 bool used_quic, | 156 bool used_quic, |
| 162 const std::string& address) override; | 157 const std::string& address) override; |
| 163 | 158 |
| 164 virtual const SupportsQuicMap& supports_quic_map() const override; | 159 const SupportsQuicMap& supports_quic_map() const override; |
| 165 | 160 |
| 166 virtual void SetServerNetworkStats(const HostPortPair& host_port_pair, | 161 void SetServerNetworkStats(const HostPortPair& host_port_pair, |
| 167 NetworkStats stats) override; | 162 NetworkStats stats) override; |
| 168 | 163 |
| 169 virtual const NetworkStats* GetServerNetworkStats( | 164 const NetworkStats* GetServerNetworkStats( |
| 170 const HostPortPair& host_port_pair) const override; | 165 const HostPortPair& host_port_pair) const override; |
| 171 | 166 |
| 172 protected: | 167 protected: |
| 173 // -------------------- | 168 // -------------------- |
| 174 // SPDY related methods | 169 // SPDY related methods |
| 175 | 170 |
| 176 // These are used to delay updating of the cached data in | 171 // These are used to delay updating of the cached data in |
| 177 // |http_server_properties_impl_| while the preferences are changing, and | 172 // |http_server_properties_impl_| while the preferences are changing, and |
| 178 // execute only one update per simultaneous prefs changes. | 173 // execute only one update per simultaneous prefs changes. |
| 179 void ScheduleUpdateCacheOnPrefThread(); | 174 void ScheduleUpdateCacheOnPrefThread(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // Used to get |weak_ptr_| to self on the network thread. | 261 // Used to get |weak_ptr_| to self on the network thread. |
| 267 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > | 262 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > |
| 268 network_weak_ptr_factory_; | 263 network_weak_ptr_factory_; |
| 269 | 264 |
| 270 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 265 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
| 271 }; | 266 }; |
| 272 | 267 |
| 273 } // namespace net | 268 } // namespace net |
| 274 | 269 |
| 275 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 270 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
| OLD | NEW |