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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
9 #include "content/browser/download/download_create_info.h" | 9 #include "content/browser/download/download_create_info.h" |
10 #include "content/browser/download/download_file_impl.h" | 10 #include "content/browser/download/download_file_impl.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 virtual void CreateDownloadFile(scoped_ptr<DownloadFile>* file, | 63 virtual void CreateDownloadFile(scoped_ptr<DownloadFile>* file, |
64 int offset, | 64 int offset, |
65 bool calculate_hash) { | 65 bool calculate_hash) { |
66 DownloadCreateInfo info; | 66 DownloadCreateInfo info; |
67 info.download_id = DownloadId(kValidIdDomain, kDummyDownloadId + offset); | 67 info.download_id = DownloadId(kValidIdDomain, kDummyDownloadId + offset); |
68 // info.request_handle default constructed to null. | 68 // info.request_handle default constructed to null. |
69 info.save_info.file_stream = file_stream_; | 69 info.save_info.file_stream = file_stream_; |
70 file->reset( | 70 file->reset( |
71 new DownloadFileImpl(&info, new DownloadRequestHandle(), | 71 new DownloadFileImpl(&info, new DownloadRequestHandle(), |
72 download_manager_, calculate_hash)); | 72 download_manager_, calculate_hash, |
| 73 net::BoundNetLog())); |
73 } | 74 } |
74 | 75 |
75 virtual void DestroyDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { | 76 virtual void DestroyDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { |
76 EXPECT_EQ(kDummyDownloadId + offset, (*file)->Id()); | 77 EXPECT_EQ(kDummyDownloadId + offset, (*file)->Id()); |
77 EXPECT_EQ(download_manager_, (*file)->GetDownloadManager()); | 78 EXPECT_EQ(download_manager_, (*file)->GetDownloadManager()); |
78 EXPECT_FALSE((*file)->InProgress()); | 79 EXPECT_FALSE((*file)->InProgress()); |
79 EXPECT_EQ(static_cast<int64>(expected_data_.size()), | 80 EXPECT_EQ(static_cast<int64>(expected_data_.size()), |
80 (*file)->BytesSoFar()); | 81 (*file)->BytesSoFar()); |
81 | 82 |
82 // Make sure the data has been properly written to disk. | 83 // Make sure the data has been properly written to disk. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // Check the files. | 189 // Check the files. |
189 EXPECT_FALSE(file_util::PathExists(path_3)); | 190 EXPECT_FALSE(file_util::PathExists(path_3)); |
190 EXPECT_TRUE(file_util::PathExists(path_4)); | 191 EXPECT_TRUE(file_util::PathExists(path_4)); |
191 | 192 |
192 // Check the hash. | 193 // Check the hash. |
193 EXPECT_TRUE(download_file_->GetHash(&hash)); | 194 EXPECT_TRUE(download_file_->GetHash(&hash)); |
194 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); | 195 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); |
195 | 196 |
196 DestroyDownloadFile(&download_file_, 0); | 197 DestroyDownloadFile(&download_file_, 0); |
197 } | 198 } |
OLD | NEW |