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

Side by Side Diff: trunk/src/chrome/test/base/testing_profile.cc

Issue 19714004: Revert 213148 "Add asserts to TestingProfile::CreateHistoryServi..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 #include "chrome/test/base/testing_profile.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // It is up to the caller to create the history service if one is needed. 344 // It is up to the caller to create the history service if one is needed.
345 FaviconServiceFactory::GetInstance()->SetTestingFactory( 345 FaviconServiceFactory::GetInstance()->SetTestingFactory(
346 this, BuildFaviconService); 346 this, BuildFaviconService);
347 } 347 }
348 348
349 static BrowserContextKeyedService* BuildHistoryService( 349 static BrowserContextKeyedService* BuildHistoryService(
350 content::BrowserContext* profile) { 350 content::BrowserContext* profile) {
351 return new HistoryService(static_cast<Profile*>(profile)); 351 return new HistoryService(static_cast<Profile*>(profile));
352 } 352 }
353 353
354 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { 354 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
355 DestroyHistoryService(); 355 DestroyHistoryService();
356 if (delete_file) { 356 if (delete_file) {
357 base::FilePath path = GetPath(); 357 base::FilePath path = GetPath();
358 path = path.Append(chrome::kHistoryFilename); 358 path = path.Append(chrome::kHistoryFilename);
359 if (!base::DeleteFile(path, false) || base::PathExists(path)) 359 base::DeleteFile(path, false);
360 return false;
361 } 360 }
362 // This will create and init the history service. 361 // This will create and init the history service.
363 HistoryService* history_service = static_cast<HistoryService*>( 362 HistoryService* history_service = static_cast<HistoryService*>(
364 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( 363 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(
365 this, BuildHistoryService)); 364 this, BuildHistoryService));
366 if (!history_service->Init(this->GetPath(), 365 if (!history_service->Init(this->GetPath(),
367 BookmarkModelFactory::GetForProfile(this), 366 BookmarkModelFactory::GetForProfile(this),
368 no_db)) { 367 no_db)) {
369 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); 368 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL);
370 } 369 }
371 // Disable WebHistoryService by default, since it makes network requests. 370 // Disable WebHistoryService by default, since it makes network requests.
372 WebHistoryServiceFactory::GetInstance()->SetTestingFactory(this, NULL); 371 WebHistoryServiceFactory::GetInstance()->SetTestingFactory(this, NULL);
373 return true;
374 } 372 }
375 373
376 void TestingProfile::DestroyHistoryService() { 374 void TestingProfile::DestroyHistoryService() {
377 HistoryService* history_service = 375 HistoryService* history_service =
378 HistoryServiceFactory::GetForProfileWithoutCreating(this); 376 HistoryServiceFactory::GetForProfileWithoutCreating(this);
379 if (!history_service) 377 if (!history_service)
380 return; 378 return;
381 379
382 history_service->NotifyRenderProcessHostDestruction(0); 380 history_service->NotifyRenderProcessHostDestruction(0);
383 history_service->SetOnBackendDestroyTask(base::MessageLoop::QuitClosure()); 381 history_service->SetOnBackendDestroyTask(base::MessageLoop::QuitClosure());
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 808
811 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 809 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
812 DCHECK(!build_called_); 810 DCHECK(!build_called_);
813 build_called_ = true; 811 build_called_ = true;
814 return scoped_ptr<TestingProfile>(new TestingProfile( 812 return scoped_ptr<TestingProfile>(new TestingProfile(
815 path_, 813 path_,
816 delegate_, 814 delegate_,
817 extension_policy_, 815 extension_policy_,
818 pref_service_.Pass())); 816 pref_service_.Pass()));
819 } 817 }
OLDNEW
« no previous file with comments | « trunk/src/chrome/test/base/testing_profile.h ('k') | trunk/src/chrome/test/perf/generate_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698