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

Side by Side Diff: chrome/test/base/testing_profile.h

Issue 9419033: Move creation of BrowserContext objects that live in content to content, instead of depending on th… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fix memory leaks in tests Created 8 years, 10 months 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
« no previous file with comments | « chrome/test/base/browser_with_test_window_test.cc ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_TEST_BASE_TESTING_PROFILE_H_ 5 #ifndef CHROME_TEST_BASE_TESTING_PROFILE_H_
6 #define CHROME_TEST_BASE_TESTING_PROFILE_H_ 6 #define CHROME_TEST_BASE_TESTING_PROFILE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // Creates an ExtensionService initialized with the testing profile and 140 // Creates an ExtensionService initialized with the testing profile and
141 // returns it. The profile keeps its own copy of a scoped_refptr to the 141 // returns it. The profile keeps its own copy of a scoped_refptr to the
142 // ExtensionService to make sure that is still alive to be notified when the 142 // ExtensionService to make sure that is still alive to be notified when the
143 // profile is destroyed. 143 // profile is destroyed.
144 ExtensionService* CreateExtensionService(const CommandLine* command_line, 144 ExtensionService* CreateExtensionService(const CommandLine* command_line,
145 const FilePath& install_directory, 145 const FilePath& install_directory,
146 bool autoupdate_enabled); 146 bool autoupdate_enabled);
147 147
148 TestingPrefService* GetTestingPrefService(); 148 TestingPrefService* GetTestingPrefService();
149 149
150 // content::BrowserContext
151 virtual FilePath GetPath() OVERRIDE;
152 virtual bool IsOffTheRecord() OVERRIDE;
153 virtual content::DownloadManager* GetDownloadManager() OVERRIDE;
154 // Returns a testing ContextGetter (if one has been created via
155 // CreateRequestContext) or NULL. This is not done on-demand for two reasons:
156 // (1) Some tests depend on GetRequestContext() returning NULL. (2) Because
157 // of the special memory management considerations for the
158 // TestURLRequestContextGetter class, many tests would find themseleves
159 // leaking if they called this method without the necessary IO thread. This
160 // getter is currently only capable of returning a Context that helps test
161 // the CookieMonster. See implementation comments for more details.
162 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
163 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
164 int renderer_child_id) OVERRIDE;
165 virtual content::ResourceContext* GetResourceContext() OVERRIDE;
166 virtual content::HostZoomMap* GetHostZoomMap() OVERRIDE;
167 virtual content::GeolocationPermissionContext*
168 GetGeolocationPermissionContext() OVERRIDE;
169 virtual content::SpeechInputPreferences* GetSpeechInputPreferences() OVERRIDE;
170 virtual bool DidLastSessionExitCleanly() OVERRIDE;
171 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
172
150 virtual TestingProfile* AsTestingProfile() OVERRIDE; 173 virtual TestingProfile* AsTestingProfile() OVERRIDE;
151 virtual std::string GetProfileName() OVERRIDE; 174 virtual std::string GetProfileName() OVERRIDE;
152 virtual FilePath GetPath() OVERRIDE;
153 void set_incognito(bool incognito) { incognito_ = incognito; } 175 void set_incognito(bool incognito) { incognito_ = incognito; }
154 virtual bool IsOffTheRecord() OVERRIDE;
155 // Assumes ownership. 176 // Assumes ownership.
156 virtual void SetOffTheRecordProfile(Profile* profile); 177 virtual void SetOffTheRecordProfile(Profile* profile);
157 virtual Profile* GetOffTheRecordProfile() OVERRIDE; 178 virtual Profile* GetOffTheRecordProfile() OVERRIDE;
158 virtual void DestroyOffTheRecordProfile() OVERRIDE {} 179 virtual void DestroyOffTheRecordProfile() OVERRIDE {}
159 virtual GAIAInfoUpdateService* GetGAIAInfoUpdateService() OVERRIDE; 180 virtual GAIAInfoUpdateService* GetGAIAInfoUpdateService() OVERRIDE;
160 virtual bool HasOffTheRecordProfile() OVERRIDE; 181 virtual bool HasOffTheRecordProfile() OVERRIDE;
161 virtual Profile* GetOriginalProfile() OVERRIDE; 182 virtual Profile* GetOriginalProfile() OVERRIDE;
162 void SetAppCacheService(ChromeAppCacheService* appcache_service);
163 virtual ChromeAppCacheService* GetAppCacheService() OVERRIDE;
164 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() OVERRIDE;
165 virtual VisitedLinkMaster* GetVisitedLinkMaster() OVERRIDE; 183 virtual VisitedLinkMaster* GetVisitedLinkMaster() OVERRIDE;
166 virtual ExtensionService* GetExtensionService() OVERRIDE; 184 virtual ExtensionService* GetExtensionService() OVERRIDE;
167 virtual UserScriptMaster* GetUserScriptMaster() OVERRIDE; 185 virtual UserScriptMaster* GetUserScriptMaster() OVERRIDE;
168 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() OVERRIDE; 186 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() OVERRIDE;
169 virtual ExtensionProcessManager* GetExtensionProcessManager() OVERRIDE; 187 virtual ExtensionProcessManager* GetExtensionProcessManager() OVERRIDE;
170 virtual ExtensionMessageService* GetExtensionMessageService() OVERRIDE; 188 virtual ExtensionMessageService* GetExtensionMessageService() OVERRIDE;
171 virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE; 189 virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE;
172 void SetExtensionSpecialStoragePolicy( 190 void SetExtensionSpecialStoragePolicy(
173 ExtensionSpecialStoragePolicy* extension_special_storage_policy); 191 ExtensionSpecialStoragePolicy* extension_special_storage_policy);
174 virtual ExtensionSpecialStoragePolicy* 192 virtual ExtensionSpecialStoragePolicy*
(...skipping 12 matching lines...) Expand all
187 virtual PasswordStore* GetPasswordStore(ServiceAccessType access) OVERRIDE; 205 virtual PasswordStore* GetPasswordStore(ServiceAccessType access) OVERRIDE;
188 // Sets the profile's PrefService. If a pref service hasn't been explicitly 206 // Sets the profile's PrefService. If a pref service hasn't been explicitly
189 // set GetPrefs creates one, so normally you need not invoke this. If you need 207 // set GetPrefs creates one, so normally you need not invoke this. If you need
190 // to set a pref service you must invoke this before GetPrefs. 208 // to set a pref service you must invoke this before GetPrefs.
191 // TestingPrefService takes ownership of |prefs|. 209 // TestingPrefService takes ownership of |prefs|.
192 void SetPrefService(PrefService* prefs); 210 void SetPrefService(PrefService* prefs);
193 virtual PrefService* GetPrefs() OVERRIDE; 211 virtual PrefService* GetPrefs() OVERRIDE;
194 virtual TemplateURLFetcher* GetTemplateURLFetcher() OVERRIDE; 212 virtual TemplateURLFetcher* GetTemplateURLFetcher() OVERRIDE;
195 virtual history::TopSites* GetTopSites() OVERRIDE; 213 virtual history::TopSites* GetTopSites() OVERRIDE;
196 virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE; 214 virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE;
197 virtual content::DownloadManager* GetDownloadManager() OVERRIDE;
198 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE;
199 virtual void SetQuotaManager(quota::QuotaManager* manager);
200 virtual quota::QuotaManager* GetQuotaManager() OVERRIDE;
201 215
202 // Returns a testing ContextGetter (if one has been created via
203 // CreateRequestContext) or NULL. This is not done on-demand for two reasons:
204 // (1) Some tests depend on GetRequestContext() returning NULL. (2) Because
205 // of the special memory management considerations for the
206 // TestURLRequestContextGetter class, many tests would find themseleves
207 // leaking if they called this method without the necessary IO thread. This
208 // getter is currently only capable of returning a Context that helps test
209 // the CookieMonster. See implementation comments for more details.
210 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
211 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
212 int renderer_child_id) OVERRIDE;
213 void CreateRequestContext(); 216 void CreateRequestContext();
214 // Clears out the created request context (which must be done before shutting 217 // Clears out the created request context (which must be done before shutting
215 // down the IO thread to avoid leaks). 218 // down the IO thread to avoid leaks).
216 void ResetRequestContext(); 219 void ResetRequestContext();
217 220
218 virtual net::URLRequestContextGetter* GetRequestContextForMedia() OVERRIDE; 221 virtual net::URLRequestContextGetter* GetRequestContextForMedia() OVERRIDE;
219 virtual net::URLRequestContextGetter* 222 virtual net::URLRequestContextGetter*
220 GetRequestContextForExtensions() OVERRIDE; 223 GetRequestContextForExtensions() OVERRIDE;
221 virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp( 224 virtual net::URLRequestContextGetter* GetRequestContextForIsolatedApp(
222 const std::string& app_id) OVERRIDE; 225 const std::string& app_id) OVERRIDE;
223
224 virtual content::ResourceContext* GetResourceContext() OVERRIDE;
225
226 virtual net::SSLConfigService* GetSSLConfigService() OVERRIDE; 226 virtual net::SSLConfigService* GetSSLConfigService() OVERRIDE;
227 virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() OVERRIDE; 227 virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() OVERRIDE;
228 virtual HostContentSettingsMap* GetHostContentSettingsMap() OVERRIDE; 228 virtual HostContentSettingsMap* GetHostContentSettingsMap() OVERRIDE;
229 virtual content::GeolocationPermissionContext*
230 GetGeolocationPermissionContext() OVERRIDE;
231 virtual content::SpeechInputPreferences* GetSpeechInputPreferences() OVERRIDE;
232 virtual content::HostZoomMap* GetHostZoomMap() OVERRIDE;
233 virtual std::wstring GetName(); 229 virtual std::wstring GetName();
234 virtual void SetName(const std::wstring& name) {} 230 virtual void SetName(const std::wstring& name) {}
235 virtual std::wstring GetID(); 231 virtual std::wstring GetID();
236 virtual void SetID(const std::wstring& id); 232 virtual void SetID(const std::wstring& id);
237 void set_last_session_exited_cleanly(bool value) { 233 void set_last_session_exited_cleanly(bool value) {
238 last_session_exited_cleanly_ = value; 234 last_session_exited_cleanly_ = value;
239 } 235 }
240 virtual bool DidLastSessionExitCleanly() OVERRIDE;
241 virtual void MergeResourceString(int message_id, 236 virtual void MergeResourceString(int message_id,
242 std::wstring* output_string) {} 237 std::wstring* output_string) {}
243 virtual void MergeResourceInteger(int message_id, int* output_value) {} 238 virtual void MergeResourceInteger(int message_id, int* output_value) {}
244 virtual void MergeResourceBoolean(int message_id, bool* output_value) {} 239 virtual void MergeResourceBoolean(int message_id, bool* output_value) {}
245 virtual BookmarkModel* GetBookmarkModel() OVERRIDE; 240 virtual BookmarkModel* GetBookmarkModel() OVERRIDE;
246 virtual bool IsSameProfile(Profile *p) OVERRIDE; 241 virtual bool IsSameProfile(Profile *p) OVERRIDE;
247 virtual base::Time GetStartTime() const OVERRIDE; 242 virtual base::Time GetStartTime() const OVERRIDE;
248 virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE; 243 virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE;
249 virtual WebKitContext* GetWebKitContext() OVERRIDE;
250 virtual WebKitContext* GetOffTheRecordWebKitContext(); 244 virtual WebKitContext* GetOffTheRecordWebKitContext();
251 virtual void MarkAsCleanShutdown() OVERRIDE {} 245 virtual void MarkAsCleanShutdown() OVERRIDE {}
252 virtual void InitExtensions(bool extensions_enabled) OVERRIDE {} 246 virtual void InitExtensions(bool extensions_enabled) OVERRIDE {}
253 virtual void InitPromoResources() OVERRIDE {} 247 virtual void InitPromoResources() OVERRIDE {}
254 virtual void InitRegisteredProtocolHandlers() OVERRIDE {} 248 virtual void InitRegisteredProtocolHandlers() OVERRIDE {}
255 249
256 virtual FilePath last_selected_directory() OVERRIDE; 250 virtual FilePath last_selected_directory() OVERRIDE;
257 virtual void set_last_selected_directory(const FilePath& path) OVERRIDE; 251 virtual void set_last_selected_directory(const FilePath& path) OVERRIDE;
258 #if defined(OS_CHROMEOS) 252 #if defined(OS_CHROMEOS)
259 virtual void SetupChromeOSEnterpriseExtensionObserver() OVERRIDE { 253 virtual void SetupChromeOSEnterpriseExtensionObserver() OVERRIDE {
260 } 254 }
261 virtual void InitChromeOSPreferences() OVERRIDE { 255 virtual void InitChromeOSPreferences() OVERRIDE {
262 } 256 }
263 virtual void ChangeAppLocale(const std::string&, 257 virtual void ChangeAppLocale(const std::string&,
264 AppLocaleChangedVia) OVERRIDE { 258 AppLocaleChangedVia) OVERRIDE {
265 } 259 }
266 virtual void OnLogin() OVERRIDE { 260 virtual void OnLogin() OVERRIDE {
267 } 261 }
268 #endif // defined(OS_CHROMEOS) 262 #endif // defined(OS_CHROMEOS)
269 263
270 virtual PrefProxyConfigTracker* GetProxyConfigTracker() OVERRIDE; 264 virtual PrefProxyConfigTracker* GetProxyConfigTracker() OVERRIDE;
271 265
272 // Schedules a task on the history backend and runs a nested loop until the 266 // Schedules a task on the history backend and runs a nested loop until the
273 // task is processed. This has the effect of blocking the caller until the 267 // task is processed. This has the effect of blocking the caller until the
274 // history service processes all pending requests. 268 // history service processes all pending requests.
275 void BlockUntilHistoryProcessesPendingRequests(); 269 void BlockUntilHistoryProcessesPendingRequests();
276 270
277 virtual TokenService* GetTokenService() OVERRIDE; 271 virtual TokenService* GetTokenService() OVERRIDE;
278 virtual ChromeBlobStorageContext* GetBlobStorageContext() OVERRIDE;
279 virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE; 272 virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE;
280 virtual PromoCounter* GetInstantPromoCounter() OVERRIDE; 273 virtual PromoCounter* GetInstantPromoCounter() OVERRIDE;
281 virtual ChromeURLDataManager* GetChromeURLDataManager() OVERRIDE; 274 virtual ChromeURLDataManager* GetChromeURLDataManager() OVERRIDE;
282 virtual chrome_browser_net::Predictor* GetNetworkPredictor() OVERRIDE; 275 virtual chrome_browser_net::Predictor* GetNetworkPredictor() OVERRIDE;
283 virtual void ClearNetworkingHistorySince(base::Time time) OVERRIDE; 276 virtual void ClearNetworkingHistorySince(base::Time time) OVERRIDE;
284 virtual GURL GetHomePage() OVERRIDE; 277 virtual GURL GetHomePage() OVERRIDE;
285 278
286 virtual PrefService* GetOffTheRecordPrefs() OVERRIDE; 279 virtual PrefService* GetOffTheRecordPrefs() OVERRIDE;
287 280
288 // TODO(jam): remove me once webkit_context_unittest.cc doesn't use Profile
289 // and gets the quota::SpecialStoragePolicy* from whatever ends up replacing
290 // it in the content module.
291 quota::SpecialStoragePolicy* GetSpecialStoragePolicy();
292
293 protected: 281 protected:
294 base::Time start_time_; 282 base::Time start_time_;
295 scoped_ptr<PrefService> prefs_; 283 scoped_ptr<PrefService> prefs_;
296 // ref only for right type, lifecycle is managed by prefs_ 284 // ref only for right type, lifecycle is managed by prefs_
297 TestingPrefService* testing_prefs_; 285 TestingPrefService* testing_prefs_;
298 286
299 private: 287 private:
300 // Common initialization between the two constructors. 288 // Common initialization between the two constructors.
301 void Init(); 289 void Init();
302 290
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 scoped_refptr<net::URLRequestContextGetter> extensions_request_context_; 337 scoped_refptr<net::URLRequestContextGetter> extensions_request_context_;
350 338
351 std::wstring id_; 339 std::wstring id_;
352 340
353 bool incognito_; 341 bool incognito_;
354 scoped_ptr<Profile> incognito_profile_; 342 scoped_ptr<Profile> incognito_profile_;
355 343
356 // Did the last session exit cleanly? Default is true. 344 // Did the last session exit cleanly? Default is true.
357 bool last_session_exited_cleanly_; 345 bool last_session_exited_cleanly_;
358 346
359 // FileSystemContext. Created lazily by GetFileSystemContext().
360 scoped_refptr<fileapi::FileSystemContext> file_system_context_;
361
362 // WebKitContext, lazily initialized by GetWebKitContext().
363 scoped_refptr<WebKitContext> webkit_context_;
364
365 // The main database tracker for this profile.
366 // Should be used only on the file thread.
367 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_;
368
369 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; 347 scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
370 scoped_refptr<content::GeolocationPermissionContext> 348 scoped_refptr<content::GeolocationPermissionContext>
371 geolocation_permission_context_; 349 geolocation_permission_context_;
372 350
373 scoped_refptr<content::SpeechInputPreferences> speech_input_preferences_; 351 scoped_refptr<content::SpeechInputPreferences> speech_input_preferences_;
374 352
375 FilePath last_selected_directory_; 353 FilePath last_selected_directory_;
376 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. 354 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails.
377 355
378 // The Extension Preferences. Only created if CreateExtensionService is 356 // The Extension Preferences. Only created if CreateExtensionService is
(...skipping 20 matching lines...) Expand all
399 // cases. 377 // cases.
400 FilePath profile_path_; 378 FilePath profile_path_;
401 379
402 scoped_ptr<ChromeURLDataManager> chrome_url_data_manager_; 380 scoped_ptr<ChromeURLDataManager> chrome_url_data_manager_;
403 381
404 // We keep a weak pointer to the dependency manager we want to notify on our 382 // We keep a weak pointer to the dependency manager we want to notify on our
405 // death. Defaults to the Singleton implementation but overridable for 383 // death. Defaults to the Singleton implementation but overridable for
406 // testing. 384 // testing.
407 ProfileDependencyManager* profile_dependency_manager_; 385 ProfileDependencyManager* profile_dependency_manager_;
408 386
409 scoped_refptr<ChromeAppCacheService> appcache_service_;
410
411 // The QuotaManager, only available if set explicitly via SetQuotaManager.
412 scoped_refptr<quota::QuotaManager> quota_manager_;
413
414 // Weak pointer to a delegate for indicating that a profile was created. 387 // Weak pointer to a delegate for indicating that a profile was created.
415 Delegate* delegate_; 388 Delegate* delegate_;
416 }; 389 };
417 390
418 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ 391 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_
OLDNEW
« no previous file with comments | « chrome/test/base/browser_with_test_window_test.cc ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698