| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/renderer_host/pepper/pepper_network_monitor_host.h" | 5 #include "content/browser/renderer_host/pepper/pepper_network_monitor_host.h" |
| 6 | 6 |
| 7 #include "base/task_runner_util.h" | 7 #include "base/task_runner_util.h" |
| 8 #include "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
| 9 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" | 9 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" |
| 10 #include "content/browser/renderer_host/pepper/pepper_socket_utils.h" | 10 #include "content/browser/renderer_host/pepper/pepper_socket_utils.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/common/socket_permission_request.h" | 12 #include "content/public/common/socket_permission_request.h" |
| 13 #include "ppapi/proxy/ppapi_messages.h" | 13 #include "ppapi/proxy/ppapi_messages.h" |
| 14 #include "ppapi/shared_impl/private/net_address_private_impl.h" | 14 #include "ppapi/shared_impl/private/net_address_private_impl.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 bool CanUseNetworkMonitor(bool external_plugin, | 20 bool CanUseNetworkMonitor(bool external_plugin, |
| 21 int render_process_id, | 21 int render_process_id, |
| 22 int render_view_id) { | 22 int render_view_id) { |
| 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 24 | 24 |
| 25 SocketPermissionRequest request = SocketPermissionRequest( | 25 SocketPermissionRequest request = SocketPermissionRequest( |
| 26 SocketPermissionRequest::NETWORK_STATE, std::string(), 0); | 26 SocketPermissionRequest::NETWORK_STATE, std::string(), 0); |
| 27 return pepper_socket_utils::CanUseSocketAPIs( | 27 return pepper_socket_utils::CanUseSocketAPIs( |
| 28 external_plugin, true /* private_api */, request, render_process_id, | 28 external_plugin, false /* private_api */, request, render_process_id, |
| 29 render_view_id); | 29 render_view_id); |
| 30 } | 30 } |
| 31 | 31 |
| 32 scoped_ptr<net::NetworkInterfaceList> GetNetworkList() { | 32 scoped_ptr<net::NetworkInterfaceList> GetNetworkList() { |
| 33 scoped_ptr<net::NetworkInterfaceList> list(new net::NetworkInterfaceList()); | 33 scoped_ptr<net::NetworkInterfaceList> list(new net::NetworkInterfaceList()); |
| 34 net::GetNetworkList(list.get()); | 34 net::GetNetworkList(list.get()); |
| 35 return list.Pass(); | 35 return list.Pass(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 network_copy.addresses.resize( | 102 network_copy.addresses.resize( |
| 103 1, ppapi::NetAddressPrivateImpl::kInvalidNetAddress); | 103 1, ppapi::NetAddressPrivateImpl::kInvalidNetAddress); |
| 104 bool result = ppapi::NetAddressPrivateImpl::IPEndPointToNetAddress( | 104 bool result = ppapi::NetAddressPrivateImpl::IPEndPointToNetAddress( |
| 105 network.address, 0, &(network_copy.addresses[0])); | 105 network.address, 0, &(network_copy.addresses[0])); |
| 106 DCHECK(result); | 106 DCHECK(result); |
| 107 | 107 |
| 108 // TODO(sergeyu): Currently net::NetworkInterfaceList provides | 108 // TODO(sergeyu): Currently net::NetworkInterfaceList provides |
| 109 // only name and one IP address. Add all other fields and copy | 109 // only name and one IP address. Add all other fields and copy |
| 110 // them here. | 110 // them here. |
| 111 network_copy.type = PP_NETWORKLIST_UNKNOWN; | 111 network_copy.type = PP_NETWORKLIST_TYPE_UNKNOWN; |
| 112 network_copy.state = PP_NETWORKLIST_UP; | 112 network_copy.state = PP_NETWORKLIST_STATE_UP; |
| 113 network_copy.display_name = network.name; | 113 network_copy.display_name = network.name; |
| 114 network_copy.mtu = 0; | 114 network_copy.mtu = 0; |
| 115 } | 115 } |
| 116 host()->SendUnsolicitedReply( | 116 host()->SendUnsolicitedReply( |
| 117 pp_resource(), PpapiPluginMsg_NetworkMonitor_NetworkList(*list_copy)); | 117 pp_resource(), PpapiPluginMsg_NetworkMonitor_NetworkList(*list_copy)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace content | 120 } // namespace content |
| OLD | NEW |