| 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 #include "net/url_request/url_request_test_util.h" | 5 #include "net/url_request/url_request_test_util.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 if (accept_language().empty()) | 155 if (accept_language().empty()) |
| 156 set_accept_language("en-us,fr"); | 156 set_accept_language("en-us,fr"); |
| 157 if (accept_charset().empty()) | 157 if (accept_charset().empty()) |
| 158 set_accept_charset("iso-8859-1,*,utf-8"); | 158 set_accept_charset("iso-8859-1,*,utf-8"); |
| 159 if (!job_factory()) | 159 if (!job_factory()) |
| 160 context_storage_.set_job_factory(new net::URLRequestJobFactory); | 160 context_storage_.set_job_factory(new net::URLRequestJobFactory); |
| 161 } | 161 } |
| 162 | 162 |
| 163 | 163 |
| 164 TestURLRequest::TestURLRequest(const GURL& url, Delegate* delegate) | 164 TestURLRequest::TestURLRequest(const GURL& url, Delegate* delegate) |
| 165 : net::URLRequest(url, delegate) { | 165 : net::URLRequest(url, delegate), |
| 166 set_context(new TestURLRequestContext()); | 166 context_(new TestURLRequestContext) { |
| 167 set_context(context_.get()); |
| 167 } | 168 } |
| 168 | 169 |
| 169 TestURLRequest::~TestURLRequest() {} | 170 TestURLRequest::~TestURLRequest() { |
| 171 set_context(NULL); |
| 172 } |
| 170 | 173 |
| 171 TestURLRequestContextGetter::TestURLRequestContextGetter( | 174 TestURLRequestContextGetter::TestURLRequestContextGetter( |
| 172 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy) | 175 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy) |
| 173 : io_message_loop_proxy_(io_message_loop_proxy) { | 176 : io_message_loop_proxy_(io_message_loop_proxy) { |
| 174 DCHECK(io_message_loop_proxy.get()); | 177 DCHECK(io_message_loop_proxy.get()); |
| 175 } | 178 } |
| 176 | 179 |
| 177 TestURLRequestContextGetter::~TestURLRequestContextGetter() {} | 180 TestURLRequestContextGetter::~TestURLRequestContextGetter() {} |
| 178 | 181 |
| 179 TestURLRequestContext* TestURLRequestContextGetter::GetURLRequestContext() { | 182 TestURLRequestContext* TestURLRequestContextGetter::GetURLRequestContext() { |
| 180 if (!context_) | 183 if (!context_.get()) |
| 181 context_ = new TestURLRequestContext(); | 184 context_.reset(new TestURLRequestContext); |
| 182 return context_.get(); | 185 return context_.get(); |
| 183 } | 186 } |
| 184 | 187 |
| 185 scoped_refptr<base::MessageLoopProxy> | 188 scoped_refptr<base::MessageLoopProxy> |
| 186 TestURLRequestContextGetter::GetIOMessageLoopProxy() const { | 189 TestURLRequestContextGetter::GetIOMessageLoopProxy() const { |
| 187 return io_message_loop_proxy_; | 190 return io_message_loop_proxy_; |
| 188 } | 191 } |
| 189 | 192 |
| 190 TestDelegate::TestDelegate() | 193 TestDelegate::TestDelegate() |
| 191 : cancel_in_rr_(false), | 194 : cancel_in_rr_(false), |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 547 |
| 545 ScopedCustomUrlRequestTestHttpHost::~ScopedCustomUrlRequestTestHttpHost() { | 548 ScopedCustomUrlRequestTestHttpHost::~ScopedCustomUrlRequestTestHttpHost() { |
| 546 DCHECK_EQ(value_, new_value_); | 549 DCHECK_EQ(value_, new_value_); |
| 547 value_ = old_value_; | 550 value_ = old_value_; |
| 548 } | 551 } |
| 549 | 552 |
| 550 // static | 553 // static |
| 551 const std::string& ScopedCustomUrlRequestTestHttpHost::value() { | 554 const std::string& ScopedCustomUrlRequestTestHttpHost::value() { |
| 552 return value_; | 555 return value_; |
| 553 } | 556 } |
| OLD | NEW |