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

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

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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
« no previous file with comments | « chrome/test/automation/proxy_launcher.cc ('k') | chrome/test/gpu/gpu_pixel_browsertest.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 #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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 base::FilePath system_tmp_dir; 262 base::FilePath system_tmp_dir;
263 bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir); 263 bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir);
264 264
265 // We're severly screwed if we can't get the system temporary 265 // We're severly screwed if we can't get the system temporary
266 // directory. Die now to avoid writing to the filesystem root 266 // directory. Die now to avoid writing to the filesystem root
267 // or other bad places. 267 // or other bad places.
268 CHECK(success); 268 CHECK(success);
269 269
270 base::FilePath fallback_dir( 270 base::FilePath fallback_dir(
271 system_tmp_dir.AppendASCII("TestingProfilePath")); 271 system_tmp_dir.AppendASCII("TestingProfilePath"));
272 file_util::Delete(fallback_dir, true); 272 base::Delete(fallback_dir, true);
273 file_util::CreateDirectory(fallback_dir); 273 file_util::CreateDirectory(fallback_dir);
274 if (!temp_dir_.Set(fallback_dir)) { 274 if (!temp_dir_.Set(fallback_dir)) {
275 // That shouldn't happen, but if it does, try to recover. 275 // That shouldn't happen, but if it does, try to recover.
276 LOG(ERROR) << "Failed to use a fallback temporary directory."; 276 LOG(ERROR) << "Failed to use a fallback temporary directory.";
277 277
278 // We're screwed if this fails, see CHECK above. 278 // We're screwed if this fails, see CHECK above.
279 CHECK(temp_dir_.Set(system_tmp_dir)); 279 CHECK(temp_dir_.Set(system_tmp_dir));
280 } 280 }
281 } 281 }
282 } 282 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 static BrowserContextKeyedService* BuildHistoryService( 353 static BrowserContextKeyedService* BuildHistoryService(
354 content::BrowserContext* profile) { 354 content::BrowserContext* profile) {
355 return new HistoryService(static_cast<Profile*>(profile)); 355 return new HistoryService(static_cast<Profile*>(profile));
356 } 356 }
357 357
358 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { 358 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
359 DestroyHistoryService(); 359 DestroyHistoryService();
360 if (delete_file) { 360 if (delete_file) {
361 base::FilePath path = GetPath(); 361 base::FilePath path = GetPath();
362 path = path.Append(chrome::kHistoryFilename); 362 path = path.Append(chrome::kHistoryFilename);
363 file_util::Delete(path, false); 363 base::Delete(path, false);
364 } 364 }
365 // This will create and init the history service. 365 // This will create and init the history service.
366 HistoryService* history_service = static_cast<HistoryService*>( 366 HistoryService* history_service = static_cast<HistoryService*>(
367 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( 367 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(
368 this, BuildHistoryService)); 368 this, BuildHistoryService));
369 if (!history_service->Init(this->GetPath(), 369 if (!history_service->Init(this->GetPath(),
370 BookmarkModelFactory::GetForProfile(this), 370 BookmarkModelFactory::GetForProfile(this),
371 no_db)) { 371 no_db)) {
372 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); 372 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL);
373 } 373 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 Profile* profile = static_cast<Profile*>(context); 422 Profile* profile = static_cast<Profile*>(context);
423 BookmarkModel* bookmark_model = new BookmarkModel(profile); 423 BookmarkModel* bookmark_model = new BookmarkModel(profile);
424 bookmark_model->Load(profile->GetIOTaskRunner()); 424 bookmark_model->Load(profile->GetIOTaskRunner());
425 return bookmark_model; 425 return bookmark_model;
426 } 426 }
427 427
428 428
429 void TestingProfile::CreateBookmarkModel(bool delete_file) { 429 void TestingProfile::CreateBookmarkModel(bool delete_file) {
430 if (delete_file) { 430 if (delete_file) {
431 base::FilePath path = GetPath().Append(chrome::kBookmarksFileName); 431 base::FilePath path = GetPath().Append(chrome::kBookmarksFileName);
432 file_util::Delete(path, false); 432 base::Delete(path, false);
433 } 433 }
434 // This will create a bookmark model. 434 // This will create a bookmark model.
435 BookmarkModel* bookmark_service = static_cast<BookmarkModel*>( 435 BookmarkModel* bookmark_service = static_cast<BookmarkModel*>(
436 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( 436 BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
437 this, BuildBookmarkModel)); 437 this, BuildBookmarkModel));
438 438
439 HistoryService* history_service = 439 HistoryService* history_service =
440 HistoryServiceFactory::GetForProfileWithoutCreating(this); 440 HistoryServiceFactory::GetForProfileWithoutCreating(this);
441 if (history_service) { 441 if (history_service) {
442 history_service->history_backend_->bookmark_service_ = bookmark_service; 442 history_service->history_backend_->bookmark_service_ = bookmark_service;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 807
808 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 808 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
809 DCHECK(!build_called_); 809 DCHECK(!build_called_);
810 build_called_ = true; 810 build_called_ = true;
811 return scoped_ptr<TestingProfile>(new TestingProfile( 811 return scoped_ptr<TestingProfile>(new TestingProfile(
812 path_, 812 path_,
813 delegate_, 813 delegate_,
814 extension_policy_, 814 extension_policy_,
815 pref_service_.Pass())); 815 pref_service_.Pass()));
816 } 816 }
OLDNEW
« no previous file with comments | « chrome/test/automation/proxy_launcher.cc ('k') | chrome/test/gpu/gpu_pixel_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698