OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_IO_THREAD_H_ | 5 #ifndef CHROME_BROWSER_IO_THREAD_H_ |
6 #define CHROME_BROWSER_IO_THREAD_H_ | 6 #define CHROME_BROWSER_IO_THREAD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... | |
32 class ProxyScriptFetcher; | 32 class ProxyScriptFetcher; |
33 class URLSecurityManager; | 33 class URLSecurityManager; |
34 } // namespace net | 34 } // namespace net |
35 | 35 |
36 class IOThread : public BrowserProcessSubThread { | 36 class IOThread : public BrowserProcessSubThread { |
37 public: | 37 public: |
38 struct Globals { | 38 struct Globals { |
39 Globals(); | 39 Globals(); |
40 ~Globals(); | 40 ~Globals(); |
41 | 41 |
42 scoped_ptr<ChromeNetLog> net_log; | |
43 scoped_ptr<net::HostResolver> host_resolver; | 42 scoped_ptr<net::HostResolver> host_resolver; |
44 scoped_ptr<net::DnsRRResolver> dnsrr_resolver; | 43 scoped_ptr<net::DnsRRResolver> dnsrr_resolver; |
45 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory; | 44 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory; |
46 scoped_ptr<net::URLSecurityManager> url_security_manager; | 45 scoped_ptr<net::URLSecurityManager> url_security_manager; |
47 ChromeNetworkDelegate network_delegate; | 46 ChromeNetworkDelegate network_delegate; |
48 }; | 47 }; |
49 | 48 |
50 IOThread(); | 49 explicit IOThread(ChromeNetLog* net_log); |
eroman
2010/11/16 17:51:14
Please describe ownership model (i.e. net_log must
| |
51 | 50 |
52 virtual ~IOThread(); | 51 virtual ~IOThread(); |
53 | 52 |
54 // Can only be called on the IO thread. | 53 // Can only be called on the IO thread. |
55 Globals* globals(); | 54 Globals* globals(); |
56 | 55 |
56 ChromeNetLog* net_log(); | |
57 | |
57 // Initializes the network predictor, which induces DNS pre-resolution and/or | 58 // Initializes the network predictor, which induces DNS pre-resolution and/or |
58 // TCP/IP preconnections. |prefetching_enabled| indicates whether or not DNS | 59 // TCP/IP preconnections. |prefetching_enabled| indicates whether or not DNS |
59 // prefetching should be enabled, and |preconnect_enabled| controls whether | 60 // prefetching should be enabled, and |preconnect_enabled| controls whether |
60 // TCP/IP preconnection is enabled. This should be called by the UI thread. | 61 // TCP/IP preconnection is enabled. This should be called by the UI thread. |
61 // It will post a task to the IO thread to perform the actual initialization. | 62 // It will post a task to the IO thread to perform the actual initialization. |
62 void InitNetworkPredictor(bool prefetching_enabled, | 63 void InitNetworkPredictor(bool prefetching_enabled, |
63 base::TimeDelta max_dns_queue_delay, | 64 base::TimeDelta max_dns_queue_delay, |
64 size_t max_speculative_parallel_resolves, | 65 size_t max_speculative_parallel_resolves, |
65 const chrome_common_net::UrlList& startup_urls, | 66 const chrome_common_net::UrlList& startup_urls, |
66 ListValue* referral_list, | 67 ListValue* referral_list, |
(...skipping 28 matching lines...) Expand all Loading... | |
95 size_t max_speculative_parallel_resolves, | 96 size_t max_speculative_parallel_resolves, |
96 const chrome_common_net::UrlList& startup_urls, | 97 const chrome_common_net::UrlList& startup_urls, |
97 ListValue* referral_list, | 98 ListValue* referral_list, |
98 bool preconnect_enabled); | 99 bool preconnect_enabled); |
99 | 100 |
100 void ChangedToOnTheRecordOnIOThread(); | 101 void ChangedToOnTheRecordOnIOThread(); |
101 | 102 |
102 // These member variables are basically global, but their lifetimes are tied | 103 // These member variables are basically global, but their lifetimes are tied |
103 // to the IOThread. IOThread owns them all, despite not using scoped_ptr. | 104 // to the IOThread. IOThread owns them all, despite not using scoped_ptr. |
104 // This is because the destructor of IOThread runs on the wrong thread. All | 105 // This is because the destructor of IOThread runs on the wrong thread. All |
105 // member variables should be deleted in CleanUp(), except ChromeNetLog | 106 // member variables should be deleted in CleanUp(). |
106 // which is deleted later in CleanUpAfterMessageLoopDestruction(). | |
107 | 107 |
108 // These member variables are initialized in Init() and do not change for the | 108 // These member variables are initialized in Init() and do not change for the |
109 // lifetime of the IO thread. | 109 // lifetime of the IO thread. |
110 | 110 |
111 Globals* globals_; | 111 Globals* globals_; |
112 | 112 |
113 // This variable is only meaningful during shutdown. It is used to defer | |
114 // deletion of the NetLog to CleanUpAfterMessageLoopDestruction() even | |
115 // though |globals_| is reset by CleanUp(). | |
116 scoped_ptr<ChromeNetLog> deferred_net_log_to_delete_; | |
117 | |
118 // Observer that logs network changes to the ChromeNetLog. | 113 // Observer that logs network changes to the ChromeNetLog. |
119 scoped_ptr<net::NetworkChangeNotifier::Observer> network_change_observer_; | 114 scoped_ptr<net::NetworkChangeNotifier::Observer> network_change_observer_; |
120 | 115 |
121 // These member variables are initialized by a task posted to the IO thread, | 116 // These member variables are initialized by a task posted to the IO thread, |
122 // which gets posted by calling certain member functions of IOThread. | 117 // which gets posted by calling certain member functions of IOThread. |
123 | 118 |
124 // Note: we user explicit pointers rather than smart pointers to be more | 119 // Note: we user explicit pointers rather than smart pointers to be more |
125 // explicit about destruction order, and ensure that there is no chance that | 120 // explicit about destruction order, and ensure that there is no chance that |
126 // these observers would be used accidentally after we have begun to tear | 121 // these observers would be used accidentally after we have begun to tear |
127 // down. | 122 // down. |
128 chrome_browser_net::ConnectInterceptor* speculative_interceptor_; | 123 chrome_browser_net::ConnectInterceptor* speculative_interceptor_; |
129 chrome_browser_net::Predictor* predictor_; | 124 chrome_browser_net::Predictor* predictor_; |
130 | 125 |
131 // List of live ProxyScriptFetchers. | 126 // List of live ProxyScriptFetchers. |
132 ProxyScriptFetchers fetchers_; | 127 ProxyScriptFetchers fetchers_; |
133 | 128 |
129 // The NetLog is owned by the browser process, to allow logging from other | |
130 // threads during shutdown, but is used most frequently on the IOThread. | |
131 ChromeNetLog* net_log_; | |
132 | |
134 DISALLOW_COPY_AND_ASSIGN(IOThread); | 133 DISALLOW_COPY_AND_ASSIGN(IOThread); |
135 }; | 134 }; |
136 | 135 |
137 #endif // CHROME_BROWSER_IO_THREAD_H_ | 136 #endif // CHROME_BROWSER_IO_THREAD_H_ |
OLD | NEW |