OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
6 #define CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 6 #define CHROME_BROWSER_NET_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" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/prefs/public/pref_change_registrar.h" | 14 #include "base/prefs/public/pref_change_registrar.h" |
| 15 #include "base/prefs/public/pref_observer.h" |
15 #include "base/timer.h" | 16 #include "base/timer.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "content/public/browser/notification_observer.h" | |
18 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
19 #include "net/http/http_pipelined_host_capability.h" | 19 #include "net/http/http_pipelined_host_capability.h" |
20 #include "net/http/http_server_properties.h" | 20 #include "net/http/http_server_properties.h" |
21 #include "net/http/http_server_properties_impl.h" | 21 #include "net/http/http_server_properties_impl.h" |
22 | 22 |
23 class PrefService; | 23 class PrefService; |
24 | 24 |
25 namespace chrome_browser_net { | 25 namespace chrome_browser_net { |
26 | 26 |
27 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 13 matching lines...) Expand all Loading... |
41 // ShutdownOnUIThread must be called from UI before destruction, to release | 41 // ShutdownOnUIThread must be called from UI before destruction, to release |
42 // the prefs listeners on the UI thread. This is done from ProfileIOData. | 42 // the prefs listeners on the UI thread. This is done from ProfileIOData. |
43 // | 43 // |
44 // Update tasks from the UI thread can post safely to the IO thread, since the | 44 // Update tasks from the UI thread can post safely to the IO thread, since the |
45 // destruction order of Profile and ProfileIOData guarantees that if this | 45 // destruction order of Profile and ProfileIOData guarantees that if this |
46 // exists in UI, then a potential destruction on IO will come after any task | 46 // exists in UI, then a potential destruction on IO will come after any task |
47 // posted to IO from that method on UI. This is used to go through IO before | 47 // posted to IO from that method on UI. This is used to go through IO before |
48 // the actual update starts, and grab a WeakPtr. | 48 // the actual update starts, and grab a WeakPtr. |
49 class HttpServerPropertiesManager | 49 class HttpServerPropertiesManager |
50 : public net::HttpServerProperties, | 50 : public net::HttpServerProperties, |
51 public content::NotificationObserver { | 51 public PrefObserver { |
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 UI thread. | 55 // HttpServerPropertiesManager object. Must be constructed on the UI thread. |
56 explicit HttpServerPropertiesManager(PrefService* pref_service); | 56 explicit HttpServerPropertiesManager(PrefService* pref_service); |
57 virtual ~HttpServerPropertiesManager(); | 57 virtual ~HttpServerPropertiesManager(); |
58 | 58 |
59 // Initialize |http_server_properties_impl_| and |io_method_factory_| on IO | 59 // Initialize |http_server_properties_impl_| and |io_method_factory_| on IO |
60 // thread. It also posts a task to UI thread to get SPDY Server preferences | 60 // thread. It also posts a task to UI thread to get SPDY Server preferences |
61 // from |pref_service_|. | 61 // from |pref_service_|. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // Update prefs::kHttpServerProperties preferences on UI thread. Protected for | 180 // Update prefs::kHttpServerProperties preferences on UI thread. Protected for |
181 // testing. | 181 // testing. |
182 void UpdatePrefsOnUI( | 182 void UpdatePrefsOnUI( |
183 base::ListValue* spdy_server_list, | 183 base::ListValue* spdy_server_list, |
184 net::SpdySettingsMap* spdy_settings_map, | 184 net::SpdySettingsMap* spdy_settings_map, |
185 net::AlternateProtocolMap* alternate_protocol_map, | 185 net::AlternateProtocolMap* alternate_protocol_map, |
186 net::PipelineCapabilityMap* pipeline_capability_map); | 186 net::PipelineCapabilityMap* pipeline_capability_map); |
187 | 187 |
188 private: | 188 private: |
189 // Callback for preference changes. | 189 // Callback for preference changes. |
190 virtual void Observe(int type, | 190 virtual void OnPreferenceChanged(PrefServiceBase* service, |
191 const content::NotificationSource& source, | 191 const std::string& pref_name) OVERRIDE; |
192 const content::NotificationDetails& details) OVERRIDE; | |
193 | 192 |
194 // --------- | 193 // --------- |
195 // UI thread | 194 // UI thread |
196 // --------- | 195 // --------- |
197 | 196 |
198 // Used to get |weak_ptr_| to self on the UI thread. | 197 // Used to get |weak_ptr_| to self on the UI thread. |
199 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > | 198 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > |
200 ui_weak_ptr_factory_; | 199 ui_weak_ptr_factory_; |
201 | 200 |
202 base::WeakPtr<HttpServerPropertiesManager> ui_weak_ptr_; | 201 base::WeakPtr<HttpServerPropertiesManager> ui_weak_ptr_; |
(...skipping 16 matching lines...) Expand all Loading... |
219 io_prefs_update_timer_; | 218 io_prefs_update_timer_; |
220 | 219 |
221 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; | 220 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_impl_; |
222 | 221 |
223 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 222 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
224 }; | 223 }; |
225 | 224 |
226 } // namespace chrome_browser_net | 225 } // namespace chrome_browser_net |
227 | 226 |
228 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 227 #endif // CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
OLD | NEW |