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 "chrome/browser/extensions/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 |
(...skipping 25 matching lines...) Expand all Loading... |
36 return; | 36 return; |
37 } | 37 } |
38 | 38 |
39 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 39 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
40 base::Bind(&SystemNetworkGetNetworkInterfacesFunction:: | 40 base::Bind(&SystemNetworkGetNetworkInterfacesFunction:: |
41 HandleGetListError, | 41 HandleGetListError, |
42 this)); | 42 this)); |
43 } | 43 } |
44 | 44 |
45 void SystemNetworkGetNetworkInterfacesFunction::HandleGetListError() { | 45 void SystemNetworkGetNetworkInterfacesFunction::HandleGetListError() { |
46 DCHECK(content::BrowserThread::CurrentlyOn(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(content::BrowserThread::CurrentlyOn(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<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<api::system_network::NetworkInterface> info = |
61 make_linked_ptr(new api::system_network::NetworkInterface); | 61 make_linked_ptr(new 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_ = 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 api |
74 } // namespace extensions | 74 } // namespace extensions |
OLD | NEW |