| 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/mojo/keep_alive_impl.h" | 5 #include "extensions/browser/mojo/keep_alive_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 .Append("background.js") | 124 .Append("background.js") |
| 125 .Build()) | 125 .Build()) |
| 126 .Build()) | 126 .Build()) |
| 127 .Build()) | 127 .Build()) |
| 128 .Build()) | 128 .Build()) |
| 129 .SetID("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") | 129 .SetID("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") |
| 130 .Build(); | 130 .Build(); |
| 131 | 131 |
| 132 ExtensionRegistry::Get(browser_context()) | 132 ExtensionRegistry::Get(browser_context()) |
| 133 ->TriggerOnUnloaded(other_extension.get(), | 133 ->TriggerOnUnloaded(other_extension.get(), |
| 134 UnloadedExtensionInfo::REASON_DISABLE); | 134 UnloadedExtensionReason::REASON_DISABLE); |
| 135 EXPECT_EQ(1, GetKeepAliveCount()); | 135 EXPECT_EQ(1, GetKeepAliveCount()); |
| 136 | 136 |
| 137 ExtensionRegistry::Get(browser_context()) | 137 ExtensionRegistry::Get(browser_context()) |
| 138 ->TriggerOnUnloaded(extension(), UnloadedExtensionInfo::REASON_DISABLE); | 138 ->TriggerOnUnloaded(extension(), UnloadedExtensionReason::REASON_DISABLE); |
| 139 // When its extension is unloaded, the KeepAliveImpl should not modify the | 139 // When its extension is unloaded, the KeepAliveImpl should not modify the |
| 140 // keep-alive count for its extension. However, ProcessManager resets its | 140 // keep-alive count for its extension. However, ProcessManager resets its |
| 141 // keep-alive count for an unloaded extension. | 141 // keep-alive count for an unloaded extension. |
| 142 EXPECT_EQ(0, GetKeepAliveCount()); | 142 EXPECT_EQ(0, GetKeepAliveCount()); |
| 143 | 143 |
| 144 // Wait for |keep_alive| to disconnect. | 144 // Wait for |keep_alive| to disconnect. |
| 145 base::RunLoop run_loop; | 145 base::RunLoop run_loop; |
| 146 keep_alive.set_connection_error_handler(run_loop.QuitClosure()); | 146 keep_alive.set_connection_error_handler(run_loop.QuitClosure()); |
| 147 run_loop.Run(); | 147 run_loop.Run(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 TEST_F(KeepAliveTest, Shutdown) { | 150 TEST_F(KeepAliveTest, Shutdown) { |
| 151 mojo::InterfacePtr<KeepAlive> keep_alive; | 151 mojo::InterfacePtr<KeepAlive> keep_alive; |
| 152 CreateKeepAlive(mojo::MakeRequest(&keep_alive)); | 152 CreateKeepAlive(mojo::MakeRequest(&keep_alive)); |
| 153 EXPECT_EQ(1, GetKeepAliveCount()); | 153 EXPECT_EQ(1, GetKeepAliveCount()); |
| 154 | 154 |
| 155 ExtensionRegistry::Get(browser_context())->Shutdown(); | 155 ExtensionRegistry::Get(browser_context())->Shutdown(); |
| 156 // After a shutdown event, the KeepAliveImpl should not access its | 156 // After a shutdown event, the KeepAliveImpl should not access its |
| 157 // ProcessManager and so the keep-alive count should remain unchanged. | 157 // ProcessManager and so the keep-alive count should remain unchanged. |
| 158 EXPECT_EQ(1, GetKeepAliveCount()); | 158 EXPECT_EQ(1, GetKeepAliveCount()); |
| 159 | 159 |
| 160 // Wait for |keep_alive| to disconnect. | 160 // Wait for |keep_alive| to disconnect. |
| 161 base::RunLoop run_loop; | 161 base::RunLoop run_loop; |
| 162 keep_alive.set_connection_error_handler(run_loop.QuitClosure()); | 162 keep_alive.set_connection_error_handler(run_loop.QuitClosure()); |
| 163 run_loop.Run(); | 163 run_loop.Run(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace extensions | 166 } // namespace extensions |
| OLD | NEW |