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 "ppapi/cpp/private/network_monitor_private.h" | 5 #include "ppapi/cpp/private/network_monitor_private.h" |
6 | 6 |
| 7 #include "ppapi/c/private/ppb_network_monitor_private.h" |
| 8 #include "ppapi/cpp/completion_callback.h" |
7 #include "ppapi/cpp/instance.h" | 9 #include "ppapi/cpp/instance.h" |
8 #include "ppapi/cpp/module_impl.h" | 10 #include "ppapi/cpp/module_impl.h" |
| 11 #include "ppapi/cpp/private/network_list_private.h" |
9 | 12 |
10 namespace pp { | 13 namespace pp { |
11 | 14 |
12 namespace { | 15 namespace { |
13 | 16 |
14 template <> const char* interface_name<PPB_NetworkMonitor_Private>() { | 17 template <> const char* interface_name<PPB_NetworkMonitor_Private_0_3>() { |
15 return PPB_NETWORKMONITOR_PRIVATE_INTERFACE; | 18 return PPB_NETWORKMONITOR_PRIVATE_INTERFACE_0_3; |
16 } | 19 } |
17 | 20 |
18 } // namespace | 21 } // namespace |
19 | 22 |
20 NetworkMonitorPrivate::NetworkMonitorPrivate( | 23 NetworkMonitorPrivate::NetworkMonitorPrivate(const InstanceHandle& instance) { |
21 const InstanceHandle& instance, | 24 if (has_interface<PPB_NetworkMonitor_Private_0_3>()) { |
22 PPB_NetworkMonitor_Callback callback, | 25 PassRefFromConstructor(get_interface<PPB_NetworkMonitor_Private_0_3>()-> |
23 void* user_data) { | 26 Create(instance.pp_instance())); |
24 if (has_interface<PPB_NetworkMonitor_Private>()) { | |
25 PassRefFromConstructor(get_interface<PPB_NetworkMonitor_Private>()->Create( | |
26 instance.pp_instance(), callback, user_data)); | |
27 } | 27 } |
28 } | 28 } |
29 | 29 |
| 30 int32_t NetworkMonitorPrivate::UpdateNetworkList( |
| 31 const CompletionCallbackWithOutput<NetworkListPrivate>& callback) { |
| 32 if (has_interface<PPB_NetworkMonitor_Private_0_3>()) { |
| 33 return get_interface<PPB_NetworkMonitor_Private_0_3>()->UpdateNetworkList( |
| 34 pp_resource(), callback.output(), callback.pp_completion_callback()); |
| 35 } |
| 36 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 37 } |
| 38 |
30 // static | 39 // static |
31 bool NetworkMonitorPrivate::IsAvailable() { | 40 bool NetworkMonitorPrivate::IsAvailable() { |
32 return has_interface<PPB_NetworkMonitor_Private>(); | 41 return has_interface<PPB_NetworkMonitor_Private_0_3>(); |
33 } | 42 } |
34 | 43 |
35 } // namespace pp | 44 } // namespace pp |
OLD | NEW |