1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROMEOS_COMPONENTS_TETHER_FAKE_ASYNCHRONOUS_SHUTDOWN_OBJECT_CONTAINER_H_ 6 #define CHROMEOS_COMPONENTS_TETHER_FAKE_ASYNCHRONOUS_SHUTDOWN_OBJECT_CONTAINER_H_ 7 8 #include "base/bind.h" 9 #include "base/callback.h" 10 #include "base/callback_helpers.h" 11 #include "base/macros.h" 12 #include "chromeos/components/tether/asynchronous_shutdown_object_container.h" 13 14 namespace chromeos { 15 16 namespace tether { 17 18 // Test double for FakeAsynchronousShutdownObjectContainer. 19 class FakeAsynchronousShutdownObjectContainer 20 : public AsynchronousShutdownObjectContainer { 21 public: 22 // |deletion_callback| will be invoked when the object is deleted. 23 FakeAsynchronousShutdownObjectContainer( 24 const base::Closure& deletion_callback = base::DoNothing()); 25 ~FakeAsynchronousShutdownObjectContainer() override; 26 shutdown_complete_callback()27 base::Closure& shutdown_complete_callback() { 28 return shutdown_complete_callback_; 29 } 30 set_tether_host_fetcher(TetherHostFetcher * tether_host_fetcher)31 void set_tether_host_fetcher(TetherHostFetcher* tether_host_fetcher) { 32 tether_host_fetcher_ = tether_host_fetcher; 33 } 34 set_disconnect_tethering_request_sender(DisconnectTetheringRequestSender * disconnect_tethering_request_sender)35 void set_disconnect_tethering_request_sender( 36 DisconnectTetheringRequestSender* disconnect_tethering_request_sender) { 37 disconnect_tethering_request_sender_ = disconnect_tethering_request_sender; 38 } 39 set_network_configuration_remover(NetworkConfigurationRemover * network_configuration_remover)40 void set_network_configuration_remover( 41 NetworkConfigurationRemover* network_configuration_remover) { 42 network_configuration_remover_ = network_configuration_remover; 43 } 44 set_wifi_hotspot_disconnector(WifiHotspotDisconnector * wifi_hotspot_disconnector)45 void set_wifi_hotspot_disconnector( 46 WifiHotspotDisconnector* wifi_hotspot_disconnector) { 47 wifi_hotspot_disconnector_ = wifi_hotspot_disconnector; 48 } 49 50 // AsynchronousShutdownObjectContainer: 51 void Shutdown(const base::Closure& shutdown_complete_callback) override; 52 TetherHostFetcher* tether_host_fetcher() override; 53 DisconnectTetheringRequestSender* disconnect_tethering_request_sender() 54 override; 55 NetworkConfigurationRemover* network_configuration_remover() override; 56 WifiHotspotDisconnector* wifi_hotspot_disconnector() override; 57 58 private: 59 base::Closure deletion_callback_; 60 base::Closure shutdown_complete_callback_; 61 62 TetherHostFetcher* tether_host_fetcher_ = nullptr; 63 DisconnectTetheringRequestSender* disconnect_tethering_request_sender_ = 64 nullptr; 65 NetworkConfigurationRemover* network_configuration_remover_ = nullptr; 66 WifiHotspotDisconnector* wifi_hotspot_disconnector_ = nullptr; 67 68 DISALLOW_COPY_AND_ASSIGN(FakeAsynchronousShutdownObjectContainer); 69 }; 70 71 } // namespace tether 72 73 } // namespace chromeos 74 75 #endif // CHROMEOS_COMPONENTS_TETHER_FAKE_ASYNCHRONOUS_SHUTDOWN_OBJECT_CONTAINER_H_ 76