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