| 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 "webkit/plugins/ppapi/ppb_network_monitor_private_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_network_monitor_private_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ppapi/shared_impl/ppb_network_list_private_shared.h" | 8 #include "ppapi/shared_impl/ppb_network_list_private_shared.h" |
| 9 #include "ppapi/shared_impl/private/net_address_private_impl.h" | 9 #include "ppapi/shared_impl/private/net_address_private_impl.h" |
| 10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 void PPB_NetworkMonitor_Private_Impl::OnNetworkListChanged( | 59 void PPB_NetworkMonitor_Private_Impl::OnNetworkListChanged( |
| 60 const net::NetworkInterfaceList& list) { | 60 const net::NetworkInterfaceList& list) { |
| 61 ::ppapi::NetworkList list_copy(list.size()); | 61 ::ppapi::NetworkList list_copy(list.size()); |
| 62 for (size_t i = 0; i < list.size(); ++i) { | 62 for (size_t i = 0; i < list.size(); ++i) { |
| 63 ::ppapi::NetworkInfo& network = list_copy.at(i); | 63 ::ppapi::NetworkInfo& network = list_copy.at(i); |
| 64 network.name = list[i].name; | 64 network.name = list[i].name; |
| 65 | 65 |
| 66 network.addresses.resize( | 66 network.addresses.resize( |
| 67 1, ::ppapi::NetAddressPrivateImpl::kInvalidNetAddress); | 67 1, ::ppapi::NetAddressPrivateImpl::kInvalidNetAddress); |
| 68 bool result = ::ppapi::NetAddressPrivateImpl::IPEndPointToNetAddress( | 68 bool result = ::ppapi::NetAddressPrivateImpl::IPEndPointToNetAddress( |
| 69 net::IPEndPoint(list[i].address, 0), &(network.addresses[0])); | 69 list[i].address, 0, &(network.addresses[0])); |
| 70 DCHECK(result); | 70 DCHECK(result); |
| 71 | 71 |
| 72 // TODO(sergeyu): Currently net::NetworkInterfaceList provides | 72 // TODO(sergeyu): Currently net::NetworkInterfaceList provides |
| 73 // only name and one IP address. Add all other fields and copy | 73 // only name and one IP address. Add all other fields and copy |
| 74 // them here. | 74 // them here. |
| 75 network.type = PP_NETWORKLIST_UNKNOWN; | 75 network.type = PP_NETWORKLIST_UNKNOWN; |
| 76 network.state = PP_NETWORKLIST_UP; | 76 network.state = PP_NETWORKLIST_UP; |
| 77 network.display_name = list[i].name; | 77 network.display_name = list[i].name; |
| 78 network.mtu = 0; | 78 network.mtu = 0; |
| 79 } | 79 } |
| 80 scoped_refptr< ::ppapi::NetworkListStorage> list_storage( | 80 scoped_refptr< ::ppapi::NetworkListStorage> list_storage( |
| 81 new ::ppapi::NetworkListStorage(list_copy)); | 81 new ::ppapi::NetworkListStorage(list_copy)); |
| 82 PP_Resource list_resource = | 82 PP_Resource list_resource = |
| 83 ::ppapi::PPB_NetworkList_Private_Shared::Create( | 83 ::ppapi::PPB_NetworkList_Private_Shared::Create( |
| 84 ::ppapi::OBJECT_IS_IMPL, pp_instance(), list_storage); | 84 ::ppapi::OBJECT_IS_IMPL, pp_instance(), list_storage); |
| 85 callback_(user_data_, list_resource); | 85 callback_(user_data_, list_resource); |
| 86 } | 86 } |
| 87 | 87 |
| 88 } // namespace ppapi | 88 } // namespace ppapi |
| 89 } // namespace webkit | 89 } // namespace webkit |
| OLD | NEW |