| 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_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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/prefs/pref_change_registrar.h" | 11 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 #include "net/url_request/url_request_context.h" | 14 #include "net/url_request/url_request_context.h" |
| 15 #include "net/url_request/url_request_context_getter.h" | 15 #include "net/url_request/url_request_context_getter.h" |
| 16 | 16 |
| 17 class ChromeURLDataManagerBackend; | 17 class ChromeURLDataManagerBackend; |
| 18 class ChromeURLRequestContextFactory; | 18 class ChromeURLRequestContextFactory; |
| 19 class IOThread; | 19 class IOThread; |
| 20 class Profile; | 20 class Profile; |
| 21 class ProfileIOData; | 21 class ProfileIOData; |
| 22 | 22 |
| 23 namespace chrome_browser_net { | 23 namespace chrome_browser_net { |
| 24 class CacheStats; | 24 class LoadTimeStats; |
| 25 } | 25 } |
| 26 | 26 |
| 27 // Subclass of net::URLRequestContext which can be used to store extra | 27 // Subclass of net::URLRequestContext which can be used to store extra |
| 28 // information for requests. | 28 // information for requests. |
| 29 // | 29 // |
| 30 // All methods of this class must be called from the IO thread, | 30 // All methods of this class must be called from the IO thread, |
| 31 // including the constructor and destructor. | 31 // including the constructor and destructor. |
| 32 class ChromeURLRequestContext : public net::URLRequestContext { | 32 class ChromeURLRequestContext : public net::URLRequestContext { |
| 33 public: | 33 public: |
| 34 enum ContextType { | 34 enum ContextType { |
| 35 CONTEXT_TYPE_MAIN, | 35 CONTEXT_TYPE_MAIN, |
| 36 CONTEXT_TYPE_MEDIA, | 36 CONTEXT_TYPE_MEDIA, |
| 37 CONTEXT_TYPE_EXTENSIONS, | 37 CONTEXT_TYPE_EXTENSIONS, |
| 38 CONTEXT_TYPE_APP | 38 CONTEXT_TYPE_APP |
| 39 }; | 39 }; |
| 40 ChromeURLRequestContext(ContextType type, | 40 ChromeURLRequestContext(ContextType type, |
| 41 chrome_browser_net::CacheStats* cache_stats); | 41 chrome_browser_net::LoadTimeStats* load_time_stats); |
| 42 virtual ~ChromeURLRequestContext(); | 42 virtual ~ChromeURLRequestContext(); |
| 43 | 43 |
| 44 base::WeakPtr<ChromeURLRequestContext> GetWeakPtr() { | 44 base::WeakPtr<ChromeURLRequestContext> GetWeakPtr() { |
| 45 return weak_factory_.GetWeakPtr(); | 45 return weak_factory_.GetWeakPtr(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Copies the state from |other| into this context. | 48 // Copies the state from |other| into this context. |
| 49 void CopyFrom(ChromeURLRequestContext* other); | 49 void CopyFrom(ChromeURLRequestContext* other); |
| 50 | 50 |
| 51 bool is_incognito() const { | 51 bool is_incognito() const { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 74 private: | 74 private: |
| 75 base::WeakPtrFactory<ChromeURLRequestContext> weak_factory_; | 75 base::WeakPtrFactory<ChromeURLRequestContext> weak_factory_; |
| 76 | 76 |
| 77 // --------------------------------------------------------------------------- | 77 // --------------------------------------------------------------------------- |
| 78 // Important: When adding any new members below, consider whether they need to | 78 // Important: When adding any new members below, consider whether they need to |
| 79 // be added to CopyFrom. | 79 // be added to CopyFrom. |
| 80 // --------------------------------------------------------------------------- | 80 // --------------------------------------------------------------------------- |
| 81 | 81 |
| 82 ChromeURLDataManagerBackend* chrome_url_data_manager_backend_; | 82 ChromeURLDataManagerBackend* chrome_url_data_manager_backend_; |
| 83 bool is_incognito_; | 83 bool is_incognito_; |
| 84 chrome_browser_net::CacheStats* cache_stats_; | 84 chrome_browser_net::LoadTimeStats* load_time_stats_; |
| 85 | 85 |
| 86 // --------------------------------------------------------------------------- | 86 // --------------------------------------------------------------------------- |
| 87 // Important: When adding any new members above, consider whether they need to | 87 // Important: When adding any new members above, consider whether they need to |
| 88 // be added to CopyFrom. | 88 // be added to CopyFrom. |
| 89 // --------------------------------------------------------------------------- | 89 // --------------------------------------------------------------------------- |
| 90 | 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); | 91 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 // A net::URLRequestContextGetter subclass used by the browser. This returns a | 94 // A net::URLRequestContextGetter subclass used by the browser. This returns a |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 // NULL if not yet initialized. Otherwise, it is the ChromeURLRequestContext | 194 // NULL if not yet initialized. Otherwise, it is the ChromeURLRequestContext |
| 195 // instance that was lazily created by GetURLRequestContext(). | 195 // instance that was lazily created by GetURLRequestContext(). |
| 196 // Access only from the IO thread. | 196 // Access only from the IO thread. |
| 197 base::WeakPtr<ChromeURLRequestContext> url_request_context_; | 197 base::WeakPtr<ChromeURLRequestContext> url_request_context_; |
| 198 | 198 |
| 199 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); | 199 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); |
| 200 }; | 200 }; |
| 201 | 201 |
| 202 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 202 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |