OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "net/proxy/proxy_resolver_v8_tracing_wrapper.h" | 5 #include "net/proxy/proxy_resolver_v8_tracing_wrapper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
13 #include "net/log/net_log.h" | 14 #include "net/log/net_log.h" |
14 #include "net/proxy/proxy_resolver_error_observer.h" | 15 #include "net/proxy/proxy_resolver_error_observer.h" |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 namespace { | 18 namespace { |
18 | 19 |
19 // Returns event parameters for a PAC error message (line number + message). | 20 // Returns event parameters for a PAC error message (line number + message). |
20 scoped_ptr<base::Value> NetLogErrorCallback( | 21 scoped_ptr<base::Value> NetLogErrorCallback( |
21 int line_number, | 22 int line_number, |
22 const base::string16* message, | 23 const base::string16* message, |
23 NetLogCaptureMode /* capture_mode */) { | 24 NetLogCaptureMode /* capture_mode */) { |
24 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 25 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
25 dict->SetInteger("line_number", line_number); | 26 dict->SetInteger("line_number", line_number); |
26 dict->SetString("message", *message); | 27 dict->SetString("message", *message); |
27 return dict.Pass(); | 28 return std::move(dict); |
28 } | 29 } |
29 | 30 |
30 class BindingsImpl : public ProxyResolverV8Tracing::Bindings { | 31 class BindingsImpl : public ProxyResolverV8Tracing::Bindings { |
31 public: | 32 public: |
32 BindingsImpl(ProxyResolverErrorObserver* error_observer, | 33 BindingsImpl(ProxyResolverErrorObserver* error_observer, |
33 HostResolver* host_resolver, | 34 HostResolver* host_resolver, |
34 NetLog* net_log, | 35 NetLog* net_log, |
35 const BoundNetLog& bound_net_log) | 36 const BoundNetLog& bound_net_log) |
36 : error_observer_(error_observer), | 37 : error_observer_(error_observer), |
37 host_resolver_(host_resolver), | 38 host_resolver_(host_resolver), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 scoped_ptr<ProxyResolverErrorObserver> error_observer_; | 102 scoped_ptr<ProxyResolverErrorObserver> error_observer_; |
102 | 103 |
103 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8TracingWrapper); | 104 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8TracingWrapper); |
104 }; | 105 }; |
105 | 106 |
106 ProxyResolverV8TracingWrapper::ProxyResolverV8TracingWrapper( | 107 ProxyResolverV8TracingWrapper::ProxyResolverV8TracingWrapper( |
107 scoped_ptr<ProxyResolverV8Tracing> resolver_impl, | 108 scoped_ptr<ProxyResolverV8Tracing> resolver_impl, |
108 NetLog* net_log, | 109 NetLog* net_log, |
109 HostResolver* host_resolver, | 110 HostResolver* host_resolver, |
110 scoped_ptr<ProxyResolverErrorObserver> error_observer) | 111 scoped_ptr<ProxyResolverErrorObserver> error_observer) |
111 : resolver_impl_(resolver_impl.Pass()), | 112 : resolver_impl_(std::move(resolver_impl)), |
112 net_log_(net_log), | 113 net_log_(net_log), |
113 host_resolver_(host_resolver), | 114 host_resolver_(host_resolver), |
114 error_observer_(error_observer.Pass()) { | 115 error_observer_(std::move(error_observer)) {} |
115 } | |
116 | 116 |
117 int ProxyResolverV8TracingWrapper::GetProxyForURL( | 117 int ProxyResolverV8TracingWrapper::GetProxyForURL( |
118 const GURL& url, | 118 const GURL& url, |
119 ProxyInfo* results, | 119 ProxyInfo* results, |
120 const CompletionCallback& callback, | 120 const CompletionCallback& callback, |
121 RequestHandle* request, | 121 RequestHandle* request, |
122 const BoundNetLog& net_log) { | 122 const BoundNetLog& net_log) { |
123 resolver_impl_->GetProxyForURL( | 123 resolver_impl_->GetProxyForURL( |
124 url, results, callback, request, | 124 url, results, callback, request, |
125 make_scoped_ptr(new BindingsImpl(error_observer_.get(), host_resolver_, | 125 make_scoped_ptr(new BindingsImpl(error_observer_.get(), host_resolver_, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 | 180 |
181 void ProxyResolverFactoryV8TracingWrapper::OnProxyResolverCreated( | 181 void ProxyResolverFactoryV8TracingWrapper::OnProxyResolverCreated( |
182 scoped_ptr<scoped_ptr<ProxyResolverV8Tracing>> v8_resolver, | 182 scoped_ptr<scoped_ptr<ProxyResolverV8Tracing>> v8_resolver, |
183 scoped_ptr<ProxyResolver>* resolver, | 183 scoped_ptr<ProxyResolver>* resolver, |
184 const CompletionCallback& callback, | 184 const CompletionCallback& callback, |
185 scoped_ptr<ProxyResolverErrorObserver> error_observer, | 185 scoped_ptr<ProxyResolverErrorObserver> error_observer, |
186 int error) { | 186 int error) { |
187 if (error == OK) { | 187 if (error == OK) { |
188 resolver->reset(new ProxyResolverV8TracingWrapper( | 188 resolver->reset(new ProxyResolverV8TracingWrapper( |
189 v8_resolver->Pass(), net_log_, host_resolver_, error_observer.Pass())); | 189 std::move(*v8_resolver), net_log_, host_resolver_, |
| 190 std::move(error_observer))); |
190 } | 191 } |
191 callback.Run(error); | 192 callback.Run(error); |
192 } | 193 } |
193 | 194 |
194 } // namespace net | 195 } // namespace net |
OLD | NEW |