| 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 "content/browser/download/mock_download_file.h" | 5 #include "content/browser/download/mock_download_file.h" |
| 6 | 6 |
| 7 #include "content/browser/download/download_create_info.h" | 7 #include "content/browser/download/download_create_info.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 using content::DownloadManager; | 10 using content::DownloadManager; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 request_handle_(request_handle), | 39 request_handle_(request_handle), |
| 40 download_manager_(download_manager), | 40 download_manager_(download_manager), |
| 41 recorder_(recorder), | 41 recorder_(recorder), |
| 42 rename_count_(0), | 42 rename_count_(0), |
| 43 in_progress_(true) { | 43 in_progress_(true) { |
| 44 } | 44 } |
| 45 | 45 |
| 46 MockDownloadFile::~MockDownloadFile() { | 46 MockDownloadFile::~MockDownloadFile() { |
| 47 } | 47 } |
| 48 | 48 |
| 49 net::Error MockDownloadFile::Initialize(bool calculate_hash) { | 49 net::Error MockDownloadFile::Initialize() { |
| 50 in_progress_ = true; | 50 in_progress_ = true; |
| 51 if (recorder_) | 51 if (recorder_) |
| 52 recorder_->Record(StatisticsRecorder::STAT_INITIALIZE); | 52 recorder_->Record(StatisticsRecorder::STAT_INITIALIZE); |
| 53 return net::OK; | 53 return net::OK; |
| 54 } | 54 } |
| 55 | 55 |
| 56 net::Error MockDownloadFile::AppendDataToFile( | 56 net::Error MockDownloadFile::AppendDataToFile( |
| 57 const char* data, size_t data_len) { | 57 const char* data, size_t data_len) { |
| 58 data_.append(data, data_len); | 58 data_.append(data, data_len); |
| 59 if (recorder_) { | 59 if (recorder_) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 | 103 |
| 104 int64 MockDownloadFile::BytesSoFar() const { | 104 int64 MockDownloadFile::BytesSoFar() const { |
| 105 return data_.length(); | 105 return data_.length(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 int64 MockDownloadFile::CurrentSpeed() const { | 108 int64 MockDownloadFile::CurrentSpeed() const { |
| 109 return 0; | 109 return 0; |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool MockDownloadFile::GetSha256Hash(std::string* hash) { | 112 bool MockDownloadFile::GetHash(std::string* hash) { |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 | 115 |
| 116 std::string MockDownloadFile::GetHashState() { |
| 117 return ""; |
| 118 } |
| 119 |
| 116 // DownloadFileInterface implementation. | 120 // DownloadFileInterface implementation. |
| 117 void MockDownloadFile::CancelDownloadRequest() { | 121 void MockDownloadFile::CancelDownloadRequest() { |
| 118 } | 122 } |
| 119 | 123 |
| 120 int MockDownloadFile::Id() const { | 124 int MockDownloadFile::Id() const { |
| 121 return id_.local(); | 125 return id_.local(); |
| 122 } | 126 } |
| 123 | 127 |
| 124 DownloadManager* MockDownloadFile::GetDownloadManager() { | 128 DownloadManager* MockDownloadFile::GetDownloadManager() { |
| 125 return download_manager_; | 129 return download_manager_; |
| 126 } | 130 } |
| 127 | 131 |
| 128 const DownloadId& MockDownloadFile::GlobalId() const { | 132 const DownloadId& MockDownloadFile::GlobalId() const { |
| 129 return id_; | 133 return id_; |
| 130 } | 134 } |
| 131 | 135 |
| 132 std::string MockDownloadFile::DebugString() const { | 136 std::string MockDownloadFile::DebugString() const { |
| 133 return ""; | 137 return ""; |
| 134 } | 138 } |
| 135 | 139 |
| 136 void MockDownloadFile::SetExpectedPath(size_t index, const FilePath& path) { | 140 void MockDownloadFile::SetExpectedPath(size_t index, const FilePath& path) { |
| 137 if (expected_rename_path_list_.size() < index + 1) | 141 if (expected_rename_path_list_.size() < index + 1) |
| 138 expected_rename_path_list_.resize(index + 1); | 142 expected_rename_path_list_.resize(index + 1); |
| 139 expected_rename_path_list_[index] = path; | 143 expected_rename_path_list_[index] = path; |
| 140 } | 144 } |
| OLD | NEW |