summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorrmcilroy@chromium.org <rmcilroy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-23 17:19:49 +0000
committerrmcilroy@chromium.org <rmcilroy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-23 17:19:49 +0000
commit9d21ec6f72db7c8c866ac36798df22cf690c20b0 (patch)
tree86fa2d9f13c08d1d96d2a848573115a38b619fbf /chrome/test
parentaba8c0f49ce5ca7a2e7305d1ff1a8c7dd4404db4 (diff)
downloadchromium_src-9d21ec6f72db7c8c866ac36798df22cf690c20b0.zip
chromium_src-9d21ec6f72db7c8c866ac36798df22cf690c20b0.tar.gz
chromium_src-9d21ec6f72db7c8c866ac36798df22cf690c20b0.tar.bz2
Add asserts to TestingProfile::CreateHistoryService to ensure files are deleted
BUG= Review URL: https://chromiumcodereview.appspot.com/19616004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/base/testing_profile.cc6
-rw-r--r--chrome/test/base/testing_profile.h4
-rw-r--r--chrome/test/perf/generate_profile.cc5
3 files changed, 10 insertions, 5 deletions
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 2704bc7..11502e4 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -351,12 +351,13 @@ static BrowserContextKeyedService* BuildHistoryService(
return new HistoryService(static_cast<Profile*>(profile));
}
-void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
+bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
DestroyHistoryService();
if (delete_file) {
base::FilePath path = GetPath();
path = path.Append(chrome::kHistoryFilename);
- base::DeleteFile(path, false);
+ if (!base::DeleteFile(path, false) || base::PathExists(path))
+ return false;
}
// This will create and init the history service.
HistoryService* history_service = static_cast<HistoryService*>(
@@ -369,6 +370,7 @@ void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
}
// Disable WebHistoryService by default, since it makes network requests.
WebHistoryServiceFactory::GetInstance()->SetTestingFactory(this, NULL);
+ return true;
}
void TestingProfile::DestroyHistoryService() {
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index 916bc33..dd8d68e 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -132,8 +132,8 @@ class TestingProfile : public Profile {
// deletes the directory containing the files used by HistoryService, this
// only matters if you're recreating the HistoryService. If |no_db| is true,
// the history backend will fail to initialize its database; this is useful
- // for testing error conditions.
- void CreateHistoryService(bool delete_file, bool no_db);
+ // for testing error conditions. Returns true on success.
+ bool CreateHistoryService(bool delete_file, bool no_db) WARN_UNUSED_RESULT;
// Shuts down and nulls out the reference to HistoryService.
void DestroyHistoryService();
diff --git a/chrome/test/perf/generate_profile.cc b/chrome/test/perf/generate_profile.cc
index d37060a..fe46c3d 100644
--- a/chrome/test/perf/generate_profile.cc
+++ b/chrome/test/perf/generate_profile.cc
@@ -229,7 +229,10 @@ bool GenerateProfile(GenerateProfileTypes types,
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
content::TestBrowserThread db_thread(BrowserThread::DB, &message_loop);
TestingProfile profile;
- profile.CreateHistoryService(false, false);
+ if (!profile.CreateHistoryService(false, false)) {
+ PLOG(ERROR) << "Creating history service failed";
+ return false;
+ }
if (types & TOP_SITES) {
profile.CreateTopSites();
profile.BlockUntilTopSitesLoaded();