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

Side by Side Diff: extensions/browser/api/system_network/system_network_api.cc

Issue 2646703002: Remove usage of AsyncExtensionFunction::results_ in system_network_api.cc (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « extensions/browser/api/system_network/system_network_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 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 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 api {
13 13
14 SystemNetworkGetNetworkInterfacesFunction:: 14 SystemNetworkGetNetworkInterfacesFunction::
15 SystemNetworkGetNetworkInterfacesFunction() { 15 SystemNetworkGetNetworkInterfacesFunction() {
16 } 16 }
17 17
18 SystemNetworkGetNetworkInterfacesFunction:: 18 SystemNetworkGetNetworkInterfacesFunction::
19 ~SystemNetworkGetNetworkInterfacesFunction() { 19 ~SystemNetworkGetNetworkInterfacesFunction() {
20 } 20 }
21 21
22 bool SystemNetworkGetNetworkInterfacesFunction::RunAsync() { 22 ExtensionFunction::ResponseAction
23 SystemNetworkGetNetworkInterfacesFunction::Run() {
23 content::BrowserThread::PostTask( 24 content::BrowserThread::PostTask(
24 content::BrowserThread::FILE, 25 content::BrowserThread::FILE,
25 FROM_HERE, 26 FROM_HERE,
26 base::Bind( 27 base::Bind(
27 &SystemNetworkGetNetworkInterfacesFunction::GetListOnFileThread, 28 &SystemNetworkGetNetworkInterfacesFunction::GetListOnFileThread,
28 this)); 29 this));
29 return true; 30 return RespondLater();
30 } 31 }
31 32
32 void SystemNetworkGetNetworkInterfacesFunction::GetListOnFileThread() { 33 void SystemNetworkGetNetworkInterfacesFunction::GetListOnFileThread() {
33 net::NetworkInterfaceList interface_list; 34 net::NetworkInterfaceList interface_list;
34 if (net::GetNetworkList(&interface_list, 35 if (net::GetNetworkList(&interface_list,
35 net::INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES)) { 36 net::INCLUDE_HOST_SCOPE_VIRTUAL_INTERFACES)) {
36 content::BrowserThread::PostTask( 37 content::BrowserThread::PostTask(
37 content::BrowserThread::UI, 38 content::BrowserThread::UI,
38 FROM_HERE, 39 FROM_HERE,
39 base::Bind( 40 base::Bind(
40 &SystemNetworkGetNetworkInterfacesFunction::SendResponseOnUIThread, 41 &SystemNetworkGetNetworkInterfacesFunction::SendResponseOnUIThread,
41 this, 42 this,
42 interface_list)); 43 interface_list));
43 return; 44 return;
44 } 45 }
45 46
46 content::BrowserThread::PostTask( 47 content::BrowserThread::PostTask(
47 content::BrowserThread::UI, 48 content::BrowserThread::UI,
48 FROM_HERE, 49 FROM_HERE,
49 base::Bind(&SystemNetworkGetNetworkInterfacesFunction::HandleGetListError, 50 base::Bind(&SystemNetworkGetNetworkInterfacesFunction::HandleGetListError,
50 this)); 51 this));
51 } 52 }
52 53
53 void SystemNetworkGetNetworkInterfacesFunction::HandleGetListError() { 54 void SystemNetworkGetNetworkInterfacesFunction::HandleGetListError() {
54 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 55 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
55 error_ = kNetworkListError; 56 Respond(Error(kNetworkListError));
56 SendResponse(false);
57 } 57 }
58 58
59 void SystemNetworkGetNetworkInterfacesFunction::SendResponseOnUIThread( 59 void SystemNetworkGetNetworkInterfacesFunction::SendResponseOnUIThread(
60 const net::NetworkInterfaceList& interface_list) { 60 const net::NetworkInterfaceList& interface_list) {
61 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 61 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
62 62
63 std::vector<api::system_network::NetworkInterface> create_arg; 63 std::vector<api::system_network::NetworkInterface> create_arg;
64 create_arg.reserve(interface_list.size()); 64 create_arg.reserve(interface_list.size());
65 for (const net::NetworkInterface& interface : interface_list) { 65 for (const net::NetworkInterface& interface : interface_list) {
66 api::system_network::NetworkInterface info; 66 api::system_network::NetworkInterface info;
67 info.name = interface.name; 67 info.name = interface.name;
68 info.address = interface.address.ToString(); 68 info.address = interface.address.ToString();
69 info.prefix_length = interface.prefix_length; 69 info.prefix_length = interface.prefix_length;
70 create_arg.push_back(std::move(info)); 70 create_arg.push_back(std::move(info));
71 } 71 }
72 72
73 results_ = 73 Respond(ArgumentList(
74 api::system_network::GetNetworkInterfaces::Results::Create(create_arg); 74 api::system_network::GetNetworkInterfaces::Results::Create(create_arg)));
75 SendResponse(true);
76 } 75 }
77 76
78 } // namespace api 77 } // namespace api
79 } // namespace extensions 78 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/system_network/system_network_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698