| 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 "extensions/browser/test_extension_registry_observer.h" | 5 #include "extensions/browser/test_extension_registry_observer.h" |
| 6 | 6 |
| 7 #include "content/public/test/test_utils.h" | 7 #include "content/public/test/test_utils.h" |
| 8 #include "extensions/browser/extension_registry.h" | 8 #include "extensions/browser/extension_registry.h" |
| 9 | 9 |
| 10 namespace extensions { | 10 namespace extensions { |
| 11 | 11 |
| 12 class TestExtensionRegistryObserver::Waiter { | 12 class TestExtensionRegistryObserver::Waiter { |
| 13 public: | 13 public: |
| 14 explicit Waiter(const std::string& extension_id) | 14 explicit Waiter(const std::string& extension_id) |
| 15 : observed_(false), runner_(NULL) {} | 15 : observed_(false), runner_(nullptr) {} |
| 16 | 16 |
| 17 void Wait() { | 17 void Wait() { |
| 18 if (observed_) | 18 if (observed_) |
| 19 return; | 19 return; |
| 20 | 20 |
| 21 runner_ = new content::MessageLoopRunner(); | 21 runner_ = new content::MessageLoopRunner(); |
| 22 runner_->Run(); | 22 runner_->Run(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void OnObserved() { | 25 void OnObserved() { |
| 26 observed_ = true; | 26 observed_ = true; |
| 27 | 27 |
| 28 if (runner_.get()) { | 28 if (runner_.get()) { |
| 29 runner_->Quit(); | 29 runner_->Quit(); |
| 30 runner_ = NULL; | 30 runner_ = nullptr; |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 bool observed_; | 35 bool observed_; |
| 36 scoped_refptr<content::MessageLoopRunner> runner_; | 36 scoped_refptr<content::MessageLoopRunner> runner_; |
| 37 | 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(Waiter); | 38 DISALLOW_COPY_AND_ASSIGN(Waiter); |
| 39 }; | 39 }; |
| 40 | 40 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 void TestExtensionRegistryObserver::OnExtensionUnloaded( | 97 void TestExtensionRegistryObserver::OnExtensionUnloaded( |
| 98 content::BrowserContext* browser_context, | 98 content::BrowserContext* browser_context, |
| 99 const Extension* extension, | 99 const Extension* extension, |
| 100 UnloadedExtensionInfo::Reason reason) { | 100 UnloadedExtensionInfo::Reason reason) { |
| 101 if (extension->id() == extension_id_) | 101 if (extension->id() == extension_id_) |
| 102 unloaded_waiter_->OnObserved(); | 102 unloaded_waiter_->OnObserved(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace extensions | 105 } // namespace extensions |
| OLD | NEW |