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_fetcher_impl.h" | 5 #include "net/url_request/url_fetcher_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 scoped_ptr<UploadElementReader>( | 193 scoped_ptr<UploadElementReader>( |
194 new UploadOwnedBytesElementReader(&buffer)), | 194 new UploadOwnedBytesElementReader(&buffer)), |
195 0); | 195 0); |
196 } | 196 } |
197 | 197 |
198 // Number of streams created by CreateUploadStream. | 198 // Number of streams created by CreateUploadStream. |
199 size_t num_upload_streams_created() const { | 199 size_t num_upload_streams_created() const { |
200 return num_upload_streams_created_; | 200 return num_upload_streams_created_; |
201 } | 201 } |
202 | 202 |
203 // Downloads |file_to_fetch| and checks the contents when done. If | |
204 // |save_to_temporary_file| is true, saves it to a temporary file, and | |
205 // |requested_out_path| is ignored. Otherwise, saves it to | |
206 // |requested_out_path|. Takes ownership of the file if |take_ownership| is | |
207 // true. Deletes file when done. | |
208 void SaveFileTest(const char* file_to_fetch, | |
209 bool save_to_temporary_file, | |
210 const base::FilePath& requested_out_path, | |
211 bool take_ownership) { | |
212 scoped_ptr<WaitingURLFetcherDelegate> delegate( | |
213 new WaitingURLFetcherDelegate()); | |
214 delegate->CreateFetcherWithContext( | |
215 test_server_->GetURL(std::string(kTestServerFilePrefix) + | |
216 file_to_fetch), | |
217 URLFetcher::GET, request_context()); | |
218 if (save_to_temporary_file) { | |
219 delegate->fetcher()->SaveResponseToTemporaryFile( | |
220 scoped_refptr<base::MessageLoopProxy>( | |
221 base::MessageLoopProxy::current())); | |
222 } else { | |
223 delegate->fetcher()->SaveResponseToFileAtPath( | |
224 requested_out_path, scoped_refptr<base::MessageLoopProxy>( | |
225 base::MessageLoopProxy::current())); | |
226 } | |
227 delegate->StartFetcherAndWait(); | |
228 | |
229 EXPECT_TRUE(delegate->fetcher()->GetStatus().is_success()); | |
230 EXPECT_EQ(200, delegate->fetcher()->GetResponseCode()); | |
231 | |
232 base::FilePath out_path; | |
233 EXPECT_TRUE( | |
234 delegate->fetcher()->GetResponseAsFilePath(take_ownership, &out_path)); | |
235 if (!save_to_temporary_file) { | |
236 EXPECT_EQ(requested_out_path, out_path); | |
237 } | |
238 | |
239 EXPECT_TRUE(base::ContentsEqual( | |
240 test_server_->GetDocumentRoot().AppendASCII(file_to_fetch), out_path)); | |
241 | |
242 // Delete the delegate and run the message loop to give the fetcher's | |
243 // destructor a chance to delete the file. | |
244 delegate.reset(); | |
245 base::RunLoop().RunUntilIdle(); | |
246 | |
247 // File should only exist if |take_ownership| was true. | |
248 EXPECT_EQ(take_ownership, base::PathExists(out_path)); | |
249 | |
250 // Cleanup. | |
251 if (base::PathExists(out_path)) | |
252 base::DeleteFile(out_path, false); | |
253 } | |
254 | |
255 // Returns a URL that hangs on DNS resolution. Only hangs when using the | 203 // Returns a URL that hangs on DNS resolution. Only hangs when using the |
256 // request context returned by request_context(). | 204 // request context returned by request_context(). |
257 const GURL& hanging_url() const { return hanging_url_; } | 205 const GURL& hanging_url() const { return hanging_url_; } |
258 | 206 |
259 MockHostResolver* resolver() { return &resolver_; } | 207 MockHostResolver* resolver() { return &resolver_; } |
260 | 208 |
261 // testing::Test: | 209 // testing::Test: |
262 void SetUp() override { | 210 void SetUp() override { |
263 SetUpServer(); | 211 SetUpServer(); |
264 ASSERT_TRUE(test_server_->Start()); | 212 ASSERT_TRUE(test_server_->Start()); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 // Version of URLFetcherTest that tests retying the same request twice. | 457 // Version of URLFetcherTest that tests retying the same request twice. |
510 class URLFetcherMultipleAttemptTest : public URLFetcherTest { | 458 class URLFetcherMultipleAttemptTest : public URLFetcherTest { |
511 public: | 459 public: |
512 // URLFetcherDelegate: | 460 // URLFetcherDelegate: |
513 void OnURLFetchComplete(const URLFetcher* source) override; | 461 void OnURLFetchComplete(const URLFetcher* source) override; |
514 | 462 |
515 private: | 463 private: |
516 std::string data_; | 464 std::string data_; |
517 }; | 465 }; |
518 | 466 |
| 467 class URLFetcherFileTest : public URLFetcherTest { |
| 468 public: |
| 469 URLFetcherFileTest() : take_ownership_of_file_(false), |
| 470 expected_file_error_(OK) {} |
| 471 |
| 472 void CreateFetcherForFile(const GURL& url, const base::FilePath& file_path); |
| 473 void CreateFetcherForTempFile(const GURL& url); |
| 474 |
| 475 // URLFetcherDelegate: |
| 476 void OnURLFetchComplete(const URLFetcher* source) override; |
| 477 |
| 478 protected: |
| 479 base::FilePath expected_file_; |
| 480 base::FilePath file_path_; |
| 481 |
| 482 // Set by the test. Used in OnURLFetchComplete() to decide if |
| 483 // the URLFetcher should own the temp file, so that we can test |
| 484 // disowning prevents the file from being deleted. |
| 485 bool take_ownership_of_file_; |
| 486 |
| 487 // Expected file error code for the test. OK when expecting success. |
| 488 int expected_file_error_; |
| 489 }; |
| 490 |
519 void URLFetcherDownloadProgressTest::CreateFetcher(const GURL& url) { | 491 void URLFetcherDownloadProgressTest::CreateFetcher(const GURL& url) { |
520 fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); | 492 fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); |
521 fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( | 493 fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( |
522 io_message_loop_proxy().get(), request_context())); | 494 io_message_loop_proxy().get(), request_context())); |
523 fetcher_->Start(); | 495 fetcher_->Start(); |
524 } | 496 } |
525 | 497 |
526 void URLFetcherDownloadProgressTest::OnURLFetchDownloadProgress( | 498 void URLFetcherDownloadProgressTest::OnURLFetchDownloadProgress( |
527 const URLFetcher* source, int64 progress, int64 total) { | 499 const URLFetcher* source, int64 progress, int64 total) { |
528 // Increasing between 0 and total. | 500 // Increasing between 0 and total. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 data_ = data; | 630 data_ = data; |
659 fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( | 631 fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( |
660 io_message_loop_proxy().get(), request_context())); | 632 io_message_loop_proxy().get(), request_context())); |
661 fetcher_->Start(); | 633 fetcher_->Start(); |
662 } else { | 634 } else { |
663 EXPECT_EQ(data, data_); | 635 EXPECT_EQ(data, data_); |
664 CleanupAfterFetchComplete(); | 636 CleanupAfterFetchComplete(); |
665 } | 637 } |
666 } | 638 } |
667 | 639 |
| 640 void URLFetcherFileTest::CreateFetcherForFile(const GURL& url, |
| 641 const base::FilePath& file_path) { |
| 642 fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); |
| 643 fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( |
| 644 io_message_loop_proxy().get(), request_context())); |
| 645 |
| 646 // Use the IO message loop to do the file operations in this test. |
| 647 fetcher_->SaveResponseToFileAtPath(file_path, io_message_loop_proxy()); |
| 648 fetcher_->Start(); |
| 649 } |
| 650 |
| 651 void URLFetcherFileTest::CreateFetcherForTempFile(const GURL& url) { |
| 652 fetcher_ = new URLFetcherImpl(url, URLFetcher::GET, this); |
| 653 fetcher_->SetRequestContext(new ThrottlingTestURLRequestContextGetter( |
| 654 io_message_loop_proxy().get(), request_context())); |
| 655 |
| 656 // Use the IO message loop to do the file operations in this test. |
| 657 fetcher_->SaveResponseToTemporaryFile(io_message_loop_proxy()); |
| 658 fetcher_->Start(); |
| 659 } |
| 660 |
| 661 void URLFetcherFileTest::OnURLFetchComplete(const URLFetcher* source) { |
| 662 if (expected_file_error_ == OK) { |
| 663 EXPECT_TRUE(source->GetStatus().is_success()); |
| 664 EXPECT_EQ(OK, source->GetStatus().error()); |
| 665 EXPECT_EQ(200, source->GetResponseCode()); |
| 666 |
| 667 EXPECT_TRUE(source->GetResponseAsFilePath( |
| 668 take_ownership_of_file_, &file_path_)); |
| 669 |
| 670 EXPECT_TRUE(base::ContentsEqual(expected_file_, file_path_)); |
| 671 } else { |
| 672 EXPECT_FALSE(source->GetStatus().is_success()); |
| 673 EXPECT_EQ(expected_file_error_, source->GetStatus().error()); |
| 674 } |
| 675 CleanupAfterFetchComplete(); |
| 676 } |
| 677 |
668 // Create the fetcher on the main thread. Since network IO will happen on the | 678 // Create the fetcher on the main thread. Since network IO will happen on the |
669 // main thread, this will test URLFetcher's ability to do everything on one | 679 // main thread, this will test URLFetcher's ability to do everything on one |
670 // thread. | 680 // thread. |
671 TEST_F(URLFetcherTest, SameThreadTest) { | 681 TEST_F(URLFetcherTest, SameThreadTest) { |
672 WaitingURLFetcherDelegate delegate; | 682 WaitingURLFetcherDelegate delegate; |
673 delegate.CreateFetcherWithContext(test_server_->GetURL(kDefaultResponsePath), | 683 delegate.CreateFetcherWithContext(test_server_->GetURL(kDefaultResponsePath), |
674 URLFetcher::GET, request_context()); | 684 URLFetcher::GET, request_context()); |
675 delegate.StartFetcherAndWait(); | 685 delegate.StartFetcherAndWait(); |
676 | 686 |
677 EXPECT_TRUE(delegate.fetcher()->GetStatus().is_success()); | 687 EXPECT_TRUE(delegate.fetcher()->GetStatus().is_success()); |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 | 1195 |
1186 TEST_F(URLFetcherMultipleAttemptTest, SameData) { | 1196 TEST_F(URLFetcherMultipleAttemptTest, SameData) { |
1187 // Create the fetcher on the main thread. Since IO will happen on the main | 1197 // Create the fetcher on the main thread. Since IO will happen on the main |
1188 // thread, this will test URLFetcher's ability to do everything on one | 1198 // thread, this will test URLFetcher's ability to do everything on one |
1189 // thread. | 1199 // thread. |
1190 CreateFetcher(test_server_->GetURL(kDefaultResponsePath)); | 1200 CreateFetcher(test_server_->GetURL(kDefaultResponsePath)); |
1191 | 1201 |
1192 base::MessageLoop::current()->Run(); | 1202 base::MessageLoop::current()->Run(); |
1193 } | 1203 } |
1194 | 1204 |
1195 // Get a small file. | 1205 TEST_F(URLFetcherFileTest, SmallGet) { |
1196 TEST_F(URLFetcherTest, FileTestSmallGet) { | |
1197 const char kFileToFetch[] = "simple.html"; | |
1198 | |
1199 base::ScopedTempDir temp_dir; | 1206 base::ScopedTempDir temp_dir; |
1200 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1207 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1201 base::FilePath out_path = temp_dir.path().AppendASCII(kFileToFetch); | 1208 |
1202 SaveFileTest(kFileToFetch, false, out_path, false); | 1209 // Get a small file. |
| 1210 static const char kFileToFetch[] = "simple.html"; |
| 1211 expected_file_ = test_server_->GetDocumentRoot().AppendASCII(kFileToFetch); |
| 1212 CreateFetcherForFile( |
| 1213 test_server_->GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), |
| 1214 temp_dir.path().AppendASCII(kFileToFetch)); |
| 1215 |
| 1216 base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). |
| 1217 |
| 1218 ASSERT_FALSE(base::PathExists(file_path_)) |
| 1219 << file_path_.value() << " not removed."; |
1203 } | 1220 } |
1204 | 1221 |
1205 // Get a file large enough to require more than one read into URLFetcher::Core's | 1222 TEST_F(URLFetcherFileTest, LargeGet) { |
1206 // IOBuffer. | |
1207 TEST_F(URLFetcherTest, FileTestLargeGet) { | |
1208 const char kFileToFetch[] = "animate1.gif"; | |
1209 | |
1210 base::ScopedTempDir temp_dir; | 1223 base::ScopedTempDir temp_dir; |
1211 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1224 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1212 base::FilePath out_path = temp_dir.path().AppendASCII(kFileToFetch); | 1225 |
1213 SaveFileTest(kFileToFetch, false, out_path, false); | 1226 // Get a file large enough to require more than one read into |
| 1227 // URLFetcher::Core's IOBuffer. |
| 1228 static const char kFileToFetch[] = "animate1.gif"; |
| 1229 expected_file_ = test_server_->GetDocumentRoot().AppendASCII(kFileToFetch); |
| 1230 CreateFetcherForFile( |
| 1231 test_server_->GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), |
| 1232 temp_dir.path().AppendASCII(kFileToFetch)); |
| 1233 |
| 1234 base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). |
1214 } | 1235 } |
1215 | 1236 |
1216 // If the caller takes the ownership of the output file, the file should persist | 1237 TEST_F(URLFetcherFileTest, SavedOutputFileOwnerhisp) { |
1217 // even after URLFetcher is gone. | 1238 // If the caller takes the ownership of the output file, the file should |
1218 TEST_F(URLFetcherTest, FileTestTakeOwnership) { | 1239 // persist even after URLFetcher is gone. If not, the file must be deleted. |
1219 const char kFileToFetch[] = "simple.html"; | 1240 const bool kTake[] = {false, true}; |
| 1241 for (size_t i = 0; i < arraysize(kTake); ++i) { |
| 1242 take_ownership_of_file_ = kTake[i]; |
| 1243 base::ScopedTempDir temp_dir; |
| 1244 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1220 | 1245 |
1221 base::ScopedTempDir temp_dir; | 1246 // Get a small file. |
1222 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1247 static const char kFileToFetch[] = "simple.html"; |
1223 base::FilePath out_path = temp_dir.path().AppendASCII(kFileToFetch); | 1248 expected_file_ = test_server_->GetDocumentRoot().AppendASCII(kFileToFetch); |
1224 SaveFileTest(kFileToFetch, false, out_path, true); | 1249 CreateFetcherForFile( |
| 1250 test_server_->GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), |
| 1251 temp_dir.path().AppendASCII(kFileToFetch)); |
| 1252 |
| 1253 base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). |
| 1254 |
| 1255 base::MessageLoop::current()->RunUntilIdle(); |
| 1256 ASSERT_EQ(kTake[i], base::PathExists(file_path_)) << |
| 1257 "FilePath: " << file_path_.value(); |
| 1258 } |
1225 } | 1259 } |
1226 | 1260 |
1227 // Test that an existing file can be overwritten be a fetcher. | 1261 TEST_F(URLFetcherFileTest, OverwriteExistingFile) { |
1228 TEST_F(URLFetcherTest, FileTestOverwriteExisting) { | |
1229 base::ScopedTempDir temp_dir; | 1262 base::ScopedTempDir temp_dir; |
1230 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1263 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1231 | 1264 |
1232 // Create a file before trying to fetch. | 1265 // Create a file before trying to fetch. |
1233 const char kFileToFetch[] = "simple.html"; | 1266 static const char kFileToFetch[] = "simple.html"; |
1234 std::string data(10000, '?'); // Meant to be larger than simple.html. | 1267 std::string data(10000, '?'); // Meant to be larger than simple.html. |
1235 base::FilePath out_path = temp_dir.path().AppendASCII(kFileToFetch); | 1268 file_path_ = temp_dir.path().AppendASCII(kFileToFetch); |
1236 ASSERT_EQ(static_cast<int>(data.size()), | 1269 ASSERT_EQ(static_cast<int>(data.size()), |
1237 base::WriteFile(out_path, data.data(), data.size())); | 1270 base::WriteFile(file_path_, data.data(), data.size())); |
1238 ASSERT_TRUE(base::PathExists(out_path)); | 1271 ASSERT_TRUE(base::PathExists(file_path_)); |
| 1272 expected_file_ = test_server_->GetDocumentRoot().AppendASCII(kFileToFetch); |
| 1273 ASSERT_FALSE(base::ContentsEqual(file_path_, expected_file_)); |
1239 | 1274 |
1240 SaveFileTest(kFileToFetch, false, out_path, true); | 1275 // Get a small file. |
| 1276 CreateFetcherForFile( |
| 1277 test_server_->GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), |
| 1278 file_path_); |
| 1279 |
| 1280 base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). |
1241 } | 1281 } |
1242 | 1282 |
1243 // Test trying to overwrite a directory with a file when using a fetcher fails. | 1283 TEST_F(URLFetcherFileTest, TryToOverwriteDirectory) { |
1244 TEST_F(URLFetcherTest, FileTestTryToOverwriteDirectory) { | |
1245 base::ScopedTempDir temp_dir; | 1284 base::ScopedTempDir temp_dir; |
1246 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 1285 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
1247 | 1286 |
1248 // Create a directory before trying to fetch. | 1287 // Create a directory before trying to fetch. |
1249 static const char kFileToFetch[] = "simple.html"; | 1288 static const char kFileToFetch[] = "simple.html"; |
1250 base::FilePath out_path = temp_dir.path().AppendASCII(kFileToFetch); | 1289 file_path_ = temp_dir.path().AppendASCII(kFileToFetch); |
1251 ASSERT_TRUE(base::CreateDirectory(out_path)); | 1290 ASSERT_TRUE(base::CreateDirectory(file_path_)); |
1252 ASSERT_TRUE(base::PathExists(out_path)); | 1291 ASSERT_TRUE(base::PathExists(file_path_)); |
1253 | 1292 |
1254 WaitingURLFetcherDelegate delegate; | 1293 // Get a small file. |
1255 delegate.CreateFetcherWithContext( | 1294 expected_file_error_ = ERR_ACCESS_DENIED; |
| 1295 expected_file_ = test_server_->GetDocumentRoot().AppendASCII(kFileToFetch); |
| 1296 CreateFetcherForFile( |
1256 test_server_->GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), | 1297 test_server_->GetURL(std::string(kTestServerFilePrefix) + kFileToFetch), |
1257 URLFetcher::GET, request_context()); | 1298 file_path_); |
1258 delegate.fetcher()->SaveResponseToFileAtPath( | |
1259 out_path, | |
1260 scoped_refptr<base::MessageLoopProxy>(base::MessageLoopProxy::current())); | |
1261 delegate.StartFetcherAndWait(); | |
1262 | 1299 |
1263 EXPECT_FALSE(delegate.fetcher()->GetStatus().is_success()); | 1300 base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). |
1264 EXPECT_EQ(ERR_ACCESS_DENIED, delegate.fetcher()->GetStatus().error()); | 1301 |
| 1302 base::MessageLoop::current()->RunUntilIdle(); |
1265 } | 1303 } |
1266 | 1304 |
1267 // Get a small file and save it to a temp file. | 1305 TEST_F(URLFetcherFileTest, SmallGetToTempFile) { |
1268 TEST_F(URLFetcherTest, TempFileTestSmallGet) { | 1306 // Get a small file. |
1269 SaveFileTest("simple.html", true, base::FilePath(), false); | 1307 static const char kFileToFetch[] = "simple.html"; |
| 1308 expected_file_ = test_server_->GetDocumentRoot().AppendASCII(kFileToFetch); |
| 1309 CreateFetcherForTempFile( |
| 1310 test_server_->GetURL(std::string(kTestServerFilePrefix) + kFileToFetch)); |
| 1311 |
| 1312 base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). |
| 1313 |
| 1314 ASSERT_FALSE(base::PathExists(file_path_)) |
| 1315 << file_path_.value() << " not removed."; |
1270 } | 1316 } |
1271 | 1317 |
1272 // Get a file large enough to require more than one read into URLFetcher::Core's | 1318 TEST_F(URLFetcherFileTest, LargeGetToTempFile) { |
1273 // IOBuffer and save it to a temp file. | 1319 // Get a file large enough to require more than one read into |
1274 TEST_F(URLFetcherTest, TempFileTestLargeGet) { | 1320 // URLFetcher::Core's IOBuffer. |
1275 SaveFileTest("animate1.gif", true, base::FilePath(), false); | 1321 static const char kFileToFetch[] = "animate1.gif"; |
| 1322 expected_file_ = test_server_->GetDocumentRoot().AppendASCII(kFileToFetch); |
| 1323 CreateFetcherForTempFile( |
| 1324 test_server_->GetURL(std::string(kTestServerFilePrefix) + kFileToFetch)); |
| 1325 |
| 1326 base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). |
1276 } | 1327 } |
1277 | 1328 |
1278 // If the caller takes the ownership of the temp file, check that the file | 1329 TEST_F(URLFetcherFileTest, SavedOutputTempFileOwnerhisp) { |
1279 // persists even after URLFetcher is gone. | 1330 // If the caller takes the ownership of the temp file, the file should persist |
1280 TEST_F(URLFetcherTest, TempFileTestTakeOwnership) { | 1331 // even after URLFetcher is gone. If not, the file must be deleted. |
1281 SaveFileTest("simple.html", true, base::FilePath(), true); | 1332 const bool kTake[] = {false, true}; |
| 1333 for (size_t i = 0; i < arraysize(kTake); ++i) { |
| 1334 take_ownership_of_file_ = kTake[i]; |
| 1335 |
| 1336 // Get a small file. |
| 1337 static const char kFileToFetch[] = "simple.html"; |
| 1338 expected_file_ = test_server_->GetDocumentRoot().AppendASCII(kFileToFetch); |
| 1339 CreateFetcherForTempFile(test_server_->GetURL( |
| 1340 std::string(kTestServerFilePrefix) + kFileToFetch)); |
| 1341 |
| 1342 base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). |
| 1343 |
| 1344 base::MessageLoop::current()->RunUntilIdle(); |
| 1345 ASSERT_EQ(kTake[i], base::PathExists(file_path_)) << |
| 1346 "FilePath: " << file_path_.value(); |
| 1347 } |
1282 } | 1348 } |
1283 | 1349 |
1284 } // namespace | 1350 } // namespace |
1285 | 1351 |
1286 } // namespace net | 1352 } // namespace net |
OLD | NEW |