| OLD | NEW |
| 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 <utility> |
| 6 |
| 5 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 6 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 7 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 10 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 11 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 12 #include "base/test/perf_time_logger.h" | 14 #include "base/test/perf_time_logger.h" |
| 13 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 14 #include "net/dns/mock_host_resolver.h" | 16 #include "net/dns/mock_host_resolver.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 222 |
| 221 void OnError(int line_number, const base::string16& message) override { | 223 void OnError(int line_number, const base::string16& message) override { |
| 222 CHECK(false); | 224 CHECK(false); |
| 223 } | 225 } |
| 224 }; | 226 }; |
| 225 | 227 |
| 226 class ProxyResolverV8Wrapper : public ProxyResolver { | 228 class ProxyResolverV8Wrapper : public ProxyResolver { |
| 227 public: | 229 public: |
| 228 ProxyResolverV8Wrapper(scoped_ptr<ProxyResolverV8> resolver, | 230 ProxyResolverV8Wrapper(scoped_ptr<ProxyResolverV8> resolver, |
| 229 scoped_ptr<MockJSBindings> bindings) | 231 scoped_ptr<MockJSBindings> bindings) |
| 230 : resolver_(resolver.Pass()), bindings_(bindings.Pass()) {} | 232 : resolver_(std::move(resolver)), bindings_(std::move(bindings)) {} |
| 231 | 233 |
| 232 int GetProxyForURL(const GURL& url, | 234 int GetProxyForURL(const GURL& url, |
| 233 ProxyInfo* results, | 235 ProxyInfo* results, |
| 234 const CompletionCallback& /*callback*/, | 236 const CompletionCallback& /*callback*/, |
| 235 RequestHandle* /*request*/, | 237 RequestHandle* /*request*/, |
| 236 const BoundNetLog& net_log) override { | 238 const BoundNetLog& net_log) override { |
| 237 return resolver_->GetProxyForURL(url, results, bindings_.get()); | 239 return resolver_->GetProxyForURL(url, results, bindings_.get()); |
| 238 } | 240 } |
| 239 | 241 |
| 240 void CancelRequest(RequestHandle request) override { NOTREACHED(); } | 242 void CancelRequest(RequestHandle request) override { NOTREACHED(); } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 257 int CreateProxyResolver( | 259 int CreateProxyResolver( |
| 258 const scoped_refptr<ProxyResolverScriptData>& pac_script, | 260 const scoped_refptr<ProxyResolverScriptData>& pac_script, |
| 259 scoped_ptr<ProxyResolver>* resolver, | 261 scoped_ptr<ProxyResolver>* resolver, |
| 260 const net::CompletionCallback& callback, | 262 const net::CompletionCallback& callback, |
| 261 scoped_ptr<Request>* request) override { | 263 scoped_ptr<Request>* request) override { |
| 262 scoped_ptr<ProxyResolverV8> v8_resolver; | 264 scoped_ptr<ProxyResolverV8> v8_resolver; |
| 263 scoped_ptr<MockJSBindings> js_bindings_(new MockJSBindings); | 265 scoped_ptr<MockJSBindings> js_bindings_(new MockJSBindings); |
| 264 int result = | 266 int result = |
| 265 ProxyResolverV8::Create(pac_script, js_bindings_.get(), &v8_resolver); | 267 ProxyResolverV8::Create(pac_script, js_bindings_.get(), &v8_resolver); |
| 266 if (result == OK) { | 268 if (result == OK) { |
| 267 resolver->reset( | 269 resolver->reset(new ProxyResolverV8Wrapper(std::move(v8_resolver), |
| 268 new ProxyResolverV8Wrapper(v8_resolver.Pass(), js_bindings_.Pass())); | 270 std::move(js_bindings_))); |
| 269 } | 271 } |
| 270 return result; | 272 return result; |
| 271 } | 273 } |
| 272 | 274 |
| 273 private: | 275 private: |
| 274 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8Factory); | 276 DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8Factory); |
| 275 }; | 277 }; |
| 276 | 278 |
| 277 TEST(ProxyResolverPerfTest, ProxyResolverV8) { | 279 TEST(ProxyResolverPerfTest, ProxyResolverV8) { |
| 278 base::MessageLoop message_loop; | 280 base::MessageLoop message_loop; |
| 279 ProxyResolverV8Factory factory; | 281 ProxyResolverV8Factory factory; |
| 280 PacPerfSuiteRunner runner(&factory, "ProxyResolverV8"); | 282 PacPerfSuiteRunner runner(&factory, "ProxyResolverV8"); |
| 281 runner.RunAllTests(); | 283 runner.RunAllTests(); |
| 282 } | 284 } |
| 283 | 285 |
| 284 } // namespace | 286 } // namespace |
| 285 | 287 |
| 286 } // namespace net | 288 } // namespace net |
| OLD | NEW |