| 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_list_private.h" | 5 #include "ppapi/cpp/network_list.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/cpp/array_output.h" | 8 #include "ppapi/cpp/array_output.h" |
| 9 #include "ppapi/cpp/logging.h" | 9 #include "ppapi/cpp/logging.h" |
| 10 #include "ppapi/cpp/module_impl.h" | 10 #include "ppapi/cpp/module_impl.h" |
| 11 #include "ppapi/cpp/net_address.h" | 11 #include "ppapi/cpp/net_address.h" |
| 12 #include "ppapi/cpp/var.h" | 12 #include "ppapi/cpp/var.h" |
| 13 | 13 |
| 14 namespace pp { | 14 namespace pp { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 template <> const char* interface_name<PPB_NetworkList_Private_0_3>() { | 18 template <> const char* interface_name<PPB_NetworkList_1_0>() { |
| 19 return PPB_NETWORKLIST_PRIVATE_INTERFACE_0_3; | 19 return PPB_NETWORKLIST_INTERFACE_1_0; |
| 20 } | 20 } |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 NetworkListPrivate::NetworkListPrivate() { | 24 NetworkList::NetworkList() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 NetworkListPrivate::NetworkListPrivate(PassRef, PP_Resource resource) | 27 NetworkList::NetworkList(PassRef, PP_Resource resource) |
| 28 : Resource(PASS_REF, resource) { | 28 : Resource(PASS_REF, resource) { |
| 29 } | 29 } |
| 30 | 30 |
| 31 // static | 31 // static |
| 32 bool NetworkListPrivate::IsAvailable() { | 32 bool NetworkList::IsAvailable() { |
| 33 return has_interface<PPB_NetworkList_Private_0_3>(); | 33 return has_interface<PPB_NetworkList_1_0>(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 uint32_t NetworkListPrivate::GetCount() const { | 36 uint32_t NetworkList::GetCount() const { |
| 37 if (!has_interface<PPB_NetworkList_Private_0_3>()) | 37 if (!has_interface<PPB_NetworkList_1_0>()) |
| 38 return 0; | 38 return 0; |
| 39 return get_interface<PPB_NetworkList_Private_0_3>()->GetCount(pp_resource()); | 39 return get_interface<PPB_NetworkList_1_0>()->GetCount(pp_resource()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 std::string NetworkListPrivate::GetName(uint32_t index) const { | 42 std::string NetworkList::GetName(uint32_t index) const { |
| 43 if (!has_interface<PPB_NetworkList_Private_0_3>()) | 43 if (!has_interface<PPB_NetworkList_1_0>()) |
| 44 return std::string(); | 44 return std::string(); |
| 45 Var result(PASS_REF, | 45 Var result(PASS_REF, |
| 46 get_interface<PPB_NetworkList_Private_0_3>()->GetName( | 46 get_interface<PPB_NetworkList_1_0>()->GetName( |
| 47 pp_resource(), index)); | 47 pp_resource(), index)); |
| 48 return result.is_string() ? result.AsString() : std::string(); | 48 return result.is_string() ? result.AsString() : std::string(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 PP_NetworkListType_Private NetworkListPrivate::GetType(uint32_t index) const { | 51 PP_NetworkList_Type NetworkList::GetType(uint32_t index) const { |
| 52 if (!has_interface<PPB_NetworkList_Private_0_3>()) | 52 if (!has_interface<PPB_NetworkList_1_0>()) |
| 53 return PP_NETWORKLIST_ETHERNET; | 53 return PP_NETWORKLIST_TYPE_ETHERNET; |
| 54 return get_interface<PPB_NetworkList_Private_0_3>()->GetType( | 54 return get_interface<PPB_NetworkList_1_0>()->GetType( |
| 55 pp_resource(), index); | 55 pp_resource(), index); |
| 56 } | 56 } |
| 57 | 57 |
| 58 PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) const { | 58 PP_NetworkList_State NetworkList::GetState(uint32_t index) const { |
| 59 if (!has_interface<PPB_NetworkList_Private_0_3>()) | 59 if (!has_interface<PPB_NetworkList_1_0>()) |
| 60 return PP_NETWORKLIST_DOWN; | 60 return PP_NETWORKLIST_STATE_DOWN; |
| 61 return get_interface<PPB_NetworkList_Private_0_3>()->GetState( | 61 return get_interface<PPB_NetworkList_1_0>()->GetState( |
| 62 pp_resource(), index); | 62 pp_resource(), index); |
| 63 } | 63 } |
| 64 | 64 |
| 65 int32_t NetworkListPrivate::GetIpAddresses( | 65 int32_t NetworkList::GetIpAddresses( |
| 66 uint32_t index, | 66 uint32_t index, |
| 67 std::vector<NetAddress>* addresses) const { | 67 std::vector<NetAddress>* addresses) const { |
| 68 if (!has_interface<PPB_NetworkList_Private_0_3>()) | 68 if (!has_interface<PPB_NetworkList_1_0>()) |
| 69 return PP_ERROR_NOINTERFACE; | 69 return PP_ERROR_NOINTERFACE; |
| 70 if (!addresses) | 70 if (!addresses) |
| 71 return PP_ERROR_BADARGUMENT; | 71 return PP_ERROR_BADARGUMENT; |
| 72 | 72 |
| 73 ResourceArrayOutputAdapter<NetAddress> adapter(addresses); | 73 ResourceArrayOutputAdapter<NetAddress> adapter(addresses); |
| 74 return get_interface<PPB_NetworkList_Private_0_3>()->GetIpAddresses( | 74 return get_interface<PPB_NetworkList_1_0>()->GetIpAddresses( |
| 75 pp_resource(), index, adapter.pp_array_output()); | 75 pp_resource(), index, adapter.pp_array_output()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 std::string NetworkListPrivate::GetDisplayName(uint32_t index) const { | 78 std::string NetworkList::GetDisplayName(uint32_t index) const { |
| 79 if (!has_interface<PPB_NetworkList_Private_0_3>()) | 79 if (!has_interface<PPB_NetworkList_1_0>()) |
| 80 return std::string(); | 80 return std::string(); |
| 81 Var result(PASS_REF, | 81 Var result(PASS_REF, |
| 82 get_interface<PPB_NetworkList_Private_0_3>()->GetDisplayName( | 82 get_interface<PPB_NetworkList_1_0>()->GetDisplayName( |
| 83 pp_resource(), index)); | 83 pp_resource(), index)); |
| 84 return result.is_string() ? result.AsString() : std::string(); | 84 return result.is_string() ? result.AsString() : std::string(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 uint32_t NetworkListPrivate::GetMTU(uint32_t index) const { | 87 uint32_t NetworkList::GetMTU(uint32_t index) const { |
| 88 if (!has_interface<PPB_NetworkList_Private_0_3>()) | 88 if (!has_interface<PPB_NetworkList_1_0>()) |
| 89 return 0; | 89 return 0; |
| 90 return get_interface<PPB_NetworkList_Private_0_3>()->GetMTU( | 90 return get_interface<PPB_NetworkList_1_0>()->GetMTU( |
| 91 pp_resource(), index); | 91 pp_resource(), index); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace pp | 94 } // namespace pp |
| OLD | NEW |