| 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/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 15 #include "net/base/host_port_pair.h" | 15 #include "net/base/host_port_pair.h" |
| 16 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
| 17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "net/base/upload_data_stream.h" |
| 18 #include "net/http/http_response_headers.h" | 19 #include "net/http/http_response_headers.h" |
| 19 #include "net/url_request/url_fetcher_delegate.h" | 20 #include "net/url_request/url_fetcher_delegate.h" |
| 20 #include "net/url_request/url_fetcher_impl.h" | 21 #include "net/url_request/url_fetcher_impl.h" |
| 21 #include "net/url_request/url_fetcher_response_writer.h" | 22 #include "net/url_request/url_fetcher_response_writer.h" |
| 22 #include "net/url_request/url_request_status.h" | 23 #include "net/url_request/url_request_status.h" |
| 23 | 24 |
| 24 namespace net { | 25 namespace net { |
| 25 | 26 |
| 26 ScopedURLFetcherFactory::ScopedURLFetcherFactory( | 27 ScopedURLFetcherFactory::ScopedURLFetcherFactory( |
| 27 URLFetcherFactory* factory) { | 28 URLFetcherFactory* factory) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 67 |
| 67 void TestURLFetcher::SetUploadFilePath( | 68 void TestURLFetcher::SetUploadFilePath( |
| 68 const std::string& upload_content_type, | 69 const std::string& upload_content_type, |
| 69 const base::FilePath& file_path, | 70 const base::FilePath& file_path, |
| 70 uint64 range_offset, | 71 uint64 range_offset, |
| 71 uint64 range_length, | 72 uint64 range_length, |
| 72 scoped_refptr<base::TaskRunner> file_task_runner) { | 73 scoped_refptr<base::TaskRunner> file_task_runner) { |
| 73 upload_file_path_ = file_path; | 74 upload_file_path_ = file_path; |
| 74 } | 75 } |
| 75 | 76 |
| 77 void TestURLFetcher::SetUploadStream( |
| 78 const std::string& upload_content_type, |
| 79 scoped_ptr<net::UploadDataStream> upload_stream) { |
| 80 upload_stream_ = upload_stream.Pass(); |
| 81 } |
| 82 |
| 76 void TestURLFetcher::SetChunkedUpload(const std::string& upload_content_type) { | 83 void TestURLFetcher::SetChunkedUpload(const std::string& upload_content_type) { |
| 77 } | 84 } |
| 78 | 85 |
| 79 void TestURLFetcher::AppendChunkToUpload(const std::string& data, | 86 void TestURLFetcher::AppendChunkToUpload(const std::string& data, |
| 80 bool is_last_chunk) { | 87 bool is_last_chunk) { |
| 81 DCHECK(!did_receive_last_chunk_); | 88 DCHECK(!did_receive_last_chunk_); |
| 82 did_receive_last_chunk_ = is_last_chunk; | 89 did_receive_last_chunk_ = is_last_chunk; |
| 83 chunks_.push_back(data); | 90 chunks_.push_back(data); |
| 84 if (delegate_for_tests_) | 91 if (delegate_for_tests_) |
| 85 delegate_for_tests_->OnChunkUpload(id_); | 92 delegate_for_tests_->OnChunkUpload(id_); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 446 |
| 440 URLFetcher* URLFetcherImplFactory::CreateURLFetcher( | 447 URLFetcher* URLFetcherImplFactory::CreateURLFetcher( |
| 441 int id, | 448 int id, |
| 442 const GURL& url, | 449 const GURL& url, |
| 443 URLFetcher::RequestType request_type, | 450 URLFetcher::RequestType request_type, |
| 444 URLFetcherDelegate* d) { | 451 URLFetcherDelegate* d) { |
| 445 return new URLFetcherImpl(url, request_type, d); | 452 return new URLFetcherImpl(url, request_type, d); |
| 446 } | 453 } |
| 447 | 454 |
| 448 } // namespace net | 455 } // namespace net |
| OLD | NEW |