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 #include "ppapi/cpp/network_monitor.h" 6 7 #include "ppapi/c/ppb_network_monitor.h" 8 #include "ppapi/cpp/completion_callback.h" 9 #include "ppapi/cpp/instance.h" 10 #include "ppapi/cpp/module_impl.h" 11 #include "ppapi/cpp/network_list.h" 12 13 namespace pp { 14 15 namespace { 16 interface_name()17template <> const char* interface_name<PPB_NetworkMonitor_1_0>() { 18 return PPB_NETWORKMONITOR_INTERFACE_1_0; 19 } 20 21 } // namespace 22 NetworkMonitor(const InstanceHandle & instance)23NetworkMonitor::NetworkMonitor(const InstanceHandle& instance) { 24 if (has_interface<PPB_NetworkMonitor_1_0>()) { 25 PassRefFromConstructor(get_interface<PPB_NetworkMonitor_1_0>()->Create( 26 instance.pp_instance())); 27 } 28 } 29 UpdateNetworkList(const CompletionCallbackWithOutput<NetworkList> & callback)30int32_t NetworkMonitor::UpdateNetworkList( 31 const CompletionCallbackWithOutput<NetworkList>& callback) { 32 if (has_interface<PPB_NetworkMonitor_1_0>()) { 33 return get_interface<PPB_NetworkMonitor_1_0>()->UpdateNetworkList( 34 pp_resource(), callback.output(), callback.pp_completion_callback()); 35 } 36 return callback.MayForce(PP_ERROR_NOINTERFACE); 37 } 38 39 // static IsAvailable()40bool NetworkMonitor::IsAvailable() { 41 return has_interface<PPB_NetworkMonitor_1_0>(); 42 } 43 44 } // namespace pp 45