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

Side by Side Diff: net/url_request/url_request_test_util.h

Issue 10408067: [net] Switch TestURLRequestContext to use MockCachingHostResolver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to trunk. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « net/socket_stream/socket_stream_unittest.cc ('k') | net/url_request/url_request_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_
6 #define NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/message_loop_proxy.h" 17 #include "base/message_loop_proxy.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/process_util.h" 19 #include "base/process_util.h"
20 #include "base/string16.h" 20 #include "base/string16.h"
21 #include "base/string_util.h" 21 #include "base/string_util.h"
22 #include "base/time.h" 22 #include "base/time.h"
23 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
24 #include "googleurl/src/url_util.h" 24 #include "googleurl/src/url_util.h"
25 #include "net/base/cert_verifier.h" 25 #include "net/base/cert_verifier.h"
26 #include "net/base/host_resolver.h"
27 #include "net/base/io_buffer.h" 26 #include "net/base/io_buffer.h"
28 #include "net/base/net_errors.h" 27 #include "net/base/net_errors.h"
29 #include "net/base/network_delegate.h" 28 #include "net/base/network_delegate.h"
30 #include "net/base/ssl_config_service_defaults.h" 29 #include "net/base/ssl_config_service_defaults.h"
31 #include "net/cookies/cookie_monster.h" 30 #include "net/cookies/cookie_monster.h"
32 #include "net/disk_cache/disk_cache.h" 31 #include "net/disk_cache/disk_cache.h"
33 #include "net/ftp/ftp_network_layer.h" 32 #include "net/ftp/ftp_network_layer.h"
34 #include "net/http/http_auth_handler_factory.h" 33 #include "net/http/http_auth_handler_factory.h"
35 #include "net/http/http_cache.h" 34 #include "net/http/http_cache.h"
36 #include "net/http/http_network_layer.h" 35 #include "net/http/http_network_layer.h"
37 #include "net/proxy/proxy_service.h" 36 #include "net/proxy/proxy_service.h"
38 #include "net/url_request/url_request.h" 37 #include "net/url_request/url_request.h"
39 #include "net/url_request/url_request_context.h" 38 #include "net/url_request/url_request_context.h"
40 #include "net/url_request/url_request_context_getter.h" 39 #include "net/url_request/url_request_context_getter.h"
41 #include "net/url_request/url_request_context_storage.h" 40 #include "net/url_request/url_request_context_storage.h"
42 41
43 using base::TimeDelta; 42 using base::TimeDelta;
44 43
45 //----------------------------------------------------------------------------- 44 //-----------------------------------------------------------------------------
46 45
47 class TestURLRequestContext : public net::URLRequestContext { 46 class TestURLRequestContext : public net::URLRequestContext {
48 public: 47 public:
49 TestURLRequestContext(); 48 TestURLRequestContext();
50 // Default constructor like TestURLRequestContext() but does not call 49 // Default constructor like TestURLRequestContext() but does not call
51 // Init() in case |delay_initialization| is true. This allows modifying the 50 // Init() in case |delay_initialization| is true. This allows modifying the
52 // URLRequestContext before it is constructed completely. If 51 // URLRequestContext before it is constructed completely. If
53 // |delay_initialization| is true, Init() needs be be called manually. 52 // |delay_initialization| is true, Init() needs be be called manually.
54 explicit TestURLRequestContext(bool delay_initialization); 53 explicit TestURLRequestContext(bool delay_initialization);
55 // We need this constructor because TestURLRequestContext("foo") actually
56 // calls the boolean constructor rather than the std::string constructor.
57 explicit TestURLRequestContext(const char* proxy);
58 explicit TestURLRequestContext(const std::string& proxy);
59 TestURLRequestContext(const std::string& proxy,
60 net::HostResolver* host_resolver);
61 virtual ~TestURLRequestContext(); 54 virtual ~TestURLRequestContext();
62 55
63 // Configures the proxy server, must not be called after Init().
64 void SetProxyFromString(const std::string& proxy);
65 void SetProxyDirect();
66
67 void Init(); 56 void Init();
68 57
69 private: 58 private:
70 bool initialized_; 59 bool initialized_;
60
61 protected:
71 net::URLRequestContextStorage context_storage_; 62 net::URLRequestContextStorage context_storage_;
72 }; 63 };
73 64
74 //----------------------------------------------------------------------------- 65 //-----------------------------------------------------------------------------
75 66
76 // Used to return a dummy context, which lives on the message loop 67 // Used to return a dummy context, which lives on the message loop
77 // given in the constructor. 68 // given in the constructor.
78 class TestURLRequestContextGetter : public net::URLRequestContextGetter { 69 class TestURLRequestContextGetter : public net::URLRequestContextGetter {
79 public: 70 public:
80 // |io_message_loop_proxy| must not be NULL. 71 // |io_message_loop_proxy| must not be NULL.
81 explicit TestURLRequestContextGetter( 72 explicit TestURLRequestContextGetter(
82 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy); 73 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy);
83 74
75 // Use to pass a pre-initialized |context|.
76 TestURLRequestContextGetter(
77 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy,
78 scoped_ptr<TestURLRequestContext> context);
79
84 // net::URLRequestContextGetter implementation. 80 // net::URLRequestContextGetter implementation.
85 virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE; 81 virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE;
86 virtual scoped_refptr<base::MessageLoopProxy> 82 virtual scoped_refptr<base::MessageLoopProxy>
87 GetIOMessageLoopProxy() const OVERRIDE; 83 GetIOMessageLoopProxy() const OVERRIDE;
88 84
89 protected: 85 protected:
90 virtual ~TestURLRequestContextGetter(); 86 virtual ~TestURLRequestContextGetter();
91 87
92 private: 88 private:
93 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; 89 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 287
292 private: 288 private:
293 static std::string value_; 289 static std::string value_;
294 const std::string old_value_; 290 const std::string old_value_;
295 const std::string new_value_; 291 const std::string new_value_;
296 292
297 DISALLOW_COPY_AND_ASSIGN(ScopedCustomUrlRequestTestHttpHost); 293 DISALLOW_COPY_AND_ASSIGN(ScopedCustomUrlRequestTestHttpHost);
298 }; 294 };
299 295
300 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ 296 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « net/socket_stream/socket_stream_unittest.cc ('k') | net/url_request/url_request_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698