| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/after_startup_task_utils.h" | 5 #include "chrome/browser/after_startup_task_utils.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 int ran_task_count_ = 0; | 66 int ran_task_count_ = 0; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 class AfterStartupTaskTest : public testing::Test { | 71 class AfterStartupTaskTest : public testing::Test { |
| 72 public: | 72 public: |
| 73 AfterStartupTaskTest() | 73 AfterStartupTaskTest() |
| 74 : browser_thread_bundle_(TestBrowserThreadBundle::REAL_DB_THREAD) { | 74 : browser_thread_bundle_(TestBrowserThreadBundle::REAL_DB_THREAD) { |
| 75 ui_thread_ = new WrappedTaskRunner( | 75 ui_thread_ = new WrappedTaskRunner( |
| 76 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)); | 76 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)); |
| 77 db_thread_ = new WrappedTaskRunner( | 77 db_thread_ = new WrappedTaskRunner( |
| 78 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)); | 78 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB)); |
| 79 AfterStartupTaskUtils::UnsafeResetForTesting(); | 79 AfterStartupTaskUtils::UnsafeResetForTesting(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // Hop to the db thread and call IsBrowserStartupComplete. | 82 // Hop to the db thread and call IsBrowserStartupComplete. |
| 83 bool GetIsBrowserStartupCompleteFromDBThread() { | 83 bool GetIsBrowserStartupCompleteFromDBThread() { |
| 84 RunLoop run_loop; | 84 RunLoop run_loop; |
| 85 bool is_complete; | 85 bool is_complete; |
| 86 base::PostTaskAndReplyWithResult( | 86 base::PostTaskAndReplyWithResult( |
| 87 db_thread_->real_runner(), FROM_HERE, | 87 db_thread_->real_runner(), FROM_HERE, |
| 88 base::Bind(&AfterStartupTaskUtils::IsBrowserStartupComplete), | 88 base::Bind(&AfterStartupTaskUtils::IsBrowserStartupComplete), |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 base::Bind(&base::DoNothing)); | 191 base::Bind(&base::DoNothing)); |
| 192 PostAfterStartupTaskFromDBThread(FROM_HERE, db_thread_, | 192 PostAfterStartupTaskFromDBThread(FROM_HERE, db_thread_, |
| 193 base::Bind(&base::DoNothing)); | 193 base::Bind(&base::DoNothing)); |
| 194 EXPECT_EQ(2, db_thread_->posted_task_count()); | 194 EXPECT_EQ(2, db_thread_->posted_task_count()); |
| 195 EXPECT_EQ(2, ui_thread_->posted_task_count()); | 195 EXPECT_EQ(2, ui_thread_->posted_task_count()); |
| 196 FlushDBThread(); | 196 FlushDBThread(); |
| 197 RunLoop().RunUntilIdle(); | 197 RunLoop().RunUntilIdle(); |
| 198 EXPECT_EQ(2, db_thread_->ran_task_count()); | 198 EXPECT_EQ(2, db_thread_->ran_task_count()); |
| 199 EXPECT_EQ(2, ui_thread_->ran_task_count()); | 199 EXPECT_EQ(2, ui_thread_->ran_task_count()); |
| 200 } | 200 } |
| OLD | NEW |