| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_CHROME_URL_REQUEST_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 6 #define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class Profile; | 34 class Profile; |
| 35 | 35 |
| 36 namespace net { | 36 namespace net { |
| 37 class DnsCertProvenanceChecker; | 37 class DnsCertProvenanceChecker; |
| 38 class NetworkDelegate; | 38 class NetworkDelegate; |
| 39 } | 39 } |
| 40 | 40 |
| 41 class ChromeURLRequestContext; | 41 class ChromeURLRequestContext; |
| 42 class ChromeURLRequestContextFactory; | 42 class ChromeURLRequestContextFactory; |
| 43 | 43 |
| 44 // Subclass of URLRequestContext which can be used to store extra information | 44 // Subclass of net::URLRequestContext which can be used to store extra |
| 45 // for requests. | 45 // information for requests. |
| 46 // | 46 // |
| 47 // All methods of this class must be called from the IO thread, | 47 // All methods of this class must be called from the IO thread, |
| 48 // including the constructor and destructor. | 48 // including the constructor and destructor. |
| 49 class ChromeURLRequestContext : public net::URLRequestContext { | 49 class ChromeURLRequestContext : public net::URLRequestContext { |
| 50 public: | 50 public: |
| 51 ChromeURLRequestContext(); | 51 ChromeURLRequestContext(); |
| 52 | 52 |
| 53 // Gets the path to the directory user scripts are stored in. | 53 // Gets the path to the directory user scripts are stored in. |
| 54 FilePath user_script_dir_path() const { | 54 FilePath user_script_dir_path() const { |
| 55 return user_script_dir_path_; | 55 return user_script_dir_path_; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 scoped_refptr<PrerenderManager> prerender_manager_; | 196 scoped_refptr<PrerenderManager> prerender_manager_; |
| 197 | 197 |
| 198 bool is_media_; | 198 bool is_media_; |
| 199 bool is_off_the_record_; | 199 bool is_off_the_record_; |
| 200 | 200 |
| 201 private: | 201 private: |
| 202 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); | 202 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 // A URLRequestContextGetter subclass used by the browser. This returns a | 205 // A URLRequestContextGetter subclass used by the browser. This returns a |
| 206 // subclass of URLRequestContext which can be used to store extra information | 206 // subclass of net::URLRequestContext which can be used to store extra |
| 207 // about requests. | 207 // information about requests. |
| 208 // | 208 // |
| 209 // Most methods are expected to be called on the UI thread, except for | 209 // Most methods are expected to be called on the UI thread, except for |
| 210 // the destructor and GetURLRequestContext(). | 210 // the destructor and GetURLRequestContext(). |
| 211 class ChromeURLRequestContextGetter : public URLRequestContextGetter, | 211 class ChromeURLRequestContextGetter : public URLRequestContextGetter, |
| 212 public NotificationObserver { | 212 public NotificationObserver { |
| 213 public: | 213 public: |
| 214 // Constructs a ChromeURLRequestContextGetter that will use |factory| to | 214 // Constructs a ChromeURLRequestContextGetter that will use |factory| to |
| 215 // create the ChromeURLRequestContext. If |profile| is non-NULL, then the | 215 // create the ChromeURLRequestContext. If |profile| is non-NULL, then the |
| 216 // ChromeURLRequestContextGetter will additionally watch the preferences for | 216 // ChromeURLRequestContextGetter will additionally watch the preferences for |
| 217 // changes to charset/language and CleanupOnUIThread() will need to be | 217 // changes to charset/language and CleanupOnUIThread() will need to be |
| 218 // called to unregister. | 218 // called to unregister. |
| 219 ChromeURLRequestContextGetter(Profile* profile, | 219 ChromeURLRequestContextGetter(Profile* profile, |
| 220 ChromeURLRequestContextFactory* factory); | 220 ChromeURLRequestContextFactory* factory); |
| 221 | 221 |
| 222 // Note that GetURLRequestContext() can only be called from the IO | 222 // Note that GetURLRequestContext() can only be called from the IO |
| 223 // thread (it will assert otherwise). GetCookieStore() and | 223 // thread (it will assert otherwise). GetCookieStore() and |
| 224 // GetIOMessageLoopProxy however can be called from any thread. | 224 // GetIOMessageLoopProxy however can be called from any thread. |
| 225 // | 225 // |
| 226 // URLRequestContextGetter implementation. | 226 // URLRequestContextGetter implementation. |
| 227 virtual net::URLRequestContext* GetURLRequestContext(); | 227 virtual net::URLRequestContext* GetURLRequestContext(); |
| 228 virtual net::CookieStore* GetCookieStore(); | 228 virtual net::CookieStore* GetCookieStore(); |
| 229 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; | 229 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; |
| 230 | 230 |
| 231 // Releases |url_request_context_|. It's invalid to call | 231 // Releases |url_request_context_|. It's invalid to call |
| 232 // GetURLRequestContext() after this point. | 232 // GetURLRequestContext() after this point. |
| 233 void ReleaseURLRequestContext(); | 233 void ReleaseURLRequestContext(); |
| 234 | 234 |
| 235 // Convenience overload of GetURLRequestContext() that returns a | 235 // Convenience overload of GetURLRequestContext() that returns a |
| 236 // ChromeURLRequestContext* rather than a URLRequestContext*. | 236 // ChromeURLRequestContext* rather than a net::URLRequestContext*. |
| 237 ChromeURLRequestContext* GetIOContext() { | 237 ChromeURLRequestContext* GetIOContext() { |
| 238 return reinterpret_cast<ChromeURLRequestContext*>(GetURLRequestContext()); | 238 return reinterpret_cast<ChromeURLRequestContext*>(GetURLRequestContext()); |
| 239 } | 239 } |
| 240 | 240 |
| 241 // Create an instance for use with an 'original' (non-OTR) profile. This is | 241 // Create an instance for use with an 'original' (non-OTR) profile. This is |
| 242 // expected to get called on the UI thread. | 242 // expected to get called on the UI thread. |
| 243 static ChromeURLRequestContextGetter* CreateOriginal( | 243 static ChromeURLRequestContextGetter* CreateOriginal( |
| 244 Profile* profile, const FilePath& cookie_store_path, | 244 Profile* profile, const FilePath& cookie_store_path, |
| 245 const FilePath& disk_cache_path, int cache_size); | 245 const FilePath& disk_cache_path, int cache_size); |
| 246 | 246 |
| 247 // Create an instance for an original profile for media. This is expected to | 247 // Create an instance for an original profile for media. This is expected to |
| 248 // get called on UI thread. This method takes a profile and reuses the | 248 // get called on UI thread. This method takes a profile and reuses the |
| 249 // 'original' URLRequestContext for common files. | 249 // 'original' net::URLRequestContext for common files. |
| 250 static ChromeURLRequestContextGetter* CreateOriginalForMedia( | 250 static ChromeURLRequestContextGetter* CreateOriginalForMedia( |
| 251 Profile* profile, const FilePath& disk_cache_path, int cache_size); | 251 Profile* profile, const FilePath& disk_cache_path, int cache_size); |
| 252 | 252 |
| 253 // Create an instance for an original profile for extensions. This is expected | 253 // Create an instance for an original profile for extensions. This is expected |
| 254 // to get called on UI thread. | 254 // to get called on UI thread. |
| 255 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( | 255 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( |
| 256 Profile* profile, const FilePath& cookie_store_path); | 256 Profile* profile, const FilePath& cookie_store_path); |
| 257 | 257 |
| 258 // Create an instance for use with an OTR profile. This is expected to get | 258 // Create an instance for use with an OTR profile. This is expected to get |
| 259 // called on the UI thread. | 259 // called on the UI thread. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 PrefChangeRegistrar registrar_; | 301 PrefChangeRegistrar registrar_; |
| 302 | 302 |
| 303 // |io_thread_| is always valid during the lifetime of |this| since |this| is | 303 // |io_thread_| is always valid during the lifetime of |this| since |this| is |
| 304 // deleted on the IO thread. | 304 // deleted on the IO thread. |
| 305 IOThread* const io_thread_; | 305 IOThread* const io_thread_; |
| 306 | 306 |
| 307 // Deferred logic for creating a ChromeURLRequestContext. | 307 // Deferred logic for creating a ChromeURLRequestContext. |
| 308 // Access only from the IO thread. | 308 // Access only from the IO thread. |
| 309 scoped_ptr<ChromeURLRequestContextFactory> factory_; | 309 scoped_ptr<ChromeURLRequestContextFactory> factory_; |
| 310 | 310 |
| 311 // NULL if not yet initialized. Otherwise, it is the URLRequestContext | 311 // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext |
| 312 // instance that was lazilly created by GetURLRequestContext. | 312 // instance that was lazilly created by GetURLRequestContext. |
| 313 // Access only from the IO thread. | 313 // Access only from the IO thread. |
| 314 scoped_refptr<net::URLRequestContext> url_request_context_; | 314 scoped_refptr<net::URLRequestContext> url_request_context_; |
| 315 | 315 |
| 316 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); | 316 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); |
| 317 }; | 317 }; |
| 318 | 318 |
| 319 // Base class for a ChromeURLRequestContext factory. This includes | 319 // Base class for a ChromeURLRequestContext factory. This includes |
| 320 // the shared functionality like extracting the default language/charset | 320 // the shared functionality like extracting the default language/charset |
| 321 // from a profile. | 321 // from a profile. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 | 368 |
| 369 FilePath profile_dir_path_; | 369 FilePath profile_dir_path_; |
| 370 | 370 |
| 371 private: | 371 private: |
| 372 IOThread* const io_thread_; | 372 IOThread* const io_thread_; |
| 373 | 373 |
| 374 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory); | 374 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory); |
| 375 }; | 375 }; |
| 376 | 376 |
| 377 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 377 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |