OLD | NEW |
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 return new HistoryService(profile); | 312 return new HistoryService(profile); |
313 } | 313 } |
314 | 314 |
315 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { | 315 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { |
316 DestroyHistoryService(); | 316 DestroyHistoryService(); |
317 if (delete_file) { | 317 if (delete_file) { |
318 FilePath path = GetPath(); | 318 FilePath path = GetPath(); |
319 path = path.Append(chrome::kHistoryFilename); | 319 path = path.Append(chrome::kHistoryFilename); |
320 file_util::Delete(path, false); | 320 file_util::Delete(path, false); |
321 } | 321 } |
322 // This will create and init the history service. | |
323 HistoryService* history_service = static_cast<HistoryService*>( | 322 HistoryService* history_service = static_cast<HistoryService*>( |
324 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 323 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
325 this, BuildHistoryService).get()); | 324 this, BuildHistoryService).get()); |
326 if (!history_service->Init(this->GetPath(), | 325 if (!InitHistoryService(history_service, no_db)) |
327 BookmarkModelFactory::GetForProfile(this), | |
328 no_db)) { | |
329 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); | 326 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); |
330 } | 327 } |
| 328 |
| 329 bool TestingProfile::InitHistoryService(HistoryService* history_service, |
| 330 bool no_db) { |
| 331 DCHECK(history_service); |
| 332 // By default, disable the InMemoryURLIndex's cache database. |
| 333 return history_service->Init(GetPath(), |
| 334 BookmarkModelFactory::GetForProfile(this), |
| 335 no_db, true); |
331 } | 336 } |
332 | 337 |
333 void TestingProfile::DestroyHistoryService() { | 338 void TestingProfile::DestroyHistoryService() { |
334 scoped_refptr<HistoryService> history_service = | 339 scoped_refptr<HistoryService> history_service = |
335 HistoryServiceFactory::GetForProfileWithoutCreating(this); | 340 HistoryServiceFactory::GetForProfileWithoutCreating(this); |
336 if (!history_service.get()) | 341 if (!history_service.get()) |
337 return; | 342 return; |
338 | 343 |
339 history_service->NotifyRenderProcessHostDestruction(0); | 344 history_service->NotifyRenderProcessHostDestruction(0); |
340 history_service->SetOnBackendDestroyTask(MessageLoop::QuitClosure()); | 345 history_service->SetOnBackendDestroyTask(MessageLoop::QuitClosure()); |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 build_called_ = true; | 810 build_called_ = true; |
806 return scoped_ptr<TestingProfile>(new TestingProfile( | 811 return scoped_ptr<TestingProfile>(new TestingProfile( |
807 path_, | 812 path_, |
808 delegate_, | 813 delegate_, |
809 extension_policy_, | 814 extension_policy_, |
810 pref_service_.Pass(), | 815 pref_service_.Pass(), |
811 user_cloud_policy_manager_.Pass())); | 816 user_cloud_policy_manager_.Pass())); |
812 } | 817 } |
813 | 818 |
814 | 819 |
OLD | NEW |