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

Side by Side Diff: chromeos/dbus/services/proxy_resolution_service_provider.cc

Issue 2787253002: chromeos: Simplify D-Bus proxy provider (but not tests). (Closed)
Patch Set: Created 3 years, 8 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
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 "chromeos/dbus/services/proxy_resolution_service_provider.h" 5 #include "chromeos/dbus/services/proxy_resolution_service_provider.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "dbus/bus.h" 14 #include "dbus/bus.h"
15 #include "dbus/message.h" 15 #include "dbus/message.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/log/net_log_with_source.h" 17 #include "net/log/net_log_with_source.h"
18 #include "net/proxy/proxy_info.h" 18 #include "net/proxy/proxy_info.h"
19 #include "net/proxy/proxy_service.h"
19 #include "net/url_request/url_request_context.h" 20 #include "net/url_request/url_request_context.h"
20 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
21 #include "third_party/cros_system_api/dbus/service_constants.h" 22 #include "third_party/cros_system_api/dbus/service_constants.h"
22 #include "url/gurl.h" 23 #include "url/gurl.h"
23 24
24 namespace chromeos { 25 namespace chromeos {
25 26
26 struct ProxyResolutionServiceProvider::Request { 27 struct ProxyResolutionServiceProvider::Request {
27 public: 28 public:
28 // Constructor for returning proxy info via an asynchronous D-Bus response. 29 // Constructor for returning proxy info via an asynchronous D-Bus response.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return; 192 return;
192 } 193 }
193 194
194 Request* request_ptr = request.get(); 195 Request* request_ptr = request.get();
195 net::CompletionCallback callback = base::Bind( 196 net::CompletionCallback callback = base::Bind(
196 &ProxyResolutionServiceProvider::OnResolutionComplete, 197 &ProxyResolutionServiceProvider::OnResolutionComplete,
197 weak_ptr_factory_.GetWeakPtr(), base::Passed(std::move(request))); 198 weak_ptr_factory_.GetWeakPtr(), base::Passed(std::move(request)));
198 199
199 VLOG(1) << "Starting network proxy resolution for " 200 VLOG(1) << "Starting network proxy resolution for "
200 << request_ptr->source_url; 201 << request_ptr->source_url;
201 const int result = 202 const int result = proxy_service->ResolveProxy(
James Cook 2017/03/31 17:33:10 optional: net::Error (or do we prefer int for erro
Daniel Erat 2017/03/31 17:46:37 i was actually confused about this too. net::Proxy
202 delegate_->ResolveProxy(proxy_service, GURL(request_ptr->source_url), 203 GURL(request_ptr->source_url), std::string(), &request_ptr->proxy_info,
203 &request_ptr->proxy_info, callback); 204 callback, nullptr, nullptr, net::NetLogWithSource());
204 if (result != net::ERR_IO_PENDING) { 205 if (result != net::ERR_IO_PENDING) {
205 VLOG(1) << "Network proxy resolution completed synchronously."; 206 VLOG(1) << "Network proxy resolution completed synchronously.";
206 callback.Run(result); 207 callback.Run(result);
207 } 208 }
208 } 209 }
209 210
210 void ProxyResolutionServiceProvider::OnResolutionComplete( 211 void ProxyResolutionServiceProvider::OnResolutionComplete(
211 std::unique_ptr<Request> request, 212 std::unique_ptr<Request> request,
212 int result) { 213 int result) {
213 DCHECK(request->context_getter->GetNetworkTaskRunner() 214 DCHECK(request->context_getter->GetNetworkTaskRunner()
(...skipping 25 matching lines...) Expand all
239 dbus::MessageWriter writer(&signal); 240 dbus::MessageWriter writer(&signal);
240 writer.AppendString(request->source_url); 241 writer.AppendString(request->source_url);
241 writer.AppendString(request->proxy_info.ToPacString()); 242 writer.AppendString(request->proxy_info.ToPacString());
242 writer.AppendString(request->error); 243 writer.AppendString(request->error);
243 exported_object_->SendSignal(&signal); 244 exported_object_->SendSignal(&signal);
244 VLOG(1) << "Sending signal: " << signal.ToString(); 245 VLOG(1) << "Sending signal: " << signal.ToString();
245 } 246 }
246 } 247 }
247 248
248 } // namespace chromeos 249 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698