| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/net/test_url_fetcher_factory.h" | 5 #include "chrome/common/net/test_url_fetcher_factory.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "net/url_request/url_request_status.h" | 11 #include "net/url_request/url_request_status.h" |
| 12 | 12 |
| 13 TestURLFetcher::TestURLFetcher(int id, | 13 TestURLFetcher::TestURLFetcher(int id, |
| 14 const GURL& url, | 14 const GURL& url, |
| 15 URLFetcher::RequestType request_type, | 15 URLFetcher::RequestType request_type, |
| 16 URLFetcher::Delegate* d) | 16 URLFetcher::Delegate* d) |
| 17 : URLFetcher(url, request_type, d), | 17 : URLFetcher(url, request_type, d), |
| 18 id_(id), | 18 id_(id), |
| 19 original_url_(url) { | 19 original_url_(url), |
| 20 did_receive_last_chunk_(false) { |
| 21 } |
| 22 |
| 23 void TestURLFetcher::AppendChunkToUpload(const std::string& data, |
| 24 bool is_last_chunk) { |
| 25 DCHECK(!did_receive_last_chunk_); |
| 26 did_receive_last_chunk_ = is_last_chunk; |
| 27 chunks_.push_back(data); |
| 20 } | 28 } |
| 21 | 29 |
| 22 TestURLFetcherFactory::TestURLFetcherFactory() {} | 30 TestURLFetcherFactory::TestURLFetcherFactory() {} |
| 23 | 31 |
| 24 TestURLFetcherFactory::~TestURLFetcherFactory() {} | 32 TestURLFetcherFactory::~TestURLFetcherFactory() {} |
| 25 | 33 |
| 26 URLFetcher* TestURLFetcherFactory::CreateURLFetcher( | 34 URLFetcher* TestURLFetcherFactory::CreateURLFetcher( |
| 27 int id, | 35 int id, |
| 28 const GURL& url, | 36 const GURL& url, |
| 29 URLFetcher::RequestType request_type, | 37 URLFetcher::RequestType request_type, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 void FakeURLFetcherFactory::SetFakeResponse(const std::string& url, | 121 void FakeURLFetcherFactory::SetFakeResponse(const std::string& url, |
| 114 const std::string& response_data, | 122 const std::string& response_data, |
| 115 bool success) { | 123 bool success) { |
| 116 // Overwrite existing URL if it already exists. | 124 // Overwrite existing URL if it already exists. |
| 117 fake_responses_[GURL(url)] = std::make_pair(response_data, success); | 125 fake_responses_[GURL(url)] = std::make_pair(response_data, success); |
| 118 } | 126 } |
| 119 | 127 |
| 120 void FakeURLFetcherFactory::ClearFakeReponses() { | 128 void FakeURLFetcherFactory::ClearFakeReponses() { |
| 121 fake_responses_.clear(); | 129 fake_responses_.clear(); |
| 122 } | 130 } |
| OLD | NEW |