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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/callback_list.h" | 7 #include "base/callback_list.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 g_callback_list.Get().Add(base::Bind(&FakeBatteryMonitor::DidChange, | 71 g_callback_list.Get().Add(base::Bind(&FakeBatteryMonitor::DidChange, |
72 base::Unretained(this))); | 72 base::Unretained(this))); |
73 // Report initial value. | 73 // Report initial value. |
74 DidChange(g_battery_status); | 74 DidChange(g_battery_status); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void DidChange(const device::BatteryStatus& battery_status) { | 78 void DidChange(const device::BatteryStatus& battery_status) { |
79 if (!callback_.is_null()) { | 79 if (!callback_.is_null()) { |
80 callback_.Run(battery_status.Clone()); | 80 callback_.Run(battery_status.Clone()); |
81 callback_.reset(); | 81 callback_.Reset(); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 std::unique_ptr<BatteryUpdateSubscription> subscription_; | 85 std::unique_ptr<BatteryUpdateSubscription> subscription_; |
86 mojo::StrongBinding<BatteryMonitor> binding_; | 86 mojo::StrongBinding<BatteryMonitor> binding_; |
87 BatteryStatusCallback callback_; | 87 BatteryStatusCallback callback_; |
88 }; | 88 }; |
89 | 89 |
90 // Overrides the default service implementation with the test implementation | 90 // Overrides the default service implementation with the test implementation |
91 // declared above. | 91 // declared above. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 TestNavigationObserver same_tab_observer2(shell()->web_contents(), 1); | 181 TestNavigationObserver same_tab_observer2(shell()->web_contents(), 1); |
182 status.level = 0.6; | 182 status.level = 0.6; |
183 UpdateBattery(status); | 183 UpdateBattery(status); |
184 same_tab_observer2.Wait(); | 184 same_tab_observer2.Wait(); |
185 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); | 185 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); |
186 } | 186 } |
187 | 187 |
188 } // namespace | 188 } // namespace |
189 | 189 |
190 } // namespace content | 190 } // namespace content |
OLD | NEW |