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

Side by Side Diff: net/proxy/proxy_resolver_v8_tracing_unittest.cc

Issue 1126513002: Add ProxyResolverFactoryV8Tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-proxy-refactor
Patch Set: Created 5 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "net/proxy/proxy_resolver_v8_tracing.h" 5 #include "net/proxy/proxy_resolver_v8_tracing.h"
6 6
7 #include <string>
8
7 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
8 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
9 #include "base/path_service.h" 11 #include "base/path_service.h"
10 #include "base/stl_util.h" 12 #include "base/stl_util.h"
11 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
14 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
15 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
16 #include "base/values.h" 18 #include "base/values.h"
17 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
18 #include "net/base/test_completion_callback.h" 20 #include "net/base/test_completion_callback.h"
19 #include "net/dns/host_cache.h" 21 #include "net/dns/host_cache.h"
20 #include "net/dns/mock_host_resolver.h" 22 #include "net/dns/mock_host_resolver.h"
21 #include "net/log/captured_net_log_entry.h" 23 #include "net/log/captured_net_log_entry.h"
22 #include "net/log/net_log.h" 24 #include "net/log/net_log.h"
23 #include "net/log/net_log_unittest.h" 25 #include "net/log/net_log_unittest.h"
24 #include "net/log/test_net_log.h" 26 #include "net/log/test_net_log.h"
25 #include "net/proxy/proxy_info.h" 27 #include "net/proxy/proxy_info.h"
26 #include "net/proxy/proxy_resolver_error_observer.h" 28 #include "net/proxy/proxy_resolver_error_observer.h"
27 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
28 #include "url/gurl.h" 30 #include "url/gurl.h"
29 31
30 namespace net { 32 namespace net {
31 33
32 namespace { 34 namespace {
33 35
36 class SingleShotProxyResolverFactoryV8Tracing
37 : public ProxyResolverFactoryV8Tracing {
38 public:
39 SingleShotProxyResolverFactoryV8Tracing(
40 HostResolver* host_resolver,
41 NetLog* net_log,
42 const ProxyResolver::LoadStateChangedCallback& callback,
43 scoped_ptr<ProxyResolverErrorObserver> error_observer)
44 : ProxyResolverFactoryV8Tracing(host_resolver, net_log, callback),
45 error_observer_(error_observer.Pass()) {}
46
47 private:
48 scoped_ptr<ProxyResolverErrorObserver> CreateErrorObserver() override {
49 return error_observer_.Pass();
50 }
51
52 scoped_ptr<ProxyResolverErrorObserver> error_observer_;
53 };
54
34 class ProxyResolverV8TracingTest : public testing::Test { 55 class ProxyResolverV8TracingTest : public testing::Test {
35 public: 56 public:
36 void TearDown() override { 57 void TearDown() override {
37 // Drain any pending messages, which may be left over from cancellation. 58 // Drain any pending messages, which may be left over from cancellation.
38 // This way they get reliably run as part of the current test, rather than 59 // This way they get reliably run as part of the current test, rather than
39 // spilling into the next test's execution. 60 // spilling into the next test's execution.
40 base::MessageLoop::current()->RunUntilIdle(); 61 base::MessageLoop::current()->RunUntilIdle();
41 } 62 }
42 }; 63 };
43 64
44 scoped_refptr<ProxyResolverScriptData> LoadScriptData(const char* filename) { 65 scoped_refptr<ProxyResolverScriptData> LoadScriptData(const char* filename) {
45 base::FilePath path; 66 base::FilePath path;
46 PathService::Get(base::DIR_SOURCE_ROOT, &path); 67 PathService::Get(base::DIR_SOURCE_ROOT, &path);
47 path = path.AppendASCII("net"); 68 path = path.AppendASCII("net");
48 path = path.AppendASCII("data"); 69 path = path.AppendASCII("data");
49 path = path.AppendASCII("proxy_resolver_v8_tracing_unittest"); 70 path = path.AppendASCII("proxy_resolver_v8_tracing_unittest");
50 path = path.AppendASCII(filename); 71 path = path.AppendASCII(filename);
51 72
52 // Try to read the file from disk. 73 // Try to read the file from disk.
53 std::string file_contents; 74 std::string file_contents;
54 bool ok = base::ReadFileToString(path, &file_contents); 75 bool ok = base::ReadFileToString(path, &file_contents);
55 76
56 // If we can't load the file from disk, something is misconfigured. 77 // If we can't load the file from disk, something is misconfigured.
57 EXPECT_TRUE(ok) << "Failed to read file: " << path.value(); 78 EXPECT_TRUE(ok) << "Failed to read file: " << path.value();
58 79
59 // Load the PAC script into the ProxyResolver. 80 // Load the PAC script into the ProxyResolver.
60 return ProxyResolverScriptData::FromUTF8(file_contents); 81 return ProxyResolverScriptData::FromUTF8(file_contents);
61 } 82 }
62 83
63 void InitResolver(ProxyResolverV8Tracing* resolver, const char* filename) { 84 scoped_ptr<ProxyResolver> CreateResolver(
85 NetLog* net_log,
86 HostResolver* host_resolver,
87 scoped_ptr<ProxyResolverErrorObserver> error_observer,
88 const char* filename) {
89 scoped_ptr<ProxyResolver> resolver;
90 SingleShotProxyResolverFactoryV8Tracing factory(
91 host_resolver, net_log, ProxyResolver::LoadStateChangedCallback(),
92 error_observer.Pass());
64 TestCompletionCallback callback; 93 TestCompletionCallback callback;
65 int rv = 94 scoped_ptr<ProxyResolverFactory::Request> request;
66 resolver->SetPacScript(LoadScriptData(filename), callback.callback()); 95 int rv = factory.CreateProxyResolver(LoadScriptData(filename), &resolver,
96 callback.callback(), &request);
67 EXPECT_EQ(ERR_IO_PENDING, rv); 97 EXPECT_EQ(ERR_IO_PENDING, rv);
68 EXPECT_EQ(OK, callback.WaitForResult()); 98 EXPECT_EQ(OK, callback.WaitForResult());
99 EXPECT_TRUE(resolver);
100 return resolver.Pass();
69 } 101 }
70 102
71 class MockErrorObserver : public ProxyResolverErrorObserver { 103 class MockErrorObserver : public ProxyResolverErrorObserver {
72 public: 104 public:
73 MockErrorObserver() : event_(true, false) {} 105 MockErrorObserver() : event_(true, false) {}
74 106
75 void OnPACScriptError(int line_number, const base::string16& error) override { 107 void OnPACScriptError(int line_number, const base::string16& error) override {
76 { 108 {
77 base::AutoLock l(lock_); 109 base::AutoLock l(lock_);
78 output += base::StringPrintf("Error: line %d: %s\n", line_number, 110 output += base::StringPrintf("Error: line %d: %s\n", line_number,
(...skipping 16 matching lines...) Expand all
95 std::string output; 127 std::string output;
96 128
97 base::WaitableEvent event_; 129 base::WaitableEvent event_;
98 }; 130 };
99 131
100 TEST_F(ProxyResolverV8TracingTest, Simple) { 132 TEST_F(ProxyResolverV8TracingTest, Simple) {
101 TestNetLog log; 133 TestNetLog log;
102 BoundTestNetLog request_log; 134 BoundTestNetLog request_log;
103 MockCachingHostResolver host_resolver; 135 MockCachingHostResolver host_resolver;
104 MockErrorObserver* error_observer = new MockErrorObserver; 136 MockErrorObserver* error_observer = new MockErrorObserver;
105 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
106 137
107 InitResolver(&resolver, "simple.js"); 138 scoped_ptr<ProxyResolver> resolver = CreateResolver(
139 &log, &host_resolver, make_scoped_ptr(error_observer), "simple.js");
108 140
109 TestCompletionCallback callback; 141 TestCompletionCallback callback;
110 ProxyInfo proxy_info; 142 ProxyInfo proxy_info;
111 143
112 int rv = resolver.GetProxyForURL( 144 int rv =
113 GURL("http://foo/"), &proxy_info, callback.callback(), 145 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
114 NULL, request_log.bound()); 146 callback.callback(), NULL, request_log.bound());
115 147
116 EXPECT_EQ(ERR_IO_PENDING, rv); 148 EXPECT_EQ(ERR_IO_PENDING, rv);
117 EXPECT_EQ(OK, callback.WaitForResult()); 149 EXPECT_EQ(OK, callback.WaitForResult());
118 150
119 EXPECT_EQ("foo:99", proxy_info.proxy_server().ToURI()); 151 EXPECT_EQ("foo:99", proxy_info.proxy_server().ToURI());
120 152
121 EXPECT_EQ(0u, host_resolver.num_resolve()); 153 EXPECT_EQ(0u, host_resolver.num_resolve());
122 154
123 // There were no errors. 155 // There were no errors.
124 EXPECT_EQ("", error_observer->GetOutput()); 156 EXPECT_EQ("", error_observer->GetOutput());
125 157
126 // Check the NetLogs -- nothing was logged. 158 // Check the NetLogs -- nothing was logged.
127 EXPECT_EQ(0u, log.GetSize()); 159 EXPECT_EQ(0u, log.GetSize());
128 EXPECT_EQ(0u, request_log.GetSize()); 160 EXPECT_EQ(0u, request_log.GetSize());
129 } 161 }
130 162
131 TEST_F(ProxyResolverV8TracingTest, JavascriptError) { 163 TEST_F(ProxyResolverV8TracingTest, JavascriptError) {
132 TestNetLog log; 164 TestNetLog log;
133 BoundTestNetLog request_log; 165 BoundTestNetLog request_log;
134 MockCachingHostResolver host_resolver; 166 MockCachingHostResolver host_resolver;
135 MockErrorObserver* error_observer = new MockErrorObserver; 167 MockErrorObserver* error_observer = new MockErrorObserver;
136 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
137 168
138 InitResolver(&resolver, "error.js"); 169 scoped_ptr<ProxyResolver> resolver = CreateResolver(
170 &log, &host_resolver, make_scoped_ptr(error_observer), "error.js");
139 171
140 TestCompletionCallback callback; 172 TestCompletionCallback callback;
141 ProxyInfo proxy_info; 173 ProxyInfo proxy_info;
142 174
143 int rv = resolver.GetProxyForURL( 175 int rv =
144 GURL("http://throw-an-error/"), &proxy_info, callback.callback(), NULL, 176 resolver->GetProxyForURL(GURL("http://throw-an-error/"), &proxy_info,
145 request_log.bound()); 177 callback.callback(), NULL, request_log.bound());
146 178
147 EXPECT_EQ(ERR_IO_PENDING, rv); 179 EXPECT_EQ(ERR_IO_PENDING, rv);
148 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, callback.WaitForResult()); 180 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, callback.WaitForResult());
149 181
150 EXPECT_EQ(0u, host_resolver.num_resolve()); 182 EXPECT_EQ(0u, host_resolver.num_resolve());
151 183
152 EXPECT_EQ("Error: line 5: Uncaught TypeError: Cannot read property 'split' " 184 EXPECT_EQ("Error: line 5: Uncaught TypeError: Cannot read property 'split' "
153 "of null\n", error_observer->GetOutput()); 185 "of null\n", error_observer->GetOutput());
154 186
155 // Check the NetLogs -- there was 1 alert and 1 javascript error, and they 187 // Check the NetLogs -- there was 1 alert and 1 javascript error, and they
(...skipping 16 matching lines...) Expand all
172 EXPECT_EQ("{\"line_number\":5,\"message\":\"Uncaught TypeError: Cannot " 204 EXPECT_EQ("{\"line_number\":5,\"message\":\"Uncaught TypeError: Cannot "
173 "read property 'split' of null\"}", entries[1].GetParamsJson()); 205 "read property 'split' of null\"}", entries[1].GetParamsJson());
174 } 206 }
175 } 207 }
176 208
177 TEST_F(ProxyResolverV8TracingTest, TooManyAlerts) { 209 TEST_F(ProxyResolverV8TracingTest, TooManyAlerts) {
178 TestNetLog log; 210 TestNetLog log;
179 BoundTestNetLog request_log; 211 BoundTestNetLog request_log;
180 MockCachingHostResolver host_resolver; 212 MockCachingHostResolver host_resolver;
181 MockErrorObserver* error_observer = new MockErrorObserver; 213 MockErrorObserver* error_observer = new MockErrorObserver;
182 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
183 214
184 InitResolver(&resolver, "too_many_alerts.js"); 215 scoped_ptr<ProxyResolver> resolver =
216 CreateResolver(&log, &host_resolver, make_scoped_ptr(error_observer),
217 "too_many_alerts.js");
185 218
186 TestCompletionCallback callback; 219 TestCompletionCallback callback;
187 ProxyInfo proxy_info; 220 ProxyInfo proxy_info;
188 221
189 int rv = resolver.GetProxyForURL( 222 int rv =
190 GURL("http://foo/"), 223 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
191 &proxy_info, 224 callback.callback(), NULL, request_log.bound());
192 callback.callback(),
193 NULL,
194 request_log.bound());
195 225
196 EXPECT_EQ(ERR_IO_PENDING, rv); 226 EXPECT_EQ(ERR_IO_PENDING, rv);
197 EXPECT_EQ(OK, callback.WaitForResult()); 227 EXPECT_EQ(OK, callback.WaitForResult());
198 228
199 // Iteration1 does a DNS resolve 229 // Iteration1 does a DNS resolve
200 // Iteration2 exceeds the alert buffer 230 // Iteration2 exceeds the alert buffer
201 // Iteration3 runs in blocking mode and completes 231 // Iteration3 runs in blocking mode and completes
202 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI()); 232 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI());
203 233
204 EXPECT_EQ(1u, host_resolver.num_resolve()); 234 EXPECT_EQ(1u, host_resolver.num_resolve());
(...skipping 18 matching lines...) Expand all
223 } 253 }
224 } 254 }
225 255
226 // Verify that buffered alerts cannot grow unboundedly, even when the message is 256 // Verify that buffered alerts cannot grow unboundedly, even when the message is
227 // empty string. 257 // empty string.
228 TEST_F(ProxyResolverV8TracingTest, TooManyEmptyAlerts) { 258 TEST_F(ProxyResolverV8TracingTest, TooManyEmptyAlerts) {
229 TestNetLog log; 259 TestNetLog log;
230 BoundTestNetLog request_log; 260 BoundTestNetLog request_log;
231 MockCachingHostResolver host_resolver; 261 MockCachingHostResolver host_resolver;
232 MockErrorObserver* error_observer = new MockErrorObserver; 262 MockErrorObserver* error_observer = new MockErrorObserver;
233 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
234 263
235 InitResolver(&resolver, "too_many_empty_alerts.js"); 264 scoped_ptr<ProxyResolver> resolver =
265 CreateResolver(&log, &host_resolver, make_scoped_ptr(error_observer),
266 "too_many_empty_alerts.js");
236 267
237 TestCompletionCallback callback; 268 TestCompletionCallback callback;
238 ProxyInfo proxy_info; 269 ProxyInfo proxy_info;
239 270
240 int rv = resolver.GetProxyForURL( 271 int rv =
241 GURL("http://foo/"), 272 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
242 &proxy_info, 273 callback.callback(), NULL, request_log.bound());
243 callback.callback(),
244 NULL,
245 request_log.bound());
246 274
247 EXPECT_EQ(ERR_IO_PENDING, rv); 275 EXPECT_EQ(ERR_IO_PENDING, rv);
248 EXPECT_EQ(OK, callback.WaitForResult()); 276 EXPECT_EQ(OK, callback.WaitForResult());
249 277
250 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI()); 278 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI());
251 279
252 EXPECT_EQ(1u, host_resolver.num_resolve()); 280 EXPECT_EQ(1u, host_resolver.num_resolve());
253 281
254 // No errors. 282 // No errors.
255 EXPECT_EQ("", error_observer->GetOutput()); 283 EXPECT_EQ("", error_observer->GetOutput());
(...skipping 16 matching lines...) Expand all
272 } 300 }
273 301
274 // This test runs a PAC script that issues a sequence of DNS resolves. The test 302 // This test runs a PAC script that issues a sequence of DNS resolves. The test
275 // verifies the final result, and that the underlying DNS resolver received 303 // verifies the final result, and that the underlying DNS resolver received
276 // the correct set of queries. 304 // the correct set of queries.
277 TEST_F(ProxyResolverV8TracingTest, Dns) { 305 TEST_F(ProxyResolverV8TracingTest, Dns) {
278 TestNetLog log; 306 TestNetLog log;
279 BoundTestNetLog request_log; 307 BoundTestNetLog request_log;
280 MockCachingHostResolver host_resolver; 308 MockCachingHostResolver host_resolver;
281 MockErrorObserver* error_observer = new MockErrorObserver; 309 MockErrorObserver* error_observer = new MockErrorObserver;
282 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
283 310
284 host_resolver.rules()->AddRuleForAddressFamily( 311 host_resolver.rules()->AddRuleForAddressFamily(
285 "host1", ADDRESS_FAMILY_IPV4, "166.155.144.44"); 312 "host1", ADDRESS_FAMILY_IPV4, "166.155.144.44");
286 host_resolver.rules() 313 host_resolver.rules()
287 ->AddIPLiteralRule("host1", "::1,192.168.1.1", std::string()); 314 ->AddIPLiteralRule("host1", "::1,192.168.1.1", std::string());
288 host_resolver.rules()->AddSimulatedFailure("host2"); 315 host_resolver.rules()->AddSimulatedFailure("host2");
289 host_resolver.rules()->AddRule("host3", "166.155.144.33"); 316 host_resolver.rules()->AddRule("host3", "166.155.144.33");
290 host_resolver.rules()->AddRule("host5", "166.155.144.55"); 317 host_resolver.rules()->AddRule("host5", "166.155.144.55");
291 host_resolver.rules()->AddSimulatedFailure("host6"); 318 host_resolver.rules()->AddSimulatedFailure("host6");
292 host_resolver.rules()->AddRuleForAddressFamily( 319 host_resolver.rules()->AddRuleForAddressFamily(
293 "*", ADDRESS_FAMILY_IPV4, "122.133.144.155"); 320 "*", ADDRESS_FAMILY_IPV4, "122.133.144.155");
294 host_resolver.rules()->AddRule("*", "133.122.100.200"); 321 host_resolver.rules()->AddRule("*", "133.122.100.200");
295 322
296 InitResolver(&resolver, "dns.js"); 323 scoped_ptr<ProxyResolver> resolver = CreateResolver(
324 &log, &host_resolver, make_scoped_ptr(error_observer), "dns.js");
297 325
298 TestCompletionCallback callback; 326 TestCompletionCallback callback;
299 ProxyInfo proxy_info; 327 ProxyInfo proxy_info;
300 328
301 int rv = resolver.GetProxyForURL( 329 int rv =
302 GURL("http://foo/"), 330 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
303 &proxy_info, 331 callback.callback(), NULL, request_log.bound());
304 callback.callback(),
305 NULL,
306 request_log.bound());
307 332
308 EXPECT_EQ(ERR_IO_PENDING, rv); 333 EXPECT_EQ(ERR_IO_PENDING, rv);
309 EXPECT_EQ(OK, callback.WaitForResult()); 334 EXPECT_EQ(OK, callback.WaitForResult());
310 335
311 // The test does 13 DNS resolution, however only 7 of them are unique. 336 // The test does 13 DNS resolution, however only 7 of them are unique.
312 EXPECT_EQ(7u, host_resolver.num_resolve()); 337 EXPECT_EQ(7u, host_resolver.num_resolve());
313 338
314 const char* kExpectedResult = 339 const char* kExpectedResult =
315 "122.133.144.155-" // myIpAddress() 340 "122.133.144.155-" // myIpAddress()
316 "null-" // dnsResolve('') 341 "null-" // dnsResolve('')
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 374 }
350 375
351 // This test runs a PAC script that does "myIpAddress()" followed by 376 // This test runs a PAC script that does "myIpAddress()" followed by
352 // "dnsResolve()". This requires 2 restarts. However once the HostResolver's 377 // "dnsResolve()". This requires 2 restarts. However once the HostResolver's
353 // cache is warmed, subsequent calls should take 0 restarts. 378 // cache is warmed, subsequent calls should take 0 restarts.
354 TEST_F(ProxyResolverV8TracingTest, DnsChecksCache) { 379 TEST_F(ProxyResolverV8TracingTest, DnsChecksCache) {
355 TestNetLog log; 380 TestNetLog log;
356 BoundTestNetLog request_log; 381 BoundTestNetLog request_log;
357 MockCachingHostResolver host_resolver; 382 MockCachingHostResolver host_resolver;
358 MockErrorObserver* error_observer = new MockErrorObserver; 383 MockErrorObserver* error_observer = new MockErrorObserver;
359 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
360 384
361 host_resolver.rules()->AddRule("foopy", "166.155.144.11"); 385 host_resolver.rules()->AddRule("foopy", "166.155.144.11");
362 host_resolver.rules()->AddRule("*", "122.133.144.155"); 386 host_resolver.rules()->AddRule("*", "122.133.144.155");
363 387
364 InitResolver(&resolver, "simple_dns.js"); 388 scoped_ptr<ProxyResolver> resolver = CreateResolver(
389 &log, &host_resolver, make_scoped_ptr(error_observer), "simple_dns.js");
365 390
366 TestCompletionCallback callback1; 391 TestCompletionCallback callback1;
367 TestCompletionCallback callback2; 392 TestCompletionCallback callback2;
368 ProxyInfo proxy_info; 393 ProxyInfo proxy_info;
369 394
370 int rv = resolver.GetProxyForURL( 395 int rv =
371 GURL("http://foopy/req1"), 396 resolver->GetProxyForURL(GURL("http://foopy/req1"), &proxy_info,
372 &proxy_info, 397 callback1.callback(), NULL, request_log.bound());
373 callback1.callback(),
374 NULL,
375 request_log.bound());
376 398
377 EXPECT_EQ(ERR_IO_PENDING, rv); 399 EXPECT_EQ(ERR_IO_PENDING, rv);
378 EXPECT_EQ(OK, callback1.WaitForResult()); 400 EXPECT_EQ(OK, callback1.WaitForResult());
379 401
380 // The test does 2 DNS resolutions. 402 // The test does 2 DNS resolutions.
381 EXPECT_EQ(2u, host_resolver.num_resolve()); 403 EXPECT_EQ(2u, host_resolver.num_resolve());
382 404
383 // The first request took 2 restarts, hence on g_iteration=3. 405 // The first request took 2 restarts, hence on g_iteration=3.
384 EXPECT_EQ("166.155.144.11:3", proxy_info.proxy_server().ToURI()); 406 EXPECT_EQ("166.155.144.11:3", proxy_info.proxy_server().ToURI());
385 407
386 rv = resolver.GetProxyForURL( 408 rv =
387 GURL("http://foopy/req2"), 409 resolver->GetProxyForURL(GURL("http://foopy/req2"), &proxy_info,
388 &proxy_info, 410 callback2.callback(), NULL, request_log.bound());
389 callback2.callback(),
390 NULL,
391 request_log.bound());
392 411
393 EXPECT_EQ(ERR_IO_PENDING, rv); 412 EXPECT_EQ(ERR_IO_PENDING, rv);
394 EXPECT_EQ(OK, callback2.WaitForResult()); 413 EXPECT_EQ(OK, callback2.WaitForResult());
395 414
396 EXPECT_EQ(4u, host_resolver.num_resolve()); 415 EXPECT_EQ(4u, host_resolver.num_resolve());
397 416
398 // This time no restarts were required, so g_iteration incremented by 1. 417 // This time no restarts were required, so g_iteration incremented by 1.
399 EXPECT_EQ("166.155.144.11:4", proxy_info.proxy_server().ToURI()); 418 EXPECT_EQ("166.155.144.11:4", proxy_info.proxy_server().ToURI());
400 419
401 // No errors. 420 // No errors.
402 EXPECT_EQ("", error_observer->GetOutput()); 421 EXPECT_EQ("", error_observer->GetOutput());
403 422
404 EXPECT_EQ(0u, log.GetSize()); 423 EXPECT_EQ(0u, log.GetSize());
405 EXPECT_EQ(0u, request_log.GetSize()); 424 EXPECT_EQ(0u, request_log.GetSize());
406 } 425 }
407 426
408 // This test runs a weird PAC script that was designed to defeat the DNS tracing 427 // This test runs a weird PAC script that was designed to defeat the DNS tracing
409 // optimization. The proxy resolver should detect the inconsistency and 428 // optimization. The proxy resolver should detect the inconsistency and
410 // fall-back to synchronous mode execution. 429 // fall-back to synchronous mode execution.
411 TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous1) { 430 TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous1) {
412 TestNetLog log; 431 TestNetLog log;
413 BoundTestNetLog request_log; 432 BoundTestNetLog request_log;
414 MockCachingHostResolver host_resolver; 433 MockCachingHostResolver host_resolver;
415 MockErrorObserver* error_observer = new MockErrorObserver; 434 MockErrorObserver* error_observer = new MockErrorObserver;
416 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
417 435
418 host_resolver.rules()->AddRule("host1", "166.155.144.11"); 436 host_resolver.rules()->AddRule("host1", "166.155.144.11");
419 host_resolver.rules()->AddRule("crazy4", "133.199.111.4"); 437 host_resolver.rules()->AddRule("crazy4", "133.199.111.4");
420 host_resolver.rules()->AddRule("*", "122.133.144.155"); 438 host_resolver.rules()->AddRule("*", "122.133.144.155");
421 439
422 InitResolver(&resolver, "global_sideffects1.js"); 440 scoped_ptr<ProxyResolver> resolver =
441 CreateResolver(&log, &host_resolver, make_scoped_ptr(error_observer),
442 "global_sideffects1.js");
423 443
424 TestCompletionCallback callback; 444 TestCompletionCallback callback;
425 ProxyInfo proxy_info; 445 ProxyInfo proxy_info;
426 446
427 int rv = resolver.GetProxyForURL( 447 int rv =
428 GURL("http://foo/"), &proxy_info, callback.callback(), NULL, 448 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
429 request_log.bound()); 449 callback.callback(), NULL, request_log.bound());
430 EXPECT_EQ(ERR_IO_PENDING, rv); 450 EXPECT_EQ(ERR_IO_PENDING, rv);
431 EXPECT_EQ(OK, callback.WaitForResult()); 451 EXPECT_EQ(OK, callback.WaitForResult());
432 452
433 // The script itself only does 2 DNS resolves per execution, however it 453 // The script itself only does 2 DNS resolves per execution, however it
434 // constructs the hostname using a global counter which changes on each 454 // constructs the hostname using a global counter which changes on each
435 // invocation. 455 // invocation.
436 EXPECT_EQ(3u, host_resolver.num_resolve()); 456 EXPECT_EQ(3u, host_resolver.num_resolve());
437 457
438 EXPECT_EQ("166.155.144.11-133.199.111.4:100", 458 EXPECT_EQ("166.155.144.11-133.199.111.4:100",
439 proxy_info.proxy_server().ToURI()); 459 proxy_info.proxy_server().ToURI());
(...skipping 18 matching lines...) Expand all
458 } 478 }
459 479
460 // This test runs a weird PAC script that was designed to defeat the DNS tracing 480 // This test runs a weird PAC script that was designed to defeat the DNS tracing
461 // optimization. The proxy resolver should detect the inconsistency and 481 // optimization. The proxy resolver should detect the inconsistency and
462 // fall-back to synchronous mode execution. 482 // fall-back to synchronous mode execution.
463 TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous2) { 483 TEST_F(ProxyResolverV8TracingTest, FallBackToSynchronous2) {
464 TestNetLog log; 484 TestNetLog log;
465 BoundTestNetLog request_log; 485 BoundTestNetLog request_log;
466 MockCachingHostResolver host_resolver; 486 MockCachingHostResolver host_resolver;
467 MockErrorObserver* error_observer = new MockErrorObserver; 487 MockErrorObserver* error_observer = new MockErrorObserver;
468 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
469 488
470 host_resolver.rules()->AddRule("host1", "166.155.144.11"); 489 host_resolver.rules()->AddRule("host1", "166.155.144.11");
471 host_resolver.rules()->AddRule("host2", "166.155.144.22"); 490 host_resolver.rules()->AddRule("host2", "166.155.144.22");
472 host_resolver.rules()->AddRule("host3", "166.155.144.33"); 491 host_resolver.rules()->AddRule("host3", "166.155.144.33");
473 host_resolver.rules()->AddRule("host4", "166.155.144.44"); 492 host_resolver.rules()->AddRule("host4", "166.155.144.44");
474 host_resolver.rules()->AddRule("*", "122.133.144.155"); 493 host_resolver.rules()->AddRule("*", "122.133.144.155");
475 494
476 InitResolver(&resolver, "global_sideffects2.js"); 495 scoped_ptr<ProxyResolver> resolver =
496 CreateResolver(&log, &host_resolver, make_scoped_ptr(error_observer),
497 "global_sideffects2.js");
477 498
478 TestCompletionCallback callback; 499 TestCompletionCallback callback;
479 ProxyInfo proxy_info; 500 ProxyInfo proxy_info;
480 501
481 int rv = resolver.GetProxyForURL( 502 int rv =
482 GURL("http://foo/"), &proxy_info, callback.callback(), NULL, 503 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
483 request_log.bound()); 504 callback.callback(), NULL, request_log.bound());
484 EXPECT_EQ(ERR_IO_PENDING, rv); 505 EXPECT_EQ(ERR_IO_PENDING, rv);
485 EXPECT_EQ(OK, callback.WaitForResult()); 506 EXPECT_EQ(OK, callback.WaitForResult());
486 507
487 EXPECT_EQ(3u, host_resolver.num_resolve()); 508 EXPECT_EQ(3u, host_resolver.num_resolve());
488 509
489 EXPECT_EQ("166.155.144.44:100", proxy_info.proxy_server().ToURI()); 510 EXPECT_EQ("166.155.144.44:100", proxy_info.proxy_server().ToURI());
490 511
491 // No errors. 512 // No errors.
492 EXPECT_EQ("", error_observer->GetOutput()); 513 EXPECT_EQ("", error_observer->GetOutput());
493 514
494 // Check the NetLogs -- nothing was logged. 515 // Check the NetLogs -- nothing was logged.
495 EXPECT_EQ(0u, log.GetSize()); 516 EXPECT_EQ(0u, log.GetSize());
496 EXPECT_EQ(0u, request_log.GetSize()); 517 EXPECT_EQ(0u, request_log.GetSize());
497 } 518 }
498 519
499 // This test runs a weird PAC script that yields a never ending sequence 520 // This test runs a weird PAC script that yields a never ending sequence
500 // of DNS resolves when restarting. Running it will hit the maximum 521 // of DNS resolves when restarting. Running it will hit the maximum
501 // DNS resolves per request limit (20) after which every DNS resolve will 522 // DNS resolves per request limit (20) after which every DNS resolve will
502 // fail. 523 // fail.
503 TEST_F(ProxyResolverV8TracingTest, InfiniteDNSSequence) { 524 TEST_F(ProxyResolverV8TracingTest, InfiniteDNSSequence) {
504 TestNetLog log; 525 TestNetLog log;
505 BoundTestNetLog request_log; 526 BoundTestNetLog request_log;
506 MockCachingHostResolver host_resolver; 527 MockCachingHostResolver host_resolver;
507 MockErrorObserver* error_observer = new MockErrorObserver; 528 MockErrorObserver* error_observer = new MockErrorObserver;
508 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
509 529
510 host_resolver.rules()->AddRule("host*", "166.155.144.11"); 530 host_resolver.rules()->AddRule("host*", "166.155.144.11");
511 host_resolver.rules()->AddRule("*", "122.133.144.155"); 531 host_resolver.rules()->AddRule("*", "122.133.144.155");
512 532
513 InitResolver(&resolver, "global_sideffects3.js"); 533 scoped_ptr<ProxyResolver> resolver =
534 CreateResolver(&log, &host_resolver, make_scoped_ptr(error_observer),
535 "global_sideffects3.js");
514 536
515 TestCompletionCallback callback; 537 TestCompletionCallback callback;
516 ProxyInfo proxy_info; 538 ProxyInfo proxy_info;
517 539
518 int rv = resolver.GetProxyForURL( 540 int rv =
519 GURL("http://foo/"), &proxy_info, callback.callback(), NULL, 541 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
520 request_log.bound()); 542 callback.callback(), NULL, request_log.bound());
521 EXPECT_EQ(ERR_IO_PENDING, rv); 543 EXPECT_EQ(ERR_IO_PENDING, rv);
522 EXPECT_EQ(OK, callback.WaitForResult()); 544 EXPECT_EQ(OK, callback.WaitForResult());
523 545
524 EXPECT_EQ(20u, host_resolver.num_resolve()); 546 EXPECT_EQ(20u, host_resolver.num_resolve());
525 547
526 EXPECT_EQ( 548 EXPECT_EQ(
527 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" 549 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
528 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" 550 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
529 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" 551 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
530 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-" 552 "166.155.144.11-166.155.144.11-166.155.144.11-166.155.144.11-"
(...skipping 10 matching lines...) Expand all
541 563
542 // This test runs a weird PAC script that yields a never ending sequence 564 // This test runs a weird PAC script that yields a never ending sequence
543 // of DNS resolves when restarting. Running it will hit the maximum 565 // of DNS resolves when restarting. Running it will hit the maximum
544 // DNS resolves per request limit (20) after which every DNS resolve will 566 // DNS resolves per request limit (20) after which every DNS resolve will
545 // fail. 567 // fail.
546 TEST_F(ProxyResolverV8TracingTest, InfiniteDNSSequence2) { 568 TEST_F(ProxyResolverV8TracingTest, InfiniteDNSSequence2) {
547 TestNetLog log; 569 TestNetLog log;
548 BoundTestNetLog request_log; 570 BoundTestNetLog request_log;
549 MockCachingHostResolver host_resolver; 571 MockCachingHostResolver host_resolver;
550 MockErrorObserver* error_observer = new MockErrorObserver; 572 MockErrorObserver* error_observer = new MockErrorObserver;
551 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
552 573
553 host_resolver.rules()->AddRule("host*", "166.155.144.11"); 574 host_resolver.rules()->AddRule("host*", "166.155.144.11");
554 host_resolver.rules()->AddRule("*", "122.133.144.155"); 575 host_resolver.rules()->AddRule("*", "122.133.144.155");
555 576
556 InitResolver(&resolver, "global_sideffects4.js"); 577 scoped_ptr<ProxyResolver> resolver =
578 CreateResolver(&log, &host_resolver, make_scoped_ptr(error_observer),
579 "global_sideffects4.js");
557 580
558 TestCompletionCallback callback; 581 TestCompletionCallback callback;
559 ProxyInfo proxy_info; 582 ProxyInfo proxy_info;
560 583
561 int rv = resolver.GetProxyForURL( 584 int rv =
562 GURL("http://foo/"), &proxy_info, callback.callback(), NULL, 585 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
563 request_log.bound()); 586 callback.callback(), NULL, request_log.bound());
564 EXPECT_EQ(ERR_IO_PENDING, rv); 587 EXPECT_EQ(ERR_IO_PENDING, rv);
565 EXPECT_EQ(OK, callback.WaitForResult()); 588 EXPECT_EQ(OK, callback.WaitForResult());
566 589
567 EXPECT_EQ(20u, host_resolver.num_resolve()); 590 EXPECT_EQ(20u, host_resolver.num_resolve());
568 591
569 EXPECT_EQ("null21:34", proxy_info.proxy_server().ToURI()); 592 EXPECT_EQ("null21:34", proxy_info.proxy_server().ToURI());
570 593
571 // No errors. 594 // No errors.
572 EXPECT_EQ("", error_observer->GetOutput()); 595 EXPECT_EQ("", error_observer->GetOutput());
573 596
574 // Check the NetLogs -- 1 alert was logged. 597 // Check the NetLogs -- 1 alert was logged.
575 EXPECT_EQ(1u, log.GetSize()); 598 EXPECT_EQ(1u, log.GetSize());
576 EXPECT_EQ(1u, request_log.GetSize()); 599 EXPECT_EQ(1u, request_log.GetSize());
577 } 600 }
578 601
579 void DnsDuringInitHelper(bool synchronous_host_resolver) { 602 void DnsDuringInitHelper(bool synchronous_host_resolver) {
580 TestNetLog log; 603 TestNetLog log;
581 BoundTestNetLog request_log; 604 BoundTestNetLog request_log;
582 MockCachingHostResolver host_resolver; 605 MockCachingHostResolver host_resolver;
583 host_resolver.set_synchronous_mode(synchronous_host_resolver); 606 host_resolver.set_synchronous_mode(synchronous_host_resolver);
584 MockErrorObserver* error_observer = new MockErrorObserver; 607 MockErrorObserver* error_observer = new MockErrorObserver;
585 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
586 608
587 host_resolver.rules()->AddRule("host1", "91.13.12.1"); 609 host_resolver.rules()->AddRule("host1", "91.13.12.1");
588 host_resolver.rules()->AddRule("host2", "91.13.12.2"); 610 host_resolver.rules()->AddRule("host2", "91.13.12.2");
589 611
590 InitResolver(&resolver, "dns_during_init.js"); 612 scoped_ptr<ProxyResolver> resolver =
613 CreateResolver(&log, &host_resolver, make_scoped_ptr(error_observer),
614 "dns_during_init.js");
591 615
592 // Initialization did 2 dnsResolves. 616 // Initialization did 2 dnsResolves.
593 EXPECT_EQ(2u, host_resolver.num_resolve()); 617 EXPECT_EQ(2u, host_resolver.num_resolve());
594 618
595 host_resolver.rules()->ClearRules(); 619 host_resolver.rules()->ClearRules();
596 host_resolver.GetHostCache()->clear(); 620 host_resolver.GetHostCache()->clear();
597 621
598 host_resolver.rules()->AddRule("host1", "145.88.13.3"); 622 host_resolver.rules()->AddRule("host1", "145.88.13.3");
599 host_resolver.rules()->AddRule("host2", "137.89.8.45"); 623 host_resolver.rules()->AddRule("host2", "137.89.8.45");
600 624
601 TestCompletionCallback callback; 625 TestCompletionCallback callback;
602 ProxyInfo proxy_info; 626 ProxyInfo proxy_info;
603 627
604 int rv = resolver.GetProxyForURL( 628 int rv =
605 GURL("http://foo/"), &proxy_info, callback.callback(), NULL, 629 resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
606 request_log.bound()); 630 callback.callback(), NULL, request_log.bound());
607 EXPECT_EQ(ERR_IO_PENDING, rv); 631 EXPECT_EQ(ERR_IO_PENDING, rv);
608 EXPECT_EQ(OK, callback.WaitForResult()); 632 EXPECT_EQ(OK, callback.WaitForResult());
609 633
610 // Fetched host1 and host2 again, since the ones done during initialization 634 // Fetched host1 and host2 again, since the ones done during initialization
611 // should not have been cached. 635 // should not have been cached.
612 EXPECT_EQ(4u, host_resolver.num_resolve()); 636 EXPECT_EQ(4u, host_resolver.num_resolve());
613 637
614 EXPECT_EQ("91.13.12.1-91.13.12.2-145.88.13.3-137.89.8.45:99", 638 EXPECT_EQ("91.13.12.1-91.13.12.2-145.88.13.3-137.89.8.45:99",
615 proxy_info.proxy_server().ToURI()); 639 proxy_info.proxy_server().ToURI());
616 640
(...skipping 27 matching lines...) Expand all
644 CHECK(false); 668 CHECK(false);
645 } 669 }
646 670
647 // Start some requests, cancel them all, and then destroy the resolver. 671 // Start some requests, cancel them all, and then destroy the resolver.
648 // Note the execution order for this test can vary. Since multiple 672 // Note the execution order for this test can vary. Since multiple
649 // threads are involved, the cancellation may be received a different 673 // threads are involved, the cancellation may be received a different
650 // times. 674 // times.
651 TEST_F(ProxyResolverV8TracingTest, CancelAll) { 675 TEST_F(ProxyResolverV8TracingTest, CancelAll) {
652 MockCachingHostResolver host_resolver; 676 MockCachingHostResolver host_resolver;
653 MockErrorObserver* error_observer = new MockErrorObserver; 677 MockErrorObserver* error_observer = new MockErrorObserver;
654 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, NULL);
655 678
656 host_resolver.rules()->AddSimulatedFailure("*"); 679 host_resolver.rules()->AddSimulatedFailure("*");
657 680
658 InitResolver(&resolver, "dns.js"); 681 scoped_ptr<ProxyResolver> resolver = CreateResolver(
682 nullptr, &host_resolver, make_scoped_ptr(error_observer), "dns.js");
659 683
660 const size_t kNumRequests = 5; 684 const size_t kNumRequests = 5;
661 ProxyInfo proxy_info[kNumRequests]; 685 ProxyInfo proxy_info[kNumRequests];
662 ProxyResolver::RequestHandle request[kNumRequests]; 686 ProxyResolver::RequestHandle request[kNumRequests];
663 687
664 for (size_t i = 0; i < kNumRequests; ++i) { 688 for (size_t i = 0; i < kNumRequests; ++i) {
665 int rv = resolver.GetProxyForURL( 689 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info[i],
666 GURL("http://foo/"), &proxy_info[i], 690 base::Bind(&CrashCallback), &request[i],
667 base::Bind(&CrashCallback), &request[i], BoundNetLog()); 691 BoundNetLog());
668 EXPECT_EQ(ERR_IO_PENDING, rv); 692 EXPECT_EQ(ERR_IO_PENDING, rv);
669 } 693 }
670 694
671 for (size_t i = 0; i < kNumRequests; ++i) { 695 for (size_t i = 0; i < kNumRequests; ++i) {
672 resolver.CancelRequest(request[i]); 696 resolver->CancelRequest(request[i]);
673 } 697 }
674 } 698 }
675 699
676 // Note the execution order for this test can vary. Since multiple 700 // Note the execution order for this test can vary. Since multiple
677 // threads are involved, the cancellation may be received a different 701 // threads are involved, the cancellation may be received a different
678 // times. 702 // times.
679 TEST_F(ProxyResolverV8TracingTest, CancelSome) { 703 TEST_F(ProxyResolverV8TracingTest, CancelSome) {
680 MockCachingHostResolver host_resolver; 704 MockCachingHostResolver host_resolver;
681 MockErrorObserver* error_observer = new MockErrorObserver; 705 MockErrorObserver* error_observer = new MockErrorObserver;
682 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, NULL);
683 706
684 host_resolver.rules()->AddSimulatedFailure("*"); 707 host_resolver.rules()->AddSimulatedFailure("*");
685 708
686 InitResolver(&resolver, "dns.js"); 709 scoped_ptr<ProxyResolver> resolver = CreateResolver(
710 nullptr, &host_resolver, make_scoped_ptr(error_observer), "dns.js");
687 711
688 ProxyInfo proxy_info1; 712 ProxyInfo proxy_info1;
689 ProxyInfo proxy_info2; 713 ProxyInfo proxy_info2;
690 ProxyResolver::RequestHandle request1; 714 ProxyResolver::RequestHandle request1;
691 ProxyResolver::RequestHandle request2; 715 ProxyResolver::RequestHandle request2;
692 TestCompletionCallback callback; 716 TestCompletionCallback callback;
693 717
694 int rv = resolver.GetProxyForURL( 718 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info1,
695 GURL("http://foo/"), &proxy_info1, 719 base::Bind(&CrashCallback), &request1,
696 base::Bind(&CrashCallback), &request1, BoundNetLog()); 720 BoundNetLog());
697 EXPECT_EQ(ERR_IO_PENDING, rv); 721 EXPECT_EQ(ERR_IO_PENDING, rv);
698 722
699 rv = resolver.GetProxyForURL( 723 rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info2,
700 GURL("http://foo/"), &proxy_info2, 724 callback.callback(), &request2, BoundNetLog());
701 callback.callback(), &request2, BoundNetLog());
702 EXPECT_EQ(ERR_IO_PENDING, rv); 725 EXPECT_EQ(ERR_IO_PENDING, rv);
703 726
704 resolver.CancelRequest(request1); 727 resolver->CancelRequest(request1);
705 728
706 EXPECT_EQ(OK, callback.WaitForResult()); 729 EXPECT_EQ(OK, callback.WaitForResult());
707 } 730 }
708 731
709 // Cancel a request after it has finished running on the worker thread, and has 732 // Cancel a request after it has finished running on the worker thread, and has
710 // posted a task the completion task back to origin thread. 733 // posted a task the completion task back to origin thread.
711 TEST_F(ProxyResolverV8TracingTest, CancelWhilePendingCompletionTask) { 734 TEST_F(ProxyResolverV8TracingTest, CancelWhilePendingCompletionTask) {
712 MockCachingHostResolver host_resolver; 735 MockCachingHostResolver host_resolver;
713 MockErrorObserver* error_observer = new MockErrorObserver; 736 MockErrorObserver* error_observer = new MockErrorObserver;
714 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, NULL);
715 737
716 host_resolver.rules()->AddSimulatedFailure("*"); 738 host_resolver.rules()->AddSimulatedFailure("*");
717 739
718 InitResolver(&resolver, "error.js"); 740 scoped_ptr<ProxyResolver> resolver = CreateResolver(
741 nullptr, &host_resolver, make_scoped_ptr(error_observer), "error.js");
719 742
720 ProxyInfo proxy_info1; 743 ProxyInfo proxy_info1;
721 ProxyInfo proxy_info2; 744 ProxyInfo proxy_info2;
722 ProxyInfo proxy_info3; 745 ProxyInfo proxy_info3;
723 ProxyResolver::RequestHandle request1; 746 ProxyResolver::RequestHandle request1;
724 ProxyResolver::RequestHandle request2; 747 ProxyResolver::RequestHandle request2;
725 ProxyResolver::RequestHandle request3; 748 ProxyResolver::RequestHandle request3;
726 TestCompletionCallback callback; 749 TestCompletionCallback callback;
727 750
728 int rv = resolver.GetProxyForURL( 751 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info1,
729 GURL("http://foo/"), &proxy_info1, 752 base::Bind(&CrashCallback), &request1,
730 base::Bind(&CrashCallback), &request1, BoundNetLog()); 753 BoundNetLog());
731 EXPECT_EQ(ERR_IO_PENDING, rv); 754 EXPECT_EQ(ERR_IO_PENDING, rv);
732 755
733 rv = resolver.GetProxyForURL( 756 rv = resolver->GetProxyForURL(GURL("http://throw-an-error/"), &proxy_info2,
734 GURL("http://throw-an-error/"), &proxy_info2, 757 callback.callback(), &request2, BoundNetLog());
735 callback.callback(), &request2, BoundNetLog());
736 EXPECT_EQ(ERR_IO_PENDING, rv); 758 EXPECT_EQ(ERR_IO_PENDING, rv);
737 759
738 // Wait until the first request has finished running on the worker thread. 760 // Wait until the first request has finished running on the worker thread.
739 // (The second request will output an error). 761 // (The second request will output an error).
740 error_observer->WaitForOutput(); 762 error_observer->WaitForOutput();
741 763
742 // Cancel the first request, while it has a pending completion task on 764 // Cancel the first request, while it has a pending completion task on
743 // the origin thread. 765 // the origin thread.
744 resolver.CancelRequest(request1); 766 resolver->CancelRequest(request1);
745 767
746 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, callback.WaitForResult()); 768 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, callback.WaitForResult());
747 769
748 // Start another request, to make sure it is able to complete. 770 // Start another request, to make sure it is able to complete.
749 rv = resolver.GetProxyForURL( 771 rv = resolver->GetProxyForURL(GURL("http://i-have-no-idea-what-im-doing/"),
750 GURL("http://i-have-no-idea-what-im-doing/"), &proxy_info3, 772 &proxy_info3, callback.callback(), &request3,
751 callback.callback(), &request3, BoundNetLog()); 773 BoundNetLog());
752 EXPECT_EQ(ERR_IO_PENDING, rv); 774 EXPECT_EQ(ERR_IO_PENDING, rv);
753 775
754 EXPECT_EQ(OK, callback.WaitForResult()); 776 EXPECT_EQ(OK, callback.WaitForResult());
755 777
756 EXPECT_EQ("i-approve-this-message:42", 778 EXPECT_EQ("i-approve-this-message:42",
757 proxy_info3.proxy_server().ToURI()); 779 proxy_info3.proxy_server().ToURI());
758 } 780 }
759 781
760 // This implementation of HostResolver allows blocking until a resolve request 782 // This implementation of HostResolver allows blocking until a resolve request
761 // has been received. The resolve requests it receives will never be completed. 783 // has been received. The resolve requests it receives will never be completed.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 int num_cancelled_requests_; 844 int num_cancelled_requests_;
823 bool waiting_for_resolve_; 845 bool waiting_for_resolve_;
824 base::Callback<void(void)> action_; 846 base::Callback<void(void)> action_;
825 }; 847 };
826 848
827 // This cancellation test exercises a more predictable cancellation codepath -- 849 // This cancellation test exercises a more predictable cancellation codepath --
828 // when the request has an outstanding DNS request in flight. 850 // when the request has an outstanding DNS request in flight.
829 TEST_F(ProxyResolverV8TracingTest, CancelWhileOutstandingNonBlockingDns) { 851 TEST_F(ProxyResolverV8TracingTest, CancelWhileOutstandingNonBlockingDns) {
830 BlockableHostResolver host_resolver; 852 BlockableHostResolver host_resolver;
831 MockErrorObserver* error_observer = new MockErrorObserver; 853 MockErrorObserver* error_observer = new MockErrorObserver;
832 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, NULL);
833 854
834 InitResolver(&resolver, "dns.js"); 855 scoped_ptr<ProxyResolver> resolver = CreateResolver(
856 nullptr, &host_resolver, make_scoped_ptr(error_observer), "dns.js");
835 857
836 ProxyInfo proxy_info1; 858 ProxyInfo proxy_info1;
837 ProxyInfo proxy_info2; 859 ProxyInfo proxy_info2;
838 ProxyResolver::RequestHandle request1; 860 ProxyResolver::RequestHandle request1;
839 ProxyResolver::RequestHandle request2; 861 ProxyResolver::RequestHandle request2;
840 862
841 int rv = resolver.GetProxyForURL( 863 int rv = resolver->GetProxyForURL(GURL("http://foo/req1"), &proxy_info1,
842 GURL("http://foo/req1"), &proxy_info1, 864 base::Bind(&CrashCallback), &request1,
843 base::Bind(&CrashCallback), &request1, BoundNetLog()); 865 BoundNetLog());
844 866
845 EXPECT_EQ(ERR_IO_PENDING, rv); 867 EXPECT_EQ(ERR_IO_PENDING, rv);
846 868
847 host_resolver.WaitUntilRequestIsReceived(); 869 host_resolver.WaitUntilRequestIsReceived();
848 870
849 rv = resolver.GetProxyForURL( 871 rv = resolver->GetProxyForURL(GURL("http://foo/req2"), &proxy_info2,
850 GURL("http://foo/req2"), &proxy_info2, 872 base::Bind(&CrashCallback), &request2,
851 base::Bind(&CrashCallback), &request2, BoundNetLog()); 873 BoundNetLog());
852 874
853 EXPECT_EQ(ERR_IO_PENDING, rv); 875 EXPECT_EQ(ERR_IO_PENDING, rv);
854 876
855 host_resolver.WaitUntilRequestIsReceived(); 877 host_resolver.WaitUntilRequestIsReceived();
856 878
857 resolver.CancelRequest(request1); 879 resolver->CancelRequest(request1);
858 resolver.CancelRequest(request2); 880 resolver->CancelRequest(request2);
859 881
860 EXPECT_EQ(2, host_resolver.num_cancelled_requests()); 882 EXPECT_EQ(2, host_resolver.num_cancelled_requests());
861 883
862 // After leaving this scope, the ProxyResolver is destroyed. 884 // After leaving this scope, the ProxyResolver is destroyed.
863 // This should not cause any problems, as the outstanding work 885 // This should not cause any problems, as the outstanding work
864 // should have been cancelled. 886 // should have been cancelled.
865 } 887 }
866 888
867 void CancelRequestAndPause(ProxyResolverV8Tracing* resolver, 889 void CancelRequestAndPause(ProxyResolver* resolver,
868 ProxyResolver::RequestHandle request) { 890 ProxyResolver::RequestHandle request) {
869 resolver->CancelRequest(request); 891 resolver->CancelRequest(request);
870 892
871 // Sleep for a little bit. This makes it more likely for the worker 893 // Sleep for a little bit. This makes it more likely for the worker
872 // thread to have returned from its call, and serves as a regression 894 // thread to have returned from its call, and serves as a regression
873 // test for http://crbug.com/173373. 895 // test for http://crbug.com/173373.
874 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(30)); 896 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(30));
875 } 897 }
876 898
877 // In non-blocking mode, the worker thread actually does block for 899 // In non-blocking mode, the worker thread actually does block for
878 // a short time to see if the result is in the DNS cache. Test 900 // a short time to see if the result is in the DNS cache. Test
879 // cancellation while the worker thread is waiting on this event. 901 // cancellation while the worker thread is waiting on this event.
880 TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns) { 902 TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns) {
881 BlockableHostResolver host_resolver; 903 BlockableHostResolver host_resolver;
882 MockErrorObserver* error_observer = new MockErrorObserver; 904 MockErrorObserver* error_observer = new MockErrorObserver;
883 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, NULL);
884 905
885 InitResolver(&resolver, "dns.js"); 906 scoped_ptr<ProxyResolver> resolver = CreateResolver(
907 nullptr, &host_resolver, make_scoped_ptr(error_observer), "dns.js");
886 908
887 ProxyInfo proxy_info; 909 ProxyInfo proxy_info;
888 ProxyResolver::RequestHandle request; 910 ProxyResolver::RequestHandle request;
889 911
890 int rv = resolver.GetProxyForURL( 912 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
891 GURL("http://foo/"), &proxy_info, 913 base::Bind(&CrashCallback), &request,
892 base::Bind(&CrashCallback), &request, BoundNetLog()); 914 BoundNetLog());
893 915
894 EXPECT_EQ(ERR_IO_PENDING, rv); 916 EXPECT_EQ(ERR_IO_PENDING, rv);
895 917
896 host_resolver.SetAction( 918 host_resolver.SetAction(
897 base::Bind(CancelRequestAndPause, &resolver, request)); 919 base::Bind(CancelRequestAndPause, resolver.get(), request));
898 920
899 host_resolver.WaitUntilRequestIsReceived(); 921 host_resolver.WaitUntilRequestIsReceived();
900 922
901 // At this point the host resolver ran Resolve(), and should have cancelled 923 // At this point the host resolver ran Resolve(), and should have cancelled
902 // the request. 924 // the request.
903 925
904 EXPECT_EQ(1, host_resolver.num_cancelled_requests()); 926 EXPECT_EQ(1, host_resolver.num_cancelled_requests());
905 } 927 }
906 928
907 // Cancel the request while there is a pending DNS request, however before 929 // Cancel the request while there is a pending DNS request, however before
908 // the request is sent to the host resolver. 930 // the request is sent to the host resolver.
909 TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns2) { 931 TEST_F(ProxyResolverV8TracingTest, CancelWhileBlockedInNonBlockingDns2) {
910 MockCachingHostResolver host_resolver; 932 MockCachingHostResolver host_resolver;
911 MockErrorObserver* error_observer = new MockErrorObserver; 933 MockErrorObserver* error_observer = new MockErrorObserver;
912 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, NULL);
913 934
914 InitResolver(&resolver, "dns.js"); 935 scoped_ptr<ProxyResolver> resolver = CreateResolver(
936 nullptr, &host_resolver, make_scoped_ptr(error_observer), "dns.js");
915 937
916 ProxyInfo proxy_info; 938 ProxyInfo proxy_info;
917 ProxyResolver::RequestHandle request; 939 ProxyResolver::RequestHandle request;
918 940
919 int rv = resolver.GetProxyForURL( 941 int rv = resolver->GetProxyForURL(GURL("http://foo/"), &proxy_info,
920 GURL("http://foo/"), &proxy_info, 942 base::Bind(&CrashCallback), &request,
921 base::Bind(&CrashCallback), &request, BoundNetLog()); 943 BoundNetLog());
922 944
923 EXPECT_EQ(ERR_IO_PENDING, rv); 945 EXPECT_EQ(ERR_IO_PENDING, rv);
924 946
925 // Wait a bit, so the DNS task has hopefully been posted. The test will 947 // Wait a bit, so the DNS task has hopefully been posted. The test will
926 // work whatever the delay is here, but it is most useful if the delay 948 // work whatever the delay is here, but it is most useful if the delay
927 // is large enough to allow a task to be posted back. 949 // is large enough to allow a task to be posted back.
928 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); 950 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
929 resolver.CancelRequest(request); 951 resolver->CancelRequest(request);
930 952
931 EXPECT_EQ(0u, host_resolver.num_resolve()); 953 EXPECT_EQ(0u, host_resolver.num_resolve());
932 } 954 }
933 955
934 TEST_F(ProxyResolverV8TracingTest, CancelSetPacWhileOutstandingBlockingDns) { 956 TEST_F(ProxyResolverV8TracingTest,
957 CancelCreateResolverWhileOutstandingBlockingDns) {
935 BlockableHostResolver host_resolver; 958 BlockableHostResolver host_resolver;
936 MockErrorObserver* error_observer = new MockErrorObserver; 959 MockErrorObserver* error_observer = new MockErrorObserver;
937 960
938 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, NULL); 961 SingleShotProxyResolverFactoryV8Tracing factory(
962 &host_resolver, nullptr, ProxyResolver::LoadStateChangedCallback(),
963 make_scoped_ptr(error_observer));
939 964
940 int rv = 965 scoped_ptr<ProxyResolver> resolver;
941 resolver.SetPacScript(LoadScriptData("dns_during_init.js"), 966 scoped_ptr<ProxyResolverFactory::Request> request;
942 base::Bind(&CrashCallback)); 967 int rv = factory.CreateProxyResolver(LoadScriptData("dns_during_init.js"),
968 &resolver, base::Bind(&CrashCallback),
969 &request);
943 EXPECT_EQ(ERR_IO_PENDING, rv); 970 EXPECT_EQ(ERR_IO_PENDING, rv);
944 971
945 host_resolver.WaitUntilRequestIsReceived(); 972 host_resolver.WaitUntilRequestIsReceived();
946 973
947 resolver.CancelSetPacScript(); 974 request.reset();
948 EXPECT_EQ(1, host_resolver.num_cancelled_requests()); 975 EXPECT_EQ(1, host_resolver.num_cancelled_requests());
949 } 976 }
950 977
978 TEST_F(ProxyResolverV8TracingTest, DeleteFactoryWhileOutstandingBlockingDns) {
979 BlockableHostResolver host_resolver;
980 MockErrorObserver* error_observer = new MockErrorObserver;
981
982 scoped_ptr<ProxyResolver> resolver;
983 scoped_ptr<ProxyResolverFactory::Request> request;
984 {
985 SingleShotProxyResolverFactoryV8Tracing factory(
986 &host_resolver, nullptr, ProxyResolver::LoadStateChangedCallback(),
987 make_scoped_ptr(error_observer));
988
989 int rv = factory.CreateProxyResolver(LoadScriptData("dns_during_init.js"),
990 &resolver, base::Bind(&CrashCallback),
991 &request);
992 EXPECT_EQ(ERR_IO_PENDING, rv);
993 host_resolver.WaitUntilRequestIsReceived();
994 }
995 EXPECT_EQ(1, host_resolver.num_cancelled_requests());
996 }
997
998 TEST_F(ProxyResolverV8TracingTest, ErrorLoadingScript) {
999 BlockableHostResolver host_resolver;
1000 MockErrorObserver* error_observer = new MockErrorObserver;
1001
1002 SingleShotProxyResolverFactoryV8Tracing factory(
1003 &host_resolver, nullptr, ProxyResolver::LoadStateChangedCallback(),
1004 make_scoped_ptr(error_observer));
1005
1006 scoped_ptr<ProxyResolver> resolver;
1007 scoped_ptr<ProxyResolverFactory::Request> request;
1008 TestCompletionCallback callback;
1009 int rv =
1010 factory.CreateProxyResolver(LoadScriptData("error_on_load.js"), &resolver,
1011 callback.callback(), &request);
1012 EXPECT_EQ(ERR_IO_PENDING, rv);
1013 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, callback.WaitForResult());
1014 EXPECT_FALSE(resolver);
1015 }
1016
951 // This tests that the execution of a PAC script is terminated when the DNS 1017 // This tests that the execution of a PAC script is terminated when the DNS
952 // dependencies are missing. If the test fails, then it will hang. 1018 // dependencies are missing. If the test fails, then it will hang.
953 TEST_F(ProxyResolverV8TracingTest, Terminate) { 1019 TEST_F(ProxyResolverV8TracingTest, Terminate) {
954 TestNetLog log; 1020 TestNetLog log;
955 BoundTestNetLog request_log; 1021 BoundTestNetLog request_log;
956 MockCachingHostResolver host_resolver; 1022 MockCachingHostResolver host_resolver;
957 MockErrorObserver* error_observer = new MockErrorObserver; 1023 MockErrorObserver* error_observer = new MockErrorObserver;
958 ProxyResolverV8Tracing resolver(&host_resolver, error_observer, &log);
959 1024
960 host_resolver.rules()->AddRule("host1", "182.111.0.222"); 1025 host_resolver.rules()->AddRule("host1", "182.111.0.222");
961 host_resolver.rules()->AddRule("host2", "111.33.44.55"); 1026 host_resolver.rules()->AddRule("host2", "111.33.44.55");
962 1027
963 InitResolver(&resolver, "terminate.js"); 1028 scoped_ptr<ProxyResolver> resolver = CreateResolver(
1029 &log, &host_resolver, make_scoped_ptr(error_observer), "terminate.js");
964 1030
965 TestCompletionCallback callback; 1031 TestCompletionCallback callback;
966 ProxyInfo proxy_info; 1032 ProxyInfo proxy_info;
967 1033
968 int rv = resolver.GetProxyForURL( 1034 int rv =
969 GURL("http://foopy/req1"), 1035 resolver->GetProxyForURL(GURL("http://foopy/req1"), &proxy_info,
970 &proxy_info, 1036 callback.callback(), NULL, request_log.bound());
971 callback.callback(),
972 NULL,
973 request_log.bound());
974 1037
975 EXPECT_EQ(ERR_IO_PENDING, rv); 1038 EXPECT_EQ(ERR_IO_PENDING, rv);
976 EXPECT_EQ(OK, callback.WaitForResult()); 1039 EXPECT_EQ(OK, callback.WaitForResult());
977 1040
978 // The test does 2 DNS resolutions. 1041 // The test does 2 DNS resolutions.
979 EXPECT_EQ(2u, host_resolver.num_resolve()); 1042 EXPECT_EQ(2u, host_resolver.num_resolve());
980 1043
981 EXPECT_EQ("foopy:3", proxy_info.proxy_server().ToURI()); 1044 EXPECT_EQ("foopy:3", proxy_info.proxy_server().ToURI());
982 1045
983 // No errors. 1046 // No errors.
(...skipping 16 matching lines...) Expand all
1000 "host1", ADDRESS_FAMILY_IPV4, "166.155.144.44"); 1063 "host1", ADDRESS_FAMILY_IPV4, "166.155.144.44");
1001 host_resolver0.rules() 1064 host_resolver0.rules()
1002 ->AddIPLiteralRule("host1", "::1,192.168.1.1", std::string()); 1065 ->AddIPLiteralRule("host1", "::1,192.168.1.1", std::string());
1003 host_resolver0.rules()->AddSimulatedFailure("host2"); 1066 host_resolver0.rules()->AddSimulatedFailure("host2");
1004 host_resolver0.rules()->AddRule("host3", "166.155.144.33"); 1067 host_resolver0.rules()->AddRule("host3", "166.155.144.33");
1005 host_resolver0.rules()->AddRule("host5", "166.155.144.55"); 1068 host_resolver0.rules()->AddRule("host5", "166.155.144.55");
1006 host_resolver0.rules()->AddSimulatedFailure("host6"); 1069 host_resolver0.rules()->AddSimulatedFailure("host6");
1007 host_resolver0.rules()->AddRuleForAddressFamily( 1070 host_resolver0.rules()->AddRuleForAddressFamily(
1008 "*", ADDRESS_FAMILY_IPV4, "122.133.144.155"); 1071 "*", ADDRESS_FAMILY_IPV4, "122.133.144.155");
1009 host_resolver0.rules()->AddRule("*", "133.122.100.200"); 1072 host_resolver0.rules()->AddRule("*", "133.122.100.200");
1010 ProxyResolverV8Tracing resolver0( 1073 scoped_ptr<ProxyResolver> resolver0 =
1011 &host_resolver0, new MockErrorObserver, NULL); 1074 CreateResolver(nullptr, &host_resolver0,
1012 InitResolver(&resolver0, "dns.js"); 1075 make_scoped_ptr(new MockErrorObserver), "dns.js");
1013 1076
1014 // ------------------------ 1077 // ------------------------
1015 // Setup resolver1 1078 // Setup resolver1
1016 // ------------------------ 1079 // ------------------------
1017 ProxyResolverV8Tracing resolver1( 1080 scoped_ptr<ProxyResolver> resolver1 =
1018 &host_resolver0, new MockErrorObserver, NULL); 1081 CreateResolver(nullptr, &host_resolver0,
1019 InitResolver(&resolver1, "dns.js"); 1082 make_scoped_ptr(new MockErrorObserver), "dns.js");
1020 1083
1021 // ------------------------ 1084 // ------------------------
1022 // Setup resolver2 1085 // Setup resolver2
1023 // ------------------------ 1086 // ------------------------
1024 ProxyResolverV8Tracing resolver2( 1087 scoped_ptr<ProxyResolver> resolver2 =
1025 &host_resolver0, new MockErrorObserver, NULL); 1088 CreateResolver(nullptr, &host_resolver0,
1026 InitResolver(&resolver2, "simple.js"); 1089 make_scoped_ptr(new MockErrorObserver), "simple.js");
1027 1090
1028 // ------------------------ 1091 // ------------------------
1029 // Setup resolver3 1092 // Setup resolver3
1030 // ------------------------ 1093 // ------------------------
1031 MockHostResolver host_resolver3; 1094 MockHostResolver host_resolver3;
1032 host_resolver3.rules()->AddRule("foo", "166.155.144.33"); 1095 host_resolver3.rules()->AddRule("foo", "166.155.144.33");
1033 ProxyResolverV8Tracing resolver3( 1096 scoped_ptr<ProxyResolver> resolver3 =
1034 &host_resolver3, new MockErrorObserver, NULL); 1097 CreateResolver(nullptr, &host_resolver3,
1035 InitResolver(&resolver3, "simple_dns.js"); 1098 make_scoped_ptr(new MockErrorObserver), "simple_dns.js");
1036 1099
1037 // ------------------------ 1100 // ------------------------
1038 // Queue up work for each resolver (which will be running in parallel). 1101 // Queue up work for each resolver (which will be running in parallel).
1039 // ------------------------ 1102 // ------------------------
1040 1103
1041 ProxyResolverV8Tracing* resolver[] = { 1104 ProxyResolver* resolver[] = {
1042 &resolver0, &resolver1, &resolver2, &resolver3, 1105 resolver0.get(), resolver1.get(), resolver2.get(), resolver3.get(),
1043 }; 1106 };
1044 1107
1045 const size_t kNumResolvers = arraysize(resolver); 1108 const size_t kNumResolvers = arraysize(resolver);
1046 const size_t kNumIterations = 20; 1109 const size_t kNumIterations = 20;
1047 const size_t kNumResults = kNumResolvers * kNumIterations; 1110 const size_t kNumResults = kNumResolvers * kNumIterations;
1048 TestCompletionCallback callback[kNumResults]; 1111 TestCompletionCallback callback[kNumResults];
1049 ProxyInfo proxy_info[kNumResults]; 1112 ProxyInfo proxy_info[kNumResults];
1050 1113
1051 for (size_t i = 0; i < kNumResults; ++i) { 1114 for (size_t i = 0; i < kNumResults; ++i) {
1052 size_t resolver_i = i % kNumResolvers; 1115 size_t resolver_i = i % kNumResolvers;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 proxy_uri.substr(0, proxy_uri.find(':') + 1)); 1154 proxy_uri.substr(0, proxy_uri.find(':') + 1));
1092 } else { 1155 } else {
1093 NOTREACHED(); 1156 NOTREACHED();
1094 } 1157 }
1095 } 1158 }
1096 } 1159 }
1097 1160
1098 } // namespace 1161 } // namespace
1099 1162
1100 } // namespace net 1163 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698