OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // Stops the specified (nested) message loop when the listener is called back. | 60 // Stops the specified (nested) message loop when the listener is called back. |
61 class MessageLoopQuitListener | 61 class MessageLoopQuitListener |
62 : public WifiDataProviderCommon::ListenerInterface { | 62 : public WifiDataProviderCommon::ListenerInterface { |
63 public: | 63 public: |
64 explicit MessageLoopQuitListener(MessageLoop* message_loop) | 64 explicit MessageLoopQuitListener(MessageLoop* message_loop) |
65 : message_loop_to_quit_(message_loop) { | 65 : message_loop_to_quit_(message_loop) { |
66 CHECK(message_loop_to_quit_ != NULL); | 66 CHECK(message_loop_to_quit_ != NULL); |
67 } | 67 } |
68 // ListenerInterface | 68 // ListenerInterface |
69 virtual void DeviceDataUpdateAvailable( | 69 virtual void DeviceDataUpdateAvailable( |
70 DeviceDataProvider<WifiData>* provider) { | 70 DeviceDataProvider<WifiData>* provider) OVERRIDE { |
71 // Provider should call back on client's thread. | 71 // Provider should call back on client's thread. |
72 EXPECT_EQ(MessageLoop::current(), message_loop_to_quit_); | 72 EXPECT_EQ(MessageLoop::current(), message_loop_to_quit_); |
73 provider_ = provider; | 73 provider_ = provider; |
74 message_loop_to_quit_->QuitNow(); | 74 message_loop_to_quit_->QuitNow(); |
75 } | 75 } |
76 MessageLoop* message_loop_to_quit_; | 76 MessageLoop* message_loop_to_quit_; |
77 DeviceDataProvider<WifiData>* provider_; | 77 DeviceDataProvider<WifiData>* provider_; |
78 }; | 78 }; |
79 | 79 |
80 | 80 |
81 class WifiDataProviderCommonWithMock : public WifiDataProviderCommon { | 81 class WifiDataProviderCommonWithMock : public WifiDataProviderCommon { |
82 public: | 82 public: |
83 WifiDataProviderCommonWithMock() | 83 WifiDataProviderCommonWithMock() |
84 : new_wlan_api_(new MockWlanApi), | 84 : new_wlan_api_(new MockWlanApi), |
85 new_polling_policy_(new MockPollingPolicy) {} | 85 new_polling_policy_(new MockPollingPolicy) {} |
86 | 86 |
87 // WifiDataProviderCommon | 87 // WifiDataProviderCommon |
88 virtual WlanApiInterface* NewWlanApi() { | 88 virtual WlanApiInterface* NewWlanApi() OVERRIDE { |
89 CHECK(new_wlan_api_ != NULL); | 89 CHECK(new_wlan_api_ != NULL); |
90 return new_wlan_api_.release(); | 90 return new_wlan_api_.release(); |
91 } | 91 } |
92 virtual PollingPolicyInterface* NewPollingPolicy() { | 92 virtual PollingPolicyInterface* NewPollingPolicy() OVERRIDE { |
93 CHECK(new_polling_policy_ != NULL); | 93 CHECK(new_polling_policy_ != NULL); |
94 return new_polling_policy_.release(); | 94 return new_polling_policy_.release(); |
95 } | 95 } |
96 | 96 |
97 scoped_ptr<MockWlanApi> new_wlan_api_; | 97 scoped_ptr<MockWlanApi> new_wlan_api_; |
98 scoped_ptr<MockPollingPolicy> new_polling_policy_; | 98 scoped_ptr<MockPollingPolicy> new_polling_policy_; |
99 | 99 |
100 private: | 100 private: |
101 virtual ~WifiDataProviderCommonWithMock() {} | 101 virtual ~WifiDataProviderCommonWithMock() {} |
102 | 102 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 StartThreadViaDeviceDataProvider) { | 224 StartThreadViaDeviceDataProvider) { |
225 MessageLoopQuitListener quit_listener(&main_message_loop_); | 225 MessageLoopQuitListener quit_listener(&main_message_loop_); |
226 WifiDataProvider::SetFactory(CreateWifiDataProviderCommonWithMock); | 226 WifiDataProvider::SetFactory(CreateWifiDataProviderCommonWithMock); |
227 DeviceDataProvider<WifiData>::Register(&quit_listener); | 227 DeviceDataProvider<WifiData>::Register(&quit_listener); |
228 main_message_loop_.Run(); | 228 main_message_loop_.Run(); |
229 DeviceDataProvider<WifiData>::Unregister(&quit_listener); | 229 DeviceDataProvider<WifiData>::Unregister(&quit_listener); |
230 DeviceDataProvider<WifiData>::ResetFactory(); | 230 DeviceDataProvider<WifiData>::ResetFactory(); |
231 } | 231 } |
232 | 232 |
233 } // namespace content | 233 } // namespace content |
OLD | NEW |