Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 10695110: Avoid disk accesses on the wrong thread in URLRequestFileJob (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 556
557 EXPECT_TRUE(!r.is_pending()); 557 EXPECT_TRUE(!r.is_pending());
558 EXPECT_EQ(1, d.response_started_count()); 558 EXPECT_EQ(1, d.response_started_count());
559 EXPECT_FALSE(d.received_data_before_response()); 559 EXPECT_FALSE(d.received_data_before_response());
560 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size)); 560 EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size));
561 EXPECT_EQ("", r.GetSocketAddress().host()); 561 EXPECT_EQ("", r.GetSocketAddress().host());
562 EXPECT_EQ(0, r.GetSocketAddress().port()); 562 EXPECT_EQ(0, r.GetSocketAddress().port());
563 } 563 }
564 } 564 }
565 565
566 TEST_F(URLRequestTest, FileTest_Cancel) {
wtc 2012/11/14 21:05:01 FileTest_Cancel => FileTestCancel
567 FilePath app_path;
568 PathService::Get(base::FILE_EXE, &app_path);
569 GURL app_url = FilePathToFileURL(app_path);
570
571 TestDelegate d;
572 {
573 URLRequest r(app_url, &d, &default_context_);
574
575 r.Start();
576 EXPECT_TRUE(r.is_pending());
577 r.Cancel();
578 }
579 // Async cancelation should be safe even when URLRequest has been already
580 // destroyed.
581 MessageLoop::current()->RunUntilIdle();
582 }
583
566 TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { 584 TEST_F(URLRequestTest, FileTestFullSpecifiedRange) {
567 const size_t buffer_size = 4000; 585 const size_t buffer_size = 4000;
568 scoped_array<char> buffer(new char[buffer_size]); 586 scoped_array<char> buffer(new char[buffer_size]);
569 FillBuffer(buffer.get(), buffer_size); 587 FillBuffer(buffer.get(), buffer_size);
570 588
571 FilePath temp_path; 589 FilePath temp_path;
572 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path)); 590 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_path));
573 GURL temp_url = FilePathToFileURL(temp_path); 591 GURL temp_url = FilePathToFileURL(temp_path);
574 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size)); 592 EXPECT_TRUE(file_util::WriteFile(temp_path, buffer.get(), buffer_size));
575 593
(...skipping 4486 matching lines...) Expand 10 before | Expand all | Expand 10 after
5062 5080
5063 EXPECT_FALSE(r.is_pending()); 5081 EXPECT_FALSE(r.is_pending());
5064 EXPECT_EQ(1, d->response_started_count()); 5082 EXPECT_EQ(1, d->response_started_count());
5065 EXPECT_FALSE(d->received_data_before_response()); 5083 EXPECT_FALSE(d->received_data_before_response());
5066 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 5084 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
5067 } 5085 }
5068 } 5086 }
5069 #endif // !defined(DISABLE_FTP_SUPPORT) 5087 #endif // !defined(DISABLE_FTP_SUPPORT)
5070 5088
5071 } // namespace net 5089 } // namespace net
OLDNEW
« net/url_request/url_request_file_job.cc ('K') | « net/url_request/url_request_file_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698