| 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 "extensions/browser/api/system_network/system_network_api.h" | 5 #include "extensions/browser/api/system_network/system_network_api.h" |
| 6 | 6 |
| 7 #include "net/base/ip_address_number.h" | 7 #include "net/base/ip_address_number.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 const char kNetworkListError[] = "Network lookup failed or unsupported"; | 10 const char kNetworkListError[] = "Network lookup failed or unsupported"; |
| 11 } // namespace | 11 } // namespace |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 namespace core_api { | 14 namespace api { |
| 15 | 15 |
| 16 SystemNetworkGetNetworkInterfacesFunction:: | 16 SystemNetworkGetNetworkInterfacesFunction:: |
| 17 SystemNetworkGetNetworkInterfacesFunction() { | 17 SystemNetworkGetNetworkInterfacesFunction() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 SystemNetworkGetNetworkInterfacesFunction:: | 20 SystemNetworkGetNetworkInterfacesFunction:: |
| 21 ~SystemNetworkGetNetworkInterfacesFunction() { | 21 ~SystemNetworkGetNetworkInterfacesFunction() { |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool SystemNetworkGetNetworkInterfacesFunction::RunAsync() { | 24 bool SystemNetworkGetNetworkInterfacesFunction::RunAsync() { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 55 void SystemNetworkGetNetworkInterfacesFunction::HandleGetListError() { | 55 void SystemNetworkGetNetworkInterfacesFunction::HandleGetListError() { |
| 56 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 56 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 57 error_ = kNetworkListError; | 57 error_ = kNetworkListError; |
| 58 SendResponse(false); | 58 SendResponse(false); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void SystemNetworkGetNetworkInterfacesFunction::SendResponseOnUIThread( | 61 void SystemNetworkGetNetworkInterfacesFunction::SendResponseOnUIThread( |
| 62 const net::NetworkInterfaceList& interface_list) { | 62 const net::NetworkInterfaceList& interface_list) { |
| 63 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 63 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 64 | 64 |
| 65 std::vector<linked_ptr<core_api::system_network::NetworkInterface> > | 65 std::vector<linked_ptr<api::system_network::NetworkInterface>> create_arg; |
| 66 create_arg; | |
| 67 create_arg.reserve(interface_list.size()); | 66 create_arg.reserve(interface_list.size()); |
| 68 for (net::NetworkInterfaceList::const_iterator i = interface_list.begin(); | 67 for (net::NetworkInterfaceList::const_iterator i = interface_list.begin(); |
| 69 i != interface_list.end(); | 68 i != interface_list.end(); |
| 70 ++i) { | 69 ++i) { |
| 71 linked_ptr<core_api::system_network::NetworkInterface> info = | 70 linked_ptr<api::system_network::NetworkInterface> info = |
| 72 make_linked_ptr(new core_api::system_network::NetworkInterface); | 71 make_linked_ptr(new api::system_network::NetworkInterface); |
| 73 info->name = i->name; | 72 info->name = i->name; |
| 74 info->address = net::IPAddressToString(i->address); | 73 info->address = net::IPAddressToString(i->address); |
| 75 info->prefix_length = i->prefix_length; | 74 info->prefix_length = i->prefix_length; |
| 76 create_arg.push_back(info); | 75 create_arg.push_back(info); |
| 77 } | 76 } |
| 78 | 77 |
| 79 results_ = core_api::system_network::GetNetworkInterfaces::Results::Create( | 78 results_ = |
| 80 create_arg); | 79 api::system_network::GetNetworkInterfaces::Results::Create(create_arg); |
| 81 SendResponse(true); | 80 SendResponse(true); |
| 82 } | 81 } |
| 83 | 82 |
| 84 } // namespace core_api | 83 } // namespace api |
| 85 } // namespace extensions | 84 } // namespace extensions |
| OLD | NEW |