| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/net/resolve_proxy_msg_helper.h" | 5 #include "chrome/browser/net/resolve_proxy_msg_helper.h" |
| 6 | 6 |
| 7 #include "base/waitable_event.h" | 7 #include "base/waitable_event.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 // This ProxyConfigService always returns "http://pac" as the PAC url to use. | 11 // This ProxyConfigService always returns "http://pac" as the PAC url to use. |
| 12 class MockProxyConfigService: public net::ProxyConfigService { | 12 class MockProxyConfigService: public net::ProxyConfigService { |
| 13 public: | 13 public: |
| 14 virtual int GetProxyConfig(net::ProxyConfig* results) { | 14 virtual int GetProxyConfig(net::ProxyConfig* results) { |
| 15 results->pac_url = GURL("http://pac"); | 15 results->pac_url = GURL("http://pac"); |
| 16 return net::OK; | 16 return net::OK; |
| 17 } | 17 } |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 // This PAC resolver always returns the hostname of the query URL as the | 20 // This PAC resolver always returns the hostname of the query URL as the |
| 21 // proxy to use. The Block() method will make GetProxyForURL() hang until | 21 // proxy to use. The Block() method will make GetProxyForURL() hang until |
| 22 // Unblock() is called. | 22 // Unblock() is called. |
| 23 class MockProxyResolver : public net::ProxyResolver { | 23 class MockProxyResolver : public net::ProxyResolver { |
| 24 public: | 24 public: |
| 25 explicit MockProxyResolver() : event_(false, false), is_blocked_(false) { | 25 MockProxyResolver() : ProxyResolver(true), event_(false, false), |
| 26 is_blocked_(false) { |
| 26 } | 27 } |
| 27 | 28 |
| 28 virtual int GetProxyForURL(const GURL& query_url, | 29 virtual int GetProxyForURL(const GURL& query_url, |
| 29 const GURL& /*pac_url*/, | 30 const GURL& /*pac_url*/, |
| 30 net::ProxyInfo* results) { | 31 net::ProxyInfo* results) { |
| 31 if (is_blocked_) | 32 if (is_blocked_) |
| 32 event_.Wait(); | 33 event_.Wait(); |
| 33 results->UseNamedProxy(query_url.host()); | 34 results->UseNamedProxy(query_url.host()); |
| 34 return net::OK; | 35 return net::OK; |
| 35 } | 36 } |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 result1->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); | 341 result1->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); |
| 341 EXPECT_FALSE( | 342 EXPECT_FALSE( |
| 342 result2->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); | 343 result2->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); |
| 343 EXPECT_FALSE( | 344 EXPECT_FALSE( |
| 344 result3->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); | 345 result3->TimedWaitUntilDone(base::TimeDelta::FromMilliseconds(2))); |
| 345 | 346 |
| 346 // It should also be the case that msg1, msg2, msg3 were deleted by the | 347 // It should also be the case that msg1, msg2, msg3 were deleted by the |
| 347 // cancellation. (Else will show up as a leak in Purify). | 348 // cancellation. (Else will show up as a leak in Purify). |
| 348 } | 349 } |
| 349 | 350 |
| OLD | NEW |