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 "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/location.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/prefs/testing_pref_store.h" | 12 #include "base/prefs/testing_pref_store.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/single_thread_task_runner.h" |
14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/thread_task_runner_handle.h" |
15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
16 #include "chrome/browser/autocomplete/in_memory_url_index.h" | 18 #include "chrome/browser/autocomplete/in_memory_url_index.h" |
17 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" | 19 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" |
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 20 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
19 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 21 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
20 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" | 22 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" |
21 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
23 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h" | 25 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h" |
24 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" | 26 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 original_profile_(NULL), | 314 original_profile_(NULL), |
313 guest_session_(false), | 315 guest_session_(false), |
314 last_session_exited_cleanly_(true), | 316 last_session_exited_cleanly_(true), |
315 profile_path_(path), | 317 profile_path_(path), |
316 browser_context_dependency_manager_( | 318 browser_context_dependency_manager_( |
317 BrowserContextDependencyManager::GetInstance()), | 319 BrowserContextDependencyManager::GetInstance()), |
318 resource_context_(NULL), | 320 resource_context_(NULL), |
319 delegate_(delegate) { | 321 delegate_(delegate) { |
320 Init(); | 322 Init(); |
321 if (delegate_) { | 323 if (delegate_) { |
322 base::MessageLoop::current()->PostTask( | 324 base::ThreadTaskRunnerHandle::Get()->PostTask( |
323 FROM_HERE, | 325 FROM_HERE, |
324 base::Bind(&TestingProfile::FinishInit, base::Unretained(this))); | 326 base::Bind(&TestingProfile::FinishInit, base::Unretained(this))); |
325 } else { | 327 } else { |
326 FinishInit(); | 328 FinishInit(); |
327 } | 329 } |
328 } | 330 } |
329 | 331 |
330 TestingProfile::TestingProfile( | 332 TestingProfile::TestingProfile( |
331 const base::FilePath& path, | 333 const base::FilePath& path, |
332 Delegate* delegate, | 334 Delegate* delegate, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 it != factories.end(); ++it) { | 371 it != factories.end(); ++it) { |
370 it->first->SetTestingFactory(this, it->second); | 372 it->first->SetTestingFactory(this, it->second); |
371 } | 373 } |
372 | 374 |
373 Init(); | 375 Init(); |
374 // If caller supplied a delegate, delay the FinishInit invocation until other | 376 // If caller supplied a delegate, delay the FinishInit invocation until other |
375 // tasks have run. | 377 // tasks have run. |
376 // TODO(atwilson): See if this is still required once we convert the current | 378 // TODO(atwilson): See if this is still required once we convert the current |
377 // users of the constructor that takes a Delegate* param. | 379 // users of the constructor that takes a Delegate* param. |
378 if (delegate_) { | 380 if (delegate_) { |
379 base::MessageLoop::current()->PostTask( | 381 base::ThreadTaskRunnerHandle::Get()->PostTask( |
380 FROM_HERE, | 382 FROM_HERE, |
381 base::Bind(&TestingProfile::FinishInit, base::Unretained(this))); | 383 base::Bind(&TestingProfile::FinishInit, base::Unretained(this))); |
382 } else { | 384 } else { |
383 FinishInit(); | 385 FinishInit(); |
384 } | 386 } |
385 | 387 |
386 SetSupervisedUserId(supervised_user_id); | 388 SetSupervisedUserId(supervised_user_id); |
387 } | 389 } |
388 | 390 |
389 void TestingProfile::CreateTempProfileDir() { | 391 void TestingProfile::CreateTempProfileDir() { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 HistoryServiceFactory::ShutdownForProfile(this); | 591 HistoryServiceFactory::ShutdownForProfile(this); |
590 | 592 |
591 // Wait for the backend class to terminate before deleting the files and | 593 // Wait for the backend class to terminate before deleting the files and |
592 // moving to the next test. Note: if this never terminates, somebody is | 594 // moving to the next test. Note: if this never terminates, somebody is |
593 // probably leaking a reference to the history backend, so it never calls | 595 // probably leaking a reference to the history backend, so it never calls |
594 // our destroy task. | 596 // our destroy task. |
595 base::MessageLoop::current()->Run(); | 597 base::MessageLoop::current()->Run(); |
596 | 598 |
597 // Make sure we don't have any event pending that could disrupt the next | 599 // Make sure we don't have any event pending that could disrupt the next |
598 // test. | 600 // test. |
599 base::MessageLoop::current()->PostTask(FROM_HERE, | 601 base::ThreadTaskRunnerHandle::Get()->PostTask( |
600 base::MessageLoop::QuitClosure()); | 602 FROM_HERE, base::MessageLoop::QuitClosure()); |
601 base::MessageLoop::current()->Run(); | 603 base::MessageLoop::current()->Run(); |
602 } | 604 } |
603 | 605 |
604 void TestingProfile::CreateBookmarkModel(bool delete_file) { | 606 void TestingProfile::CreateBookmarkModel(bool delete_file) { |
605 if (delete_file) { | 607 if (delete_file) { |
606 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); | 608 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); |
607 base::DeleteFile(path, false); | 609 base::DeleteFile(path, false); |
608 } | 610 } |
609 ChromeHistoryClientFactory::GetInstance()->SetTestingFactory( | 611 ChromeHistoryClientFactory::GetInstance()->SetTestingFactory( |
610 this, BuildChromeHistoryClient); | 612 this, BuildChromeHistoryClient); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 } | 649 } |
648 | 650 |
649 scoped_ptr<content::ZoomLevelDelegate> TestingProfile::CreateZoomLevelDelegate( | 651 scoped_ptr<content::ZoomLevelDelegate> TestingProfile::CreateZoomLevelDelegate( |
650 const base::FilePath& partition_path) { | 652 const base::FilePath& partition_path) { |
651 return make_scoped_ptr(new chrome::ChromeZoomLevelPrefs( | 653 return make_scoped_ptr(new chrome::ChromeZoomLevelPrefs( |
652 GetPrefs(), GetPath(), partition_path, | 654 GetPrefs(), GetPath(), partition_path, |
653 ui_zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr())); | 655 ui_zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr())); |
654 } | 656 } |
655 | 657 |
656 scoped_refptr<base::SequencedTaskRunner> TestingProfile::GetIOTaskRunner() { | 658 scoped_refptr<base::SequencedTaskRunner> TestingProfile::GetIOTaskRunner() { |
657 return base::MessageLoop::current()->message_loop_proxy(); | 659 return base::MessageLoop::current()->task_runner(); |
658 } | 660 } |
659 | 661 |
660 TestingPrefServiceSyncable* TestingProfile::GetTestingPrefService() { | 662 TestingPrefServiceSyncable* TestingProfile::GetTestingPrefService() { |
661 DCHECK(prefs_); | 663 DCHECK(prefs_); |
662 DCHECK(testing_prefs_); | 664 DCHECK(testing_prefs_); |
663 return testing_prefs_; | 665 return testing_prefs_; |
664 } | 666 } |
665 | 667 |
666 TestingProfile* TestingProfile::AsTestingProfile() { | 668 TestingProfile* TestingProfile::AsTestingProfile() { |
667 return this; | 669 return this; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 #if defined(ENABLE_EXTENSIONS) | 1082 #if defined(ENABLE_EXTENSIONS) |
1081 extension_policy_, | 1083 extension_policy_, |
1082 #endif | 1084 #endif |
1083 pref_service_.Pass(), | 1085 pref_service_.Pass(), |
1084 original_profile, | 1086 original_profile, |
1085 guest_session_, | 1087 guest_session_, |
1086 supervised_user_id_, | 1088 supervised_user_id_, |
1087 policy_service_.Pass(), | 1089 policy_service_.Pass(), |
1088 testing_factories_); | 1090 testing_factories_); |
1089 } | 1091 } |
OLD | NEW |