| 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 // This test creates a safebrowsing service using test safebrowsing database | 5 // This test creates a safebrowsing service using test safebrowsing database |
| 6 // and a test protocol manager. It is used to test logics in safebrowsing | 6 // and a test protocol manager. It is used to test logics in safebrowsing |
| 7 // service. | 7 // service. |
| 8 | 8 |
| 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 10 | 10 |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 scoped_refptr<base::SingleThreadTaskRunner> browser_thread) { | 635 scoped_refptr<base::SingleThreadTaskRunner> browser_thread) { |
| 636 scoped_refptr<base::ThreadTestHelper> thread_helper( | 636 scoped_refptr<base::ThreadTestHelper> thread_helper( |
| 637 new base::ThreadTestHelper(browser_thread)); | 637 new base::ThreadTestHelper(browser_thread)); |
| 638 ASSERT_TRUE(thread_helper->Run()); | 638 ASSERT_TRUE(thread_helper->Run()); |
| 639 } | 639 } |
| 640 | 640 |
| 641 // Waits for pending tasks on the IO thread to complete. This is useful | 641 // Waits for pending tasks on the IO thread to complete. This is useful |
| 642 // to wait for the SafeBrowsingService to finish loading/stopping. | 642 // to wait for the SafeBrowsingService to finish loading/stopping. |
| 643 void WaitForIOThread() { | 643 void WaitForIOThread() { |
| 644 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( | 644 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( |
| 645 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())); | 645 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get())); |
| 646 ASSERT_TRUE(io_helper->Run()); | 646 ASSERT_TRUE(io_helper->Run()); |
| 647 } | 647 } |
| 648 | 648 |
| 649 // Waits for pending tasks on the IO thread to complete and check if the | 649 // Waits for pending tasks on the IO thread to complete and check if the |
| 650 // SafeBrowsingService enabled state matches |enabled|. | 650 // SafeBrowsingService enabled state matches |enabled|. |
| 651 void WaitForIOAndCheckEnabled(SafeBrowsingService* service, bool enabled) { | 651 void WaitForIOAndCheckEnabled(SafeBrowsingService* service, bool enabled) { |
| 652 scoped_refptr<ServiceEnabledHelper> enabled_helper(new ServiceEnabledHelper( | 652 scoped_refptr<ServiceEnabledHelper> enabled_helper(new ServiceEnabledHelper( |
| 653 service, enabled, | 653 service, enabled, |
| 654 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())); | 654 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get())); |
| 655 ASSERT_TRUE(enabled_helper->Run()); | 655 ASSERT_TRUE(enabled_helper->Run()); |
| 656 } | 656 } |
| 657 | 657 |
| 658 private: | 658 private: |
| 659 std::unique_ptr<TestSafeBrowsingServiceFactory> sb_factory_; | 659 std::unique_ptr<TestSafeBrowsingServiceFactory> sb_factory_; |
| 660 TestSafeBrowsingDatabaseFactory db_factory_; | 660 TestSafeBrowsingDatabaseFactory db_factory_; |
| 661 TestSBProtocolManagerFactory pm_factory_; | 661 TestSBProtocolManagerFactory pm_factory_; |
| 662 | 662 |
| 663 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceTest); | 663 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceTest); |
| 664 }; | 664 }; |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 1754 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
| 1755 content::Source<SafeBrowsingDatabaseManager>( | 1755 content::Source<SafeBrowsingDatabaseManager>( |
| 1756 sb_factory_->test_safe_browsing_service()->database_manager().get())); | 1756 sb_factory_->test_safe_browsing_service()->database_manager().get())); |
| 1757 BrowserThread::PostTask( | 1757 BrowserThread::PostTask( |
| 1758 BrowserThread::IO, FROM_HERE, | 1758 BrowserThread::IO, FROM_HERE, |
| 1759 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); | 1759 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); |
| 1760 observer.Wait(); | 1760 observer.Wait(); |
| 1761 } | 1761 } |
| 1762 | 1762 |
| 1763 } // namespace safe_browsing | 1763 } // namespace safe_browsing |
| OLD | NEW |