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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 class ProfileIOData; | 22 class ProfileIOData; |
23 | 23 |
24 // Subclass of net::URLRequestContext which can be used to store extra | 24 // Subclass of net::URLRequestContext which can be used to store extra |
25 // information for requests. | 25 // information for requests. |
26 // | 26 // |
27 // All methods of this class must be called from the IO thread, | 27 // All methods of this class must be called from the IO thread, |
28 // including the constructor and destructor. | 28 // including the constructor and destructor. |
29 class ChromeURLRequestContext : public net::URLRequestContext { | 29 class ChromeURLRequestContext : public net::URLRequestContext { |
30 public: | 30 public: |
31 ChromeURLRequestContext(); | 31 ChromeURLRequestContext(); |
| 32 virtual ~ChromeURLRequestContext(); |
| 33 |
| 34 base::WeakPtr<ChromeURLRequestContext> GetWeakPtr() { |
| 35 return weak_factory_.GetWeakPtr(); |
| 36 } |
32 | 37 |
33 // Copies the state from |other| into this context. | 38 // Copies the state from |other| into this context. |
34 void CopyFrom(ChromeURLRequestContext* other); | 39 void CopyFrom(ChromeURLRequestContext* other); |
35 | 40 |
36 bool is_incognito() const { | 41 bool is_incognito() const { |
37 return is_incognito_; | 42 return is_incognito_; |
38 } | 43 } |
39 | 44 |
40 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE; | 45 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE; |
41 | 46 |
42 // TODO(willchan): Get rid of the need for this accessor. Really, this should | 47 // TODO(willchan): Get rid of the need for this accessor. Really, this should |
43 // move completely to ProfileIOData. | 48 // move completely to ProfileIOData. |
44 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const; | 49 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const; |
45 | 50 |
46 void set_is_incognito(bool is_incognito) { | 51 void set_is_incognito(bool is_incognito) { |
47 is_incognito_ = is_incognito; | 52 is_incognito_ = is_incognito; |
48 } | 53 } |
49 | 54 |
50 void set_chrome_url_data_manager_backend( | 55 void set_chrome_url_data_manager_backend( |
51 ChromeURLDataManagerBackend* backend); | 56 ChromeURLDataManagerBackend* backend); |
52 | 57 |
53 // Callback for when the accept language changes. | 58 // Callback for when the accept language changes. |
54 void OnAcceptLanguageChange(const std::string& accept_language); | 59 void OnAcceptLanguageChange(const std::string& accept_language); |
55 | 60 |
56 // Callback for when the default charset changes. | 61 // Callback for when the default charset changes. |
57 void OnDefaultCharsetChange(const std::string& default_charset); | 62 void OnDefaultCharsetChange(const std::string& default_charset); |
58 | 63 |
59 protected: | 64 private: |
60 virtual ~ChromeURLRequestContext(); | 65 base::WeakPtrFactory<ChromeURLRequestContext> weak_factory_; |
61 | 66 |
62 private: | |
63 // --------------------------------------------------------------------------- | 67 // --------------------------------------------------------------------------- |
64 // Important: When adding any new members below, consider whether they need to | 68 // Important: When adding any new members below, consider whether they need to |
65 // be added to CopyFrom. | 69 // be added to CopyFrom. |
66 // --------------------------------------------------------------------------- | 70 // --------------------------------------------------------------------------- |
67 | 71 |
68 ChromeURLDataManagerBackend* chrome_url_data_manager_backend_; | 72 ChromeURLDataManagerBackend* chrome_url_data_manager_backend_; |
69 bool is_incognito_; | 73 bool is_incognito_; |
70 | 74 |
71 // --------------------------------------------------------------------------- | 75 // --------------------------------------------------------------------------- |
72 // Important: When adding any new members above, consider whether they need to | 76 // Important: When adding any new members above, consider whether they need to |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 void OnAcceptLanguageChange(const std::string& accept_language); | 174 void OnAcceptLanguageChange(const std::string& accept_language); |
171 void OnDefaultCharsetChange(const std::string& default_charset); | 175 void OnDefaultCharsetChange(const std::string& default_charset); |
172 void OnClearSiteDataOnExitChange(bool clear_site_data); | 176 void OnClearSiteDataOnExitChange(bool clear_site_data); |
173 | 177 |
174 PrefChangeRegistrar registrar_; | 178 PrefChangeRegistrar registrar_; |
175 | 179 |
176 // Deferred logic for creating a ChromeURLRequestContext. | 180 // Deferred logic for creating a ChromeURLRequestContext. |
177 // Access only from the IO thread. | 181 // Access only from the IO thread. |
178 scoped_ptr<ChromeURLRequestContextFactory> factory_; | 182 scoped_ptr<ChromeURLRequestContextFactory> factory_; |
179 | 183 |
180 // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext | 184 // NULL if not yet initialized. Otherwise, it is the ChromeURLRequestContext |
181 // instance that was lazily created by GetURLRequestContext(). | 185 // instance that was lazily created by GetURLRequestContext(). |
182 // Access only from the IO thread. | 186 // Access only from the IO thread. |
183 base::WeakPtr<net::URLRequestContext> url_request_context_; | 187 base::WeakPtr<ChromeURLRequestContext> url_request_context_; |
184 | 188 |
185 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); | 189 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); |
186 }; | 190 }; |
187 | 191 |
188 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 192 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
OLD | NEW |