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 3 // found in the LICENSE file. 4 5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_NETWORK_MANAGER_H_ 6 #define REMOTING_CLIENT_PLUGIN_PEPPER_NETWORK_MANAGER_H_ 7 8 #include "base/compiler_specific.h" 9 #include "base/memory/weak_ptr.h" 10 #include "ppapi/cpp/instance_handle.h" 11 #include "ppapi/cpp/private/network_monitor_private.h" 12 #include "third_party/libjingle/source/talk/base/network.h" 13 14 namespace pp { 15 class NetworkListPrivate; 16 } // namespace pp 17 18 namespace remoting { 19 20 // PepperNetworkManager uses the PPB_NetworkMonitor_Private API to 21 // implement the NetworkManager interface that libjingle uses to 22 // monitor the host system's network interfaces. 23 class PepperNetworkManager : public talk_base::NetworkManagerBase { 24 public: 25 PepperNetworkManager(const pp::InstanceHandle& instance); 26 virtual ~PepperNetworkManager(); 27 28 // NetworkManager interface. 29 virtual void StartUpdating() OVERRIDE; 30 virtual void StopUpdating() OVERRIDE; 31 32 private: 33 static void OnNetworkListCallbackHandler(void* user_data, 34 PP_Resource list_resource); 35 36 void OnNetworkList(const pp::NetworkListPrivate& list); 37 38 void SendNetworksChangedSignal(); 39 40 pp::NetworkMonitorPrivate monitor_; 41 int start_count_; 42 bool network_list_received_; 43 44 base::WeakPtrFactory<PepperNetworkManager> weak_factory_; 45 }; 46 47 } // namespace remoting 48 49 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_NETWORK_MANAGER_H_ 50