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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 const Extension* extension() { return extension_.get(); } | 67 const Extension* extension() { return extension_.get(); } |
68 | 68 |
69 int GetKeepAliveCount() { | 69 int GetKeepAliveCount() { |
70 return ProcessManager::Get(browser_context()) | 70 return ProcessManager::Get(browser_context()) |
71 ->GetLazyKeepaliveCount(extension()); | 71 ->GetLazyKeepaliveCount(extension()); |
72 } | 72 } |
73 | 73 |
74 private: | 74 private: |
75 scoped_ptr<base::MessageLoop> message_loop_; | 75 std::unique_ptr<base::MessageLoop> message_loop_; |
76 scoped_ptr<content::NotificationService> notification_service_; | 76 std::unique_ptr<content::NotificationService> notification_service_; |
77 scoped_refptr<const Extension> extension_; | 77 scoped_refptr<const Extension> extension_; |
78 | 78 |
79 DISALLOW_COPY_AND_ASSIGN(KeepAliveTest); | 79 DISALLOW_COPY_AND_ASSIGN(KeepAliveTest); |
80 }; | 80 }; |
81 | 81 |
82 TEST_F(KeepAliveTest, Basic) { | 82 TEST_F(KeepAliveTest, Basic) { |
83 mojo::InterfacePtr<KeepAlive> keep_alive; | 83 mojo::InterfacePtr<KeepAlive> keep_alive; |
84 CreateKeepAlive(mojo::GetProxy(&keep_alive)); | 84 CreateKeepAlive(mojo::GetProxy(&keep_alive)); |
85 EXPECT_EQ(1, GetKeepAliveCount()); | 85 EXPECT_EQ(1, GetKeepAliveCount()); |
86 | 86 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // ProcessManager and so the keep-alive count should remain unchanged. | 160 // ProcessManager and so the keep-alive count should remain unchanged. |
161 EXPECT_EQ(1, GetKeepAliveCount()); | 161 EXPECT_EQ(1, GetKeepAliveCount()); |
162 | 162 |
163 // Wait for |keep_alive| to disconnect. | 163 // Wait for |keep_alive| to disconnect. |
164 base::RunLoop run_loop; | 164 base::RunLoop run_loop; |
165 keep_alive.set_connection_error_handler(run_loop.QuitClosure()); | 165 keep_alive.set_connection_error_handler(run_loop.QuitClosure()); |
166 run_loop.Run(); | 166 run_loop.Run(); |
167 } | 167 } |
168 | 168 |
169 } // namespace extensions | 169 } // namespace extensions |
OLD | NEW |