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

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
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 "net/base/net_util.h" 9 #include "net/base/net_util.h"
10 #include "webkit/plugins/ppapi/resource_helper.h" 10 #include "webkit/plugins/ppapi/resource_helper.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 bool PPB_NetworkMonitor_Private_Impl::Start() { 49 bool PPB_NetworkMonitor_Private_Impl::Start() {
50 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); 50 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
51 if (!plugin_delegate) 51 if (!plugin_delegate)
52 return false; 52 return false;
53 started_ = plugin_delegate->AddNetworkListObserver(this); 53 started_ = plugin_delegate->AddNetworkListObserver(this);
54 return started_; 54 return started_;
55 } 55 }
56 56
57 void PPB_NetworkMonitor_Private_Impl::OnNetworkListChanged( 57 void PPB_NetworkMonitor_Private_Impl::OnNetworkListChanged(
58 const net::NetworkInterfaceList& list) { 58 const net::NetworkInterfaceList& list) {
59 scoped_ptr< ::ppapi::PPB_NetworkList_Private_Shared::NetworkList> list_copy( 59 ::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) { 60 for (size_t i = 0; i < list.size(); ++i) {
62 ::ppapi::PPB_NetworkList_Private_Shared::NetworkInfo& network = 61 ::ppapi::NetworkInfo& network = list_copy.at(i);
63 list_copy->at(i);
64 network.name = list[i].name; 62 network.name = list[i].name;
65 63
66 network.addresses.resize(1); 64 network.addresses.resize(1);
67 CHECK_LE(list[i].address.size(), sizeof(network.addresses[0].data)); 65 CHECK_LE(list[i].address.size(), sizeof(network.addresses[0].data));
68 network.addresses[0].size = list[i].address.size(); 66 network.addresses[0].size = list[i].address.size();
69 memcpy(network.addresses[0].data, &(list[i].address.front()), 67 memcpy(network.addresses[0].data, &(list[i].address.front()),
70 list[i].address.size()); 68 list[i].address.size());
71 69
72 // TODO(sergeyu): Currently net::NetworkInterfaceList provides 70 // TODO(sergeyu): Currently net::NetworkInterfaceList provides
73 // only name and one IP address. Add all other fields and copy 71 // only name and one IP address. Add all other fields and copy
74 // them here. 72 // them here.
75 network.type = PP_NETWORKLIST_UNKNOWN; 73 network.type = PP_NETWORKLIST_UNKNOWN;
76 network.state = PP_NETWORKLIST_UP; 74 network.state = PP_NETWORKLIST_UP;
77 network.display_name = list[i].name; 75 network.display_name = list[i].name;
78 network.mtu = 0; 76 network.mtu = 0;
79 } 77 }
78 scoped_refptr< ::ppapi::NetworkListStorage> list_storage(
79 new ::ppapi::NetworkListStorage(list_copy));
80 PP_Resource list_resource = 80 PP_Resource list_resource =
81 ::ppapi::PPB_NetworkList_Private_Shared::Create( 81 ::ppapi::PPB_NetworkList_Private_Shared::Create(
82 ::ppapi::OBJECT_IS_IMPL, pp_instance(), list_copy.Pass()); 82 ::ppapi::OBJECT_IS_IMPL, pp_instance(), list_storage);
83 callback_(user_data_, list_resource); 83 callback_(user_data_, list_resource);
84 } 84 }
85 85
86 } // namespace ppapi 86 } // namespace ppapi
87 } // namespace webkit 87 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698