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

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

Issue 10299002: Stop refcounting URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize to NULL 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/url_request/url_request_job_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
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Init() in case |delay_initialization| is true. This allows modifying the 51 // Init() in case |delay_initialization| is true. This allows modifying the
52 // URLRequestContext before it is constructed completely. If 52 // URLRequestContext before it is constructed completely. If
53 // |delay_initialization| is true, Init() needs be be called manually. 53 // |delay_initialization| is true, Init() needs be be called manually.
54 explicit TestURLRequestContext(bool delay_initialization); 54 explicit TestURLRequestContext(bool delay_initialization);
55 // We need this constructor because TestURLRequestContext("foo") actually 55 // We need this constructor because TestURLRequestContext("foo") actually
56 // calls the boolean constructor rather than the std::string constructor. 56 // calls the boolean constructor rather than the std::string constructor.
57 explicit TestURLRequestContext(const char* proxy); 57 explicit TestURLRequestContext(const char* proxy);
58 explicit TestURLRequestContext(const std::string& proxy); 58 explicit TestURLRequestContext(const std::string& proxy);
59 TestURLRequestContext(const std::string& proxy, 59 TestURLRequestContext(const std::string& proxy,
60 net::HostResolver* host_resolver); 60 net::HostResolver* host_resolver);
61 virtual ~TestURLRequestContext();
61 62
62 // Configures the proxy server, must not be called after Init(). 63 // Configures the proxy server, must not be called after Init().
63 void SetProxyFromString(const std::string& proxy); 64 void SetProxyFromString(const std::string& proxy);
64 void SetProxyDirect(); 65 void SetProxyDirect();
65 66
66 void Init(); 67 void Init();
67 68
68 protected:
69 virtual ~TestURLRequestContext();
70
71 private: 69 private:
72 bool initialized_; 70 bool initialized_;
73 net::URLRequestContextStorage context_storage_; 71 net::URLRequestContextStorage context_storage_;
74 }; 72 };
75 73
76 //----------------------------------------------------------------------------- 74 //-----------------------------------------------------------------------------
77 75
78 // Used to return a dummy context, which lives on the message loop 76 // Used to return a dummy context, which lives on the message loop
79 // given in the constructor. 77 // given in the constructor.
80 class TestURLRequestContextGetter : public net::URLRequestContextGetter { 78 class TestURLRequestContextGetter : public net::URLRequestContextGetter {
81 public: 79 public:
82 // |io_message_loop_proxy| must not be NULL. 80 // |io_message_loop_proxy| must not be NULL.
83 explicit TestURLRequestContextGetter( 81 explicit TestURLRequestContextGetter(
84 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy); 82 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy);
85 83
86 // net::URLRequestContextGetter implementation. 84 // net::URLRequestContextGetter implementation.
87 virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE; 85 virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE;
88 virtual scoped_refptr<base::MessageLoopProxy> 86 virtual scoped_refptr<base::MessageLoopProxy>
89 GetIOMessageLoopProxy() const OVERRIDE; 87 GetIOMessageLoopProxy() const OVERRIDE;
90 88
91 protected: 89 protected:
92 virtual ~TestURLRequestContextGetter(); 90 virtual ~TestURLRequestContextGetter();
93 91
94 private: 92 private:
95 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; 93 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
96 scoped_refptr<TestURLRequestContext> context_; 94 scoped_ptr<TestURLRequestContext> context_;
97 }; 95 };
98 96
99 //----------------------------------------------------------------------------- 97 //-----------------------------------------------------------------------------
100 98
101 class TestURLRequest : public net::URLRequest { 99 class TestURLRequest : public net::URLRequest {
102 public: 100 public:
103 TestURLRequest(const GURL& url, Delegate* delegate); 101 TestURLRequest(const GURL& url, Delegate* delegate);
104 virtual ~TestURLRequest(); 102 virtual ~TestURLRequest();
103
104 private:
105 const scoped_ptr<net::URLRequestContext> context_;
105 }; 106 };
106 107
107 //----------------------------------------------------------------------------- 108 //-----------------------------------------------------------------------------
108 109
109 class TestDelegate : public net::URLRequest::Delegate { 110 class TestDelegate : public net::URLRequest::Delegate {
110 public: 111 public:
111 TestDelegate(); 112 TestDelegate();
112 virtual ~TestDelegate(); 113 virtual ~TestDelegate();
113 114
114 void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; } 115 void set_cancel_in_received_redirect(bool val) { cancel_in_rr_ = val; }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 291
291 private: 292 private:
292 static std::string value_; 293 static std::string value_;
293 const std::string old_value_; 294 const std::string old_value_;
294 const std::string new_value_; 295 const std::string new_value_;
295 296
296 DISALLOW_COPY_AND_ASSIGN(ScopedCustomUrlRequestTestHttpHost); 297 DISALLOW_COPY_AND_ASSIGN(ScopedCustomUrlRequestTestHttpHost);
297 }; 298 };
298 299
299 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ 300 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_job_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