| OLD | NEW |
| 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 Loading... |
| 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(); |
| 105 }; | 103 }; |
| 106 | 104 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 286 |
| 289 private: | 287 private: |
| 290 static std::string value_; | 288 static std::string value_; |
| 291 const std::string old_value_; | 289 const std::string old_value_; |
| 292 const std::string new_value_; | 290 const std::string new_value_; |
| 293 | 291 |
| 294 DISALLOW_COPY_AND_ASSIGN(ScopedCustomUrlRequestTestHttpHost); | 292 DISALLOW_COPY_AND_ASSIGN(ScopedCustomUrlRequestTestHttpHost); |
| 295 }; | 293 }; |
| 296 | 294 |
| 297 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ | 295 #endif // NET_URL_REQUEST_URL_REQUEST_TEST_UTIL_H_ |
| OLD | NEW |