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

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

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments. merge to ToT. Murder a DB thread and more TestBrowserThreads. Created 7 years, 5 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
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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 void BlockUntilTopSitesLoaded(); 167 void BlockUntilTopSitesLoaded();
168 168
169 TestingPrefServiceSyncable* GetTestingPrefService(); 169 TestingPrefServiceSyncable* GetTestingPrefService();
170 170
171 // content::BrowserContext 171 // content::BrowserContext
172 virtual base::FilePath GetPath() OVERRIDE; 172 virtual base::FilePath GetPath() OVERRIDE;
173 virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE; 173 virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE;
174 virtual bool IsOffTheRecord() const OVERRIDE; 174 virtual bool IsOffTheRecord() const OVERRIDE;
175 virtual content::DownloadManagerDelegate* 175 virtual content::DownloadManagerDelegate*
176 GetDownloadManagerDelegate() OVERRIDE; 176 GetDownloadManagerDelegate() OVERRIDE;
177 // Returns a testing ContextGetter (if one has been created via
178 // CreateRequestContext) or NULL. This is not done on-demand for two reasons:
179 // (1) Some tests depend on GetRequestContext() returning NULL. (2) Because
180 // of the special memory management considerations for the
181 // TestURLRequestContextGetter class, many tests would find themseleves
182 // leaking if they called this method without the necessary IO thread. This
183 // getter is currently only capable of returning a Context that helps test
184 // the CookieMonster. See implementation comments for more details.
185 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; 177 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
186 virtual net::URLRequestContextGetter* CreateRequestContext( 178 virtual net::URLRequestContextGetter* CreateRequestContext(
187 content::ProtocolHandlerMap* protocol_handlers) OVERRIDE; 179 content::ProtocolHandlerMap* protocol_handlers) OVERRIDE;
188 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( 180 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
189 int renderer_child_id) OVERRIDE; 181 int renderer_child_id) OVERRIDE;
190 virtual content::ResourceContext* GetResourceContext() OVERRIDE; 182 virtual content::ResourceContext* GetResourceContext() OVERRIDE;
191 virtual content::GeolocationPermissionContext* 183 virtual content::GeolocationPermissionContext*
192 GetGeolocationPermissionContext() OVERRIDE; 184 GetGeolocationPermissionContext() OVERRIDE;
193 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; 185 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
194 186
195 virtual TestingProfile* AsTestingProfile() OVERRIDE; 187 virtual TestingProfile* AsTestingProfile() OVERRIDE;
196 virtual std::string GetProfileName() OVERRIDE; 188 virtual std::string GetProfileName() OVERRIDE;
197 void set_incognito(bool incognito) { incognito_ = incognito; } 189 void set_incognito(bool incognito) { incognito_ = incognito; }
198 // Assumes ownership. 190 // Assumes ownership.
199 virtual void SetOffTheRecordProfile(Profile* profile); 191 virtual void SetOffTheRecordProfile(Profile* profile);
200 virtual void SetOriginalProfile(Profile* profile); 192 virtual void SetOriginalProfile(Profile* profile);
201 virtual Profile* GetOffTheRecordProfile() OVERRIDE; 193 virtual Profile* GetOffTheRecordProfile() OVERRIDE;
202 virtual void DestroyOffTheRecordProfile() OVERRIDE {} 194 virtual void DestroyOffTheRecordProfile() OVERRIDE {}
203 virtual bool HasOffTheRecordProfile() OVERRIDE; 195 virtual bool HasOffTheRecordProfile() OVERRIDE;
204 virtual Profile* GetOriginalProfile() OVERRIDE; 196 virtual Profile* GetOriginalProfile() OVERRIDE;
205 virtual ExtensionService* GetExtensionService() OVERRIDE; 197 virtual ExtensionService* GetExtensionService() OVERRIDE;
206 void SetExtensionSpecialStoragePolicy( 198 void SetExtensionSpecialStoragePolicy(
207 ExtensionSpecialStoragePolicy* extension_special_storage_policy); 199 ExtensionSpecialStoragePolicy* extension_special_storage_policy);
208 virtual ExtensionSpecialStoragePolicy* 200 virtual ExtensionSpecialStoragePolicy*
209 GetExtensionSpecialStoragePolicy() OVERRIDE; 201 GetExtensionSpecialStoragePolicy() OVERRIDE;
210 // The CookieMonster will only be returned if a Context has been created. Do 202 // TODO(ajwong): Remove this API in favor of directly retrieving the
211 // this by calling CreateRequestContext(). See the note at GetRequestContext 203 // CookieStore from the StoragePartition after ExtensionURLRequestContext
212 // for more information. 204 // has been removed.
213 net::CookieMonster* GetCookieMonster(); 205 net::CookieMonster* GetCookieMonster();
214 206
215 virtual PrefService* GetPrefs() OVERRIDE; 207 virtual PrefService* GetPrefs() OVERRIDE;
216 208
217 virtual history::TopSites* GetTopSites() OVERRIDE; 209 virtual history::TopSites* GetTopSites() OVERRIDE;
218 virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE; 210 virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE;
219 211
220 void CreateRequestContext();
221 // Clears out the created request context (which must be done before shutting
222 // down the IO thread to avoid leaks).
223 void ResetRequestContext();
224
225 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; 212 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
226 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( 213 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
227 int renderer_child_id) OVERRIDE; 214 int renderer_child_id) OVERRIDE;
228 virtual net::URLRequestContextGetter* 215 virtual net::URLRequestContextGetter*
229 GetRequestContextForExtensions() OVERRIDE; 216 GetRequestContextForExtensions() OVERRIDE;
230 virtual net::URLRequestContextGetter* 217 virtual net::URLRequestContextGetter*
231 GetMediaRequestContextForStoragePartition( 218 GetMediaRequestContextForStoragePartition(
232 const base::FilePath& partition_path, 219 const base::FilePath& partition_path,
233 bool in_memory) OVERRIDE; 220 bool in_memory) OVERRIDE;
234 virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition( 221 virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 287
301 // Creates a TestingPrefService and associates it with the TestingProfile. 288 // Creates a TestingPrefService and associates it with the TestingProfile.
302 void CreateTestingPrefService(); 289 void CreateTestingPrefService();
303 290
304 // Creates a ProfilePolicyConnector that the ProfilePolicyConnectorFactory 291 // Creates a ProfilePolicyConnector that the ProfilePolicyConnectorFactory
305 // maps to this profile. 292 // maps to this profile.
306 void CreateProfilePolicyConnector(); 293 void CreateProfilePolicyConnector();
307 294
308 // Internally, this is a TestURLRequestContextGetter that creates a dummy 295 // Internally, this is a TestURLRequestContextGetter that creates a dummy
309 // request context. Currently, only the CookieMonster is hooked up. 296 // request context. Currently, only the CookieMonster is hooked up.
310 scoped_refptr<net::URLRequestContextGetter> request_context_;
311 scoped_refptr<net::URLRequestContextGetter> extensions_request_context_; 297 scoped_refptr<net::URLRequestContextGetter> extensions_request_context_;
312 298
313 std::wstring id_; 299 std::wstring id_;
314 300
315 bool incognito_; 301 bool incognito_;
316 scoped_ptr<Profile> incognito_profile_; 302 scoped_ptr<Profile> incognito_profile_;
317 Profile* original_profile_; 303 Profile* original_profile_;
318 304
319 // Did the last session exit cleanly? Default is true. 305 // Did the last session exit cleanly? Default is true.
320 bool last_session_exited_cleanly_; 306 bool last_session_exited_cleanly_;
(...skipping 15 matching lines...) Expand all
336 base::ScopedTempDir temp_dir_; 322 base::ScopedTempDir temp_dir_;
337 // The path to this profile. This will be valid in either of the two above 323 // The path to this profile. This will be valid in either of the two above
338 // cases. 324 // cases.
339 base::FilePath profile_path_; 325 base::FilePath profile_path_;
340 326
341 // We keep a weak pointer to the dependency manager we want to notify on our 327 // We keep a weak pointer to the dependency manager we want to notify on our
342 // death. Defaults to the Singleton implementation but overridable for 328 // death. Defaults to the Singleton implementation but overridable for
343 // testing. 329 // testing.
344 BrowserContextDependencyManager* browser_context_dependency_manager_; 330 BrowserContextDependencyManager* browser_context_dependency_manager_;
345 331
346 scoped_ptr<content::MockResourceContext> resource_context_; 332 // Owned, but must be deleted on the IO thread so not placing in a
333 // scoped_ptr<>.
334 content::MockResourceContext* resource_context_;
347 335
348 scoped_ptr<policy::ProfilePolicyConnector> profile_policy_connector_; 336 scoped_ptr<policy::ProfilePolicyConnector> profile_policy_connector_;
349 337
350 // Weak pointer to a delegate for indicating that a profile was created. 338 // Weak pointer to a delegate for indicating that a profile was created.
351 Delegate* delegate_; 339 Delegate* delegate_;
352 }; 340 };
353 341
354 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ 342 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698