| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/extension_gcm_app_handler.h" | 5 #include "chrome/browser/extensions/extension_gcm_app_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (run_loop_ && run_loop_->running()) | 91 if (run_loop_ && run_loop_->running()) |
| 92 run_loop_->Quit(); | 92 run_loop_->Quit(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Runs until UI loop becomes idle. | 95 // Runs until UI loop becomes idle. |
| 96 void PumpUILoop() { base::RunLoop().RunUntilIdle(); } | 96 void PumpUILoop() { base::RunLoop().RunUntilIdle(); } |
| 97 | 97 |
| 98 // Runs until IO loop becomes idle. | 98 // Runs until IO loop becomes idle. |
| 99 void PumpIOLoop() { | 99 void PumpIOLoop() { |
| 100 content::BrowserThread::PostTask( | 100 content::BrowserThread::PostTask( |
| 101 content::BrowserThread::IO, | 101 content::BrowserThread::IO, FROM_HERE, |
| 102 FROM_HERE, | 102 base::BindOnce(&Waiter::OnIOLoopPump, base::Unretained(this))); |
| 103 base::Bind(&Waiter::OnIOLoopPump, base::Unretained(this))); | |
| 104 | 103 |
| 105 WaitUntilCompleted(); | 104 WaitUntilCompleted(); |
| 106 } | 105 } |
| 107 | 106 |
| 108 private: | 107 private: |
| 109 void PumpIOLoopCompleted() { | 108 void PumpIOLoopCompleted() { |
| 110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 109 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 111 | 110 |
| 112 SignalCompleted(); | 111 SignalCompleted(); |
| 113 } | 112 } |
| 114 | 113 |
| 115 void OnIOLoopPump() { | 114 void OnIOLoopPump() { |
| 116 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 115 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 117 | 116 |
| 118 content::BrowserThread::PostTask( | 117 content::BrowserThread::PostTask( |
| 119 content::BrowserThread::IO, | 118 content::BrowserThread::IO, FROM_HERE, |
| 120 FROM_HERE, | 119 base::BindOnce(&Waiter::OnIOLoopPumpCompleted, base::Unretained(this))); |
| 121 base::Bind(&Waiter::OnIOLoopPumpCompleted, base::Unretained(this))); | |
| 122 } | 120 } |
| 123 | 121 |
| 124 void OnIOLoopPumpCompleted() { | 122 void OnIOLoopPumpCompleted() { |
| 125 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 123 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 126 | 124 |
| 127 content::BrowserThread::PostTask( | 125 content::BrowserThread::PostTask( |
| 128 content::BrowserThread::UI, | 126 content::BrowserThread::UI, FROM_HERE, |
| 129 FROM_HERE, | 127 base::BindOnce(&Waiter::PumpIOLoopCompleted, base::Unretained(this))); |
| 130 base::Bind(&Waiter::PumpIOLoopCompleted, base::Unretained(this))); | |
| 131 } | 128 } |
| 132 | 129 |
| 133 std::unique_ptr<base::RunLoop> run_loop_; | 130 std::unique_ptr<base::RunLoop> run_loop_; |
| 134 | 131 |
| 135 DISALLOW_COPY_AND_ASSIGN(Waiter); | 132 DISALLOW_COPY_AND_ASSIGN(Waiter); |
| 136 }; | 133 }; |
| 137 | 134 |
| 138 class FakeExtensionGCMAppHandler : public ExtensionGCMAppHandler { | 135 class FakeExtensionGCMAppHandler : public ExtensionGCMAppHandler { |
| 139 public: | 136 public: |
| 140 FakeExtensionGCMAppHandler(Profile* profile, Waiter* waiter) | 137 FakeExtensionGCMAppHandler(Profile* profile, Waiter* waiter) |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 481 |
| 485 // App handler is removed when the extension is updated to the version that | 482 // App handler is removed when the extension is updated to the version that |
| 486 // has GCM permission removed. | 483 // has GCM permission removed. |
| 487 UpdateExtension(extension.get(), "good2.crx"); | 484 UpdateExtension(extension.get(), "good2.crx"); |
| 488 waiter()->PumpUILoop(); | 485 waiter()->PumpUILoop(); |
| 489 EXPECT_TRUE(gcm_app_handler()->app_handler_count_drop_to_zero()); | 486 EXPECT_TRUE(gcm_app_handler()->app_handler_count_drop_to_zero()); |
| 490 EXPECT_FALSE(HasAppHandlers(extension->id())); | 487 EXPECT_FALSE(HasAppHandlers(extension->id())); |
| 491 } | 488 } |
| 492 | 489 |
| 493 } // namespace extensions | 490 } // namespace extensions |
| OLD | NEW |