Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: webkit/plugins/ppapi/ppb_network_monitor_private_impl.cc

Issue 9677060: Out-of-process implementation of the PPB_NetworkMonitor_Private interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/thunk/ppb_network_list_private_api.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
10 #include "net/base/ip_endpoint.h"
9 #include "net/base/net_util.h" 11 #include "net/base/net_util.h"
10 #include "webkit/plugins/ppapi/resource_helper.h" 12 #include "webkit/plugins/ppapi/resource_helper.h"
11 13
12 namespace webkit { 14 namespace webkit {
13 namespace ppapi { 15 namespace ppapi {
14 16
15 PPB_NetworkMonitor_Private_Impl::PPB_NetworkMonitor_Private_Impl( 17 PPB_NetworkMonitor_Private_Impl::PPB_NetworkMonitor_Private_Impl(
16 PP_Instance instance, 18 PP_Instance instance,
17 PPB_NetworkMonitor_Callback callback, 19 PPB_NetworkMonitor_Callback callback,
18 void* user_data) 20 void* user_data)
(...skipping 30 matching lines...) Expand all
49 bool PPB_NetworkMonitor_Private_Impl::Start() { 51 bool PPB_NetworkMonitor_Private_Impl::Start() {
50 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); 52 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
51 if (!plugin_delegate) 53 if (!plugin_delegate)
52 return false; 54 return false;
53 started_ = plugin_delegate->AddNetworkListObserver(this); 55 started_ = plugin_delegate->AddNetworkListObserver(this);
54 return started_; 56 return started_;
55 } 57 }
56 58
57 void PPB_NetworkMonitor_Private_Impl::OnNetworkListChanged( 59 void PPB_NetworkMonitor_Private_Impl::OnNetworkListChanged(
58 const net::NetworkInterfaceList& list) { 60 const net::NetworkInterfaceList& list) {
59 scoped_ptr< ::ppapi::PPB_NetworkList_Private_Shared::NetworkList> list_copy( 61 ::ppapi::NetworkList list_copy(list.size());
60 new ::ppapi::PPB_NetworkList_Private_Shared::NetworkList(list.size()));
61 for (size_t i = 0; i < list.size(); ++i) { 62 for (size_t i = 0; i < list.size(); ++i) {
62 ::ppapi::PPB_NetworkList_Private_Shared::NetworkInfo& network = 63 ::ppapi::NetworkInfo& network = list_copy.at(i);
63 list_copy->at(i);
64 network.name = list[i].name; 64 network.name = list[i].name;
65 65
66 network.addresses.resize(1); 66 network.addresses.resize(
67 CHECK_LE(list[i].address.size(), sizeof(network.addresses[0].data)); 67 1, ::ppapi::NetAddressPrivateImpl::kInvalidNetAddress);
68 network.addresses[0].size = list[i].address.size(); 68 bool result = ::ppapi::NetAddressPrivateImpl::IPEndPointToNetAddress(
69 memcpy(network.addresses[0].data, &(list[i].address.front()), 69 net::IPEndPoint(list[i].address, 0), &(network.addresses[0]));
70 list[i].address.size()); 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(
81 new ::ppapi::NetworkListStorage(list_copy));
80 PP_Resource list_resource = 82 PP_Resource list_resource =
81 ::ppapi::PPB_NetworkList_Private_Shared::Create( 83 ::ppapi::PPB_NetworkList_Private_Shared::Create(
82 ::ppapi::OBJECT_IS_IMPL, pp_instance(), list_copy.Pass()); 84 ::ppapi::OBJECT_IS_IMPL, pp_instance(), list_storage);
83 callback_(user_data_, list_resource); 85 callback_(user_data_, list_resource);
84 } 86 }
85 87
86 } // namespace ppapi 88 } // namespace ppapi
87 } // namespace webkit 89 } // namespace webkit
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_network_list_private_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698