Chromium Code Reviews| 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/test_url_fetcher_factory.h" | 5 #include "net/url_request/test_url_fetcher_factory.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "net/base/host_port_pair.h" | 13 #include "net/base/host_port_pair.h" |
| 14 #include "net/base/upload_data_stream.h" | |
| 14 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
| 15 #include "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
| 16 #include "net/url_request/url_fetcher_impl.h" | 17 #include "net/url_request/url_fetcher_impl.h" |
| 17 #include "net/url_request/url_request_status.h" | 18 #include "net/url_request/url_request_status.h" |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 | 21 |
| 21 ScopedURLFetcherFactory::ScopedURLFetcherFactory( | 22 ScopedURLFetcherFactory::ScopedURLFetcherFactory( |
| 22 URLFetcherFactory* factory) { | 23 URLFetcherFactory* factory) { |
| 23 DCHECK(!URLFetcherImpl::factory()); | 24 DCHECK(!URLFetcherImpl::factory()); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 45 fake_max_retries_(0) { | 46 fake_max_retries_(0) { |
| 46 } | 47 } |
| 47 | 48 |
| 48 TestURLFetcher::~TestURLFetcher() { | 49 TestURLFetcher::~TestURLFetcher() { |
| 49 if (delegate_for_tests_) | 50 if (delegate_for_tests_) |
| 50 delegate_for_tests_->OnRequestEnd(id_); | 51 delegate_for_tests_->OnRequestEnd(id_); |
| 51 if (owner_) | 52 if (owner_) |
| 52 owner_->RemoveFetcherFromMap(id_); | 53 owner_->RemoveFetcherFromMap(id_); |
| 53 } | 54 } |
| 54 | 55 |
| 56 void TestURLFetcher::SetUploadDataStream( | |
| 57 const std::string& upload_content_type, | |
| 58 scoped_ptr<UploadDataStream> upload_content) { | |
| 59 upload_data_stream_ = upload_content.Pass(); | |
| 60 } | |
| 61 | |
| 55 void TestURLFetcher::SetUploadData(const std::string& upload_content_type, | 62 void TestURLFetcher::SetUploadData(const std::string& upload_content_type, |
| 56 const std::string& upload_content) { | 63 const std::string& upload_content) { |
| 57 upload_data_ = upload_content; | 64 upload_data_ = upload_content; |
|
hashimoto
2013/01/11 06:07:38
Having both upload_data_stream_ and upload_data_ s
mattm
2013/01/11 21:42:02
Thought about that, but wasn't entirely sure what
hashimoto
2013/01/15 06:59:28
I see. Seems all users of this method just want t
| |
| 58 } | 65 } |
| 59 | 66 |
| 60 void TestURLFetcher::SetChunkedUpload(const std::string& upload_content_type) { | 67 void TestURLFetcher::SetChunkedUpload(const std::string& upload_content_type) { |
| 61 } | 68 } |
| 62 | 69 |
| 63 void TestURLFetcher::AppendChunkToUpload(const std::string& data, | 70 void TestURLFetcher::AppendChunkToUpload(const std::string& data, |
| 64 bool is_last_chunk) { | 71 bool is_last_chunk) { |
| 65 DCHECK(!did_receive_last_chunk_); | 72 DCHECK(!did_receive_last_chunk_); |
| 66 did_receive_last_chunk_ = is_last_chunk; | 73 did_receive_last_chunk_ = is_last_chunk; |
| 67 chunks_.push_back(data); | 74 chunks_.push_back(data); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 | 370 |
| 364 URLFetcher* URLFetcherImplFactory::CreateURLFetcher( | 371 URLFetcher* URLFetcherImplFactory::CreateURLFetcher( |
| 365 int id, | 372 int id, |
| 366 const GURL& url, | 373 const GURL& url, |
| 367 URLFetcher::RequestType request_type, | 374 URLFetcher::RequestType request_type, |
| 368 URLFetcherDelegate* d) { | 375 URLFetcherDelegate* d) { |
| 369 return new URLFetcherImpl(url, request_type, d); | 376 return new URLFetcherImpl(url, request_type, d); |
| 370 } | 377 } |
| 371 | 378 |
| 372 } // namespace net | 379 } // namespace net |
| OLD | NEW |