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 "base/files/file.h" | 5 #include "base/files/file.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/test/test_file_util.h" | 10 #include "base/test/test_file_util.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 default_downloads_directory, | 81 default_downloads_directory, |
82 url, | 82 url, |
83 referrer_url, | 83 referrer_url, |
84 calculate_hash, | 84 calculate_hash, |
85 stream.Pass(), | 85 stream.Pass(), |
86 bound_net_log, | 86 bound_net_log, |
87 observer) {} | 87 observer) {} |
88 | 88 |
89 protected: | 89 protected: |
90 virtual base::TimeDelta GetRetryDelayForFailedRename( | 90 virtual base::TimeDelta GetRetryDelayForFailedRename( |
91 int attempt_count) OVERRIDE { | 91 int attempt_count) override { |
92 return base::TimeDelta::FromMilliseconds(0); | 92 return base::TimeDelta::FromMilliseconds(0); |
93 } | 93 } |
94 | 94 |
95 #if !defined(OS_WIN) | 95 #if !defined(OS_WIN) |
96 // On Posix, we don't encounter transient errors during renames, except | 96 // On Posix, we don't encounter transient errors during renames, except |
97 // possibly EAGAIN, which is difficult to replicate reliably. So we resort to | 97 // possibly EAGAIN, which is difficult to replicate reliably. So we resort to |
98 // simulating a transient error using ACCESS_DENIED instead. | 98 // simulating a transient error using ACCESS_DENIED instead. |
99 virtual bool ShouldRetryFailedRename( | 99 virtual bool ShouldRetryFailedRename( |
100 DownloadInterruptReason reason) OVERRIDE { | 100 DownloadInterruptReason reason) override { |
101 return reason == DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED; | 101 return reason == DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED; |
102 } | 102 } |
103 #endif | 103 #endif |
104 }; | 104 }; |
105 | 105 |
106 } // namespace | 106 } // namespace |
107 | 107 |
108 class DownloadFileTest : public testing::Test { | 108 class DownloadFileTest : public testing::Test { |
109 public: | 109 public: |
110 | 110 |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 785 |
786 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), | 786 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), |
787 bytes_); | 787 bytes_); |
788 EXPECT_EQ(download_file_->GetHashState(), hash_state_); | 788 EXPECT_EQ(download_file_->GetHashState(), hash_state_); |
789 | 789 |
790 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); | 790 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); |
791 DestroyDownloadFile(0); | 791 DestroyDownloadFile(0); |
792 } | 792 } |
793 | 793 |
794 } // namespace content | 794 } // namespace content |
OLD | NEW |