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. |
322 HistoryService* history_service = static_cast<HistoryService*>( | 323 HistoryService* history_service = static_cast<HistoryService*>( |
323 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 324 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
324 this, BuildHistoryService).get()); | 325 this, BuildHistoryService).get()); |
325 if (!InitHistoryService(history_service, no_db)) | 326 if (!history_service->Init(this->GetPath(), |
| 327 BookmarkModelFactory::GetForProfile(this), |
| 328 no_db)) { |
326 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); | 329 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse(this, NULL); |
327 } | 330 } |
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); | |
336 } | 331 } |
337 | 332 |
338 void TestingProfile::DestroyHistoryService() { | 333 void TestingProfile::DestroyHistoryService() { |
339 scoped_refptr<HistoryService> history_service = | 334 scoped_refptr<HistoryService> history_service = |
340 HistoryServiceFactory::GetForProfileWithoutCreating(this); | 335 HistoryServiceFactory::GetForProfileWithoutCreating(this); |
341 if (!history_service.get()) | 336 if (!history_service.get()) |
342 return; | 337 return; |
343 | 338 |
344 history_service->NotifyRenderProcessHostDestruction(0); | 339 history_service->NotifyRenderProcessHostDestruction(0); |
345 history_service->SetOnBackendDestroyTask(MessageLoop::QuitClosure()); | 340 history_service->SetOnBackendDestroyTask(MessageLoop::QuitClosure()); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 build_called_ = true; | 811 build_called_ = true; |
817 return scoped_ptr<TestingProfile>(new TestingProfile( | 812 return scoped_ptr<TestingProfile>(new TestingProfile( |
818 path_, | 813 path_, |
819 delegate_, | 814 delegate_, |
820 extension_policy_, | 815 extension_policy_, |
821 pref_service_.Pass(), | 816 pref_service_.Pass(), |
822 user_cloud_policy_manager_.Pass())); | 817 user_cloud_policy_manager_.Pass())); |
823 } | 818 } |
824 | 819 |
825 | 820 |
OLD | NEW |