Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Side by Side Diff: chrome/browser/net/chrome_url_request_context.h

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable test for chrome_frame_net_tests Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/prefs/public/pref_change_registrar.h"
12 #include "base/prefs/public/pref_observer.h"
13 #include "net/url_request/url_request_context.h" 11 #include "net/url_request/url_request_context.h"
14 #include "net/url_request/url_request_context_getter.h" 12 #include "net/url_request/url_request_context_getter.h"
15 #include "net/url_request/url_request_job_factory.h" 13 #include "net/url_request/url_request_job_factory.h"
16 14
17 class ChromeURLDataManagerBackend; 15 class ChromeURLDataManagerBackend;
18 class ChromeURLRequestContextFactory; 16 class ChromeURLRequestContextFactory;
19 class IOThread; 17 class IOThread;
20 class Profile; 18 class Profile;
21 class ProfileIOData; 19 class ProfileIOData;
22 struct StoragePartitionDescriptor; 20 struct StoragePartitionDescriptor;
(...skipping 23 matching lines...) Expand all
46 return weak_factory_.GetWeakPtr(); 44 return weak_factory_.GetWeakPtr();
47 } 45 }
48 46
49 // Copies the state from |other| into this context. 47 // Copies the state from |other| into this context.
50 void CopyFrom(ChromeURLRequestContext* other); 48 void CopyFrom(ChromeURLRequestContext* other);
51 49
52 bool is_incognito() const { 50 bool is_incognito() const {
53 return is_incognito_; 51 return is_incognito_;
54 } 52 }
55 53
56 virtual const std::string& GetUserAgent(const GURL& url) const OVERRIDE;
57
58 // TODO(willchan): Get rid of the need for this accessor. Really, this should 54 // TODO(willchan): Get rid of the need for this accessor. Really, this should
59 // move completely to ProfileIOData. 55 // move completely to ProfileIOData.
60 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const; 56 ChromeURLDataManagerBackend* chrome_url_data_manager_backend() const;
61 57
62 void set_is_incognito(bool is_incognito) { 58 void set_is_incognito(bool is_incognito) {
63 is_incognito_ = is_incognito; 59 is_incognito_ = is_incognito;
64 } 60 }
65 61
66 void set_chrome_url_data_manager_backend( 62 void set_chrome_url_data_manager_backend(
67 ChromeURLDataManagerBackend* backend); 63 ChromeURLDataManagerBackend* backend);
68 64
69 // Callback for when the accept language changes.
70 void OnAcceptLanguageChange(const std::string& accept_language);
71
72 // Callback for when the default charset changes.
73 void OnDefaultCharsetChange(const std::string& default_charset);
74
75 private: 65 private:
76 base::WeakPtrFactory<ChromeURLRequestContext> weak_factory_; 66 base::WeakPtrFactory<ChromeURLRequestContext> weak_factory_;
77 67
78 // --------------------------------------------------------------------------- 68 // ---------------------------------------------------------------------------
79 // Important: When adding any new members below, consider whether they need to 69 // Important: When adding any new members below, consider whether they need to
80 // be added to CopyFrom. 70 // be added to CopyFrom.
81 // --------------------------------------------------------------------------- 71 // ---------------------------------------------------------------------------
82 72
83 ChromeURLDataManagerBackend* chrome_url_data_manager_backend_; 73 ChromeURLDataManagerBackend* chrome_url_data_manager_backend_;
84 bool is_incognito_; 74 bool is_incognito_;
85 chrome_browser_net::LoadTimeStats* load_time_stats_; 75 chrome_browser_net::LoadTimeStats* load_time_stats_;
86 76
87 // --------------------------------------------------------------------------- 77 // ---------------------------------------------------------------------------
88 // Important: When adding any new members above, consider whether they need to 78 // Important: When adding any new members above, consider whether they need to
89 // be added to CopyFrom. 79 // be added to CopyFrom.
90 // --------------------------------------------------------------------------- 80 // ---------------------------------------------------------------------------
91 81
92 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); 82 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext);
93 }; 83 };
94 84
95 // A net::URLRequestContextGetter subclass used by the browser. This returns a 85 // A net::URLRequestContextGetter subclass used by the browser. This returns a
96 // subclass of net::URLRequestContext which can be used to store extra 86 // subclass of net::URLRequestContext which can be used to store extra
97 // information about requests. 87 // information about requests.
98 // 88 //
99 // Most methods are expected to be called on the UI thread, except for 89 // Most methods are expected to be called on the UI thread, except for
100 // the destructor and GetURLRequestContext(). 90 // the destructor and GetURLRequestContext().
101 class ChromeURLRequestContextGetter : public net::URLRequestContextGetter, 91 class ChromeURLRequestContextGetter : public net::URLRequestContextGetter {
102 public PrefObserver {
103 public: 92 public:
104 // Constructs a ChromeURLRequestContextGetter that will use |factory| to 93 // Constructs a ChromeURLRequestContextGetter that will use |factory| to
105 // create the ChromeURLRequestContext. If |profile| is non-NULL, then the 94 // create the ChromeURLRequestContext.
106 // ChromeURLRequestContextGetter will additionally watch the preferences for 95 explicit ChromeURLRequestContextGetter(
107 // changes to charset/language and CleanupOnUIThread() will need to be 96 ChromeURLRequestContextFactory* factory);
108 // called to unregister.
109 ChromeURLRequestContextGetter(Profile* profile,
110 ChromeURLRequestContextFactory* factory);
111 97
112 // Note that GetURLRequestContext() can only be called from the IO 98 // Note that GetURLRequestContext() can only be called from the IO
113 // thread (it will assert otherwise). 99 // thread (it will assert otherwise).
114 // GetIOMessageLoopProxy however can be called from any thread. 100 // GetIOMessageLoopProxy however can be called from any thread.
115 // 101 //
116 // net::URLRequestContextGetter implementation. 102 // net::URLRequestContextGetter implementation.
117 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; 103 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
118 virtual scoped_refptr<base::SingleThreadTaskRunner> 104 virtual scoped_refptr<base::SingleThreadTaskRunner>
119 GetNetworkTaskRunner() const OVERRIDE; 105 GetNetworkTaskRunner() const OVERRIDE;
120 106
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 155
170 // Create an instance for an OTR profile for an app with isolated storage. 156 // Create an instance for an OTR profile for an app with isolated storage.
171 // This is expected to get called on UI thread. 157 // This is expected to get called on UI thread.
172 static ChromeURLRequestContextGetter* CreateOffTheRecordForIsolatedApp( 158 static ChromeURLRequestContextGetter* CreateOffTheRecordForIsolatedApp(
173 Profile* profile, 159 Profile* profile,
174 const ProfileIOData* profile_io_data, 160 const ProfileIOData* profile_io_data,
175 const StoragePartitionDescriptor& partition_descriptor, 161 const StoragePartitionDescriptor& partition_descriptor,
176 scoped_ptr<net::URLRequestJobFactory::Interceptor> 162 scoped_ptr<net::URLRequestJobFactory::Interceptor>
177 protocol_handler_interceptor); 163 protocol_handler_interceptor);
178 164
179 // Clean up UI thread resources. This is expected to get called on the UI
180 // thread before the instance is deleted on the IO thread.
181 void CleanupOnUIThread();
182
183 // PrefObserver implementation.
184 virtual void OnPreferenceChanged(PrefServiceBase* service,
185 const std::string& pref_name) OVERRIDE;
186
187 private: 165 private:
188 // Must be called on the IO thread.
189 virtual ~ChromeURLRequestContextGetter(); 166 virtual ~ChromeURLRequestContextGetter();
190 167
191 // Registers an observer on |profile|'s preferences which will be used
192 // to update the context when the default language and charset change.
193 void RegisterPrefsObserver(Profile* profile);
194
195 // These methods simply forward to the corresponding method on
196 // ChromeURLRequestContext.
197 void OnAcceptLanguageChange(const std::string& accept_language);
198 void OnDefaultCharsetChange(const std::string& default_charset);
199
200 PrefChangeRegistrar registrar_;
201
202 // Deferred logic for creating a ChromeURLRequestContext. 168 // Deferred logic for creating a ChromeURLRequestContext.
203 // Access only from the IO thread. 169 // Access only from the IO thread.
204 scoped_ptr<ChromeURLRequestContextFactory> factory_; 170 scoped_ptr<ChromeURLRequestContextFactory> factory_;
205 171
206 // NULL if not yet initialized. Otherwise, it is the ChromeURLRequestContext 172 // NULL if not yet initialized. Otherwise, it is the ChromeURLRequestContext
207 // instance that was lazily created by GetURLRequestContext(). 173 // instance that was lazily created by GetURLRequestContext().
208 // Access only from the IO thread. 174 // Access only from the IO thread.
209 base::WeakPtr<ChromeURLRequestContext> url_request_context_; 175 base::WeakPtr<ChromeURLRequestContext> url_request_context_;
210 176
211 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); 177 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter);
212 }; 178 };
213 179
214 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ 180 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_http_user_agent_settings.cc ('k') | chrome/browser/net/chrome_url_request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698