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

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

Issue 118100: Avoid doing concurrent DNS resolves of the same hostname (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Get compiling on mac Created 11 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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_script_fetcher.h" 5 #include "net/proxy/proxy_script_fetcher.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "net/base/net_util.h" 10 #include "net/base/net_util.h"
(...skipping 12 matching lines...) Expand all
23 struct FetchResult { 23 struct FetchResult {
24 int code; 24 int code;
25 std::string bytes; 25 std::string bytes;
26 }; 26 };
27 27
28 // A non-mock URL request which can access http:// and file:// urls. 28 // A non-mock URL request which can access http:// and file:// urls.
29 class RequestContext : public URLRequestContext { 29 class RequestContext : public URLRequestContext {
30 public: 30 public:
31 RequestContext() { 31 RequestContext() {
32 net::ProxyConfig no_proxy; 32 net::ProxyConfig no_proxy;
33 host_resolver_ = new net::HostResolver;
33 proxy_service_ = net::ProxyService::CreateFixed(no_proxy); 34 proxy_service_ = net::ProxyService::CreateFixed(no_proxy);
34 35
35 http_transaction_factory_ = 36 http_transaction_factory_ =
36 new net::HttpCache(net::HttpNetworkLayer::CreateFactory(proxy_service_), 37 new net::HttpCache(net::HttpNetworkLayer::CreateFactory(
37 disk_cache::CreateInMemoryCacheBackend(0)); 38 host_resolver_, proxy_service_),
39 disk_cache::CreateInMemoryCacheBackend(0));
38 } 40 }
39 ~RequestContext() { 41 ~RequestContext() {
40 delete http_transaction_factory_; 42 delete http_transaction_factory_;
41 delete proxy_service_; 43 delete proxy_service_;
44 delete host_resolver_;
42 } 45 }
43 }; 46 };
44 47
45 // Helper for doing synch fetches. This object lives in SynchFetcher's 48 // Helper for doing synch fetches. This object lives in SynchFetcher's
46 // |io_thread_| and communicates with SynchFetcher though (|result|, |event|). 49 // |io_thread_| and communicates with SynchFetcher though (|result|, |event|).
47 class SynchFetcherThreadHelper { 50 class SynchFetcherThreadHelper {
48 public: 51 public:
49 SynchFetcherThreadHelper(base::WaitableEvent* event, FetchResult* result) 52 SynchFetcherThreadHelper(base::WaitableEvent* event, FetchResult* result)
50 : event_(event), 53 : event_(event),
51 fetch_result_(result), 54 fetch_result_(result),
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 329
327 { // Make sure we can still fetch regular URLs. 330 { // Make sure we can still fetch regular URLs.
328 GURL url = server->TestServerPage("files/pac.nsproxy"); 331 GURL url = server->TestServerPage("files/pac.nsproxy");
329 FetchResult result = pac_fetcher.Fetch(url); 332 FetchResult result = pac_fetcher.Fetch(url);
330 EXPECT_EQ(net::OK, result.code); 333 EXPECT_EQ(net::OK, result.code);
331 EXPECT_EQ("-pac.nsproxy-\n", result.bytes); 334 EXPECT_EQ("-pac.nsproxy-\n", result.bytes);
332 } 335 }
333 } 336 }
334 337
335 } // namespace net 338 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698