| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/download/internal/test/test_download_driver.h" | 5 #include "components/download/internal/test/test_download_driver.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "components/download/public/download_params.h" | 8 #include "components/download/public/download_params.h" |
| 9 #include "net/http/http_response_headers.h" | 9 #include "net/http/http_response_headers.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 void TestDownloadDriver::Initialize(DownloadDriver::Client* client) { | 47 void TestDownloadDriver::Initialize(DownloadDriver::Client* client) { |
| 48 DCHECK(!client_); | 48 DCHECK(!client_); |
| 49 client_ = client; | 49 client_ = client; |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool TestDownloadDriver::IsReady() const { | 52 bool TestDownloadDriver::IsReady() const { |
| 53 return is_ready_; | 53 return is_ready_; |
| 54 } | 54 } |
| 55 | 55 |
| 56 void TestDownloadDriver::Start(const DownloadParams& params) { | 56 void TestDownloadDriver::Start( |
| 57 const DownloadParams& params, |
| 58 const net::NetworkTrafficAnnotationTag& traffic_annotation) { |
| 57 DriverEntry entry; | 59 DriverEntry entry; |
| 58 entry.guid = params.guid; | 60 entry.guid = params.guid; |
| 59 entry.state = DriverEntry::State::IN_PROGRESS; | 61 entry.state = DriverEntry::State::IN_PROGRESS; |
| 60 entry.paused = false; | 62 entry.paused = false; |
| 61 entry.bytes_downloaded = 0; | 63 entry.bytes_downloaded = 0; |
| 62 entry.expected_total_size = 0; | 64 entry.expected_total_size = 0; |
| 63 entry.response_headers = | 65 entry.response_headers = |
| 64 base::MakeRefCounted<net::HttpResponseHeaders>("HTTP/1.1 200"); | 66 base::MakeRefCounted<net::HttpResponseHeaders>("HTTP/1.1 200"); |
| 65 entries_[params.guid] = entry; | 67 entries_[params.guid] = entry; |
| 66 | 68 |
| 67 if (client_) | 69 if (client_) |
| 68 client_->OnDownloadCreated(entry); | 70 client_->OnDownloadCreated(entry); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void TestDownloadDriver::Cancel(const std::string& guid) {} | 73 void TestDownloadDriver::Cancel(const std::string& guid) {} |
| 72 | 74 |
| 73 void TestDownloadDriver::Pause(const std::string& guid) {} | 75 void TestDownloadDriver::Pause(const std::string& guid) {} |
| 74 | 76 |
| 75 void TestDownloadDriver::Resume(const std::string& guid) {} | 77 void TestDownloadDriver::Resume(const std::string& guid) {} |
| 76 | 78 |
| 77 base::Optional<DriverEntry> TestDownloadDriver::Find(const std::string& guid) { | 79 base::Optional<DriverEntry> TestDownloadDriver::Find(const std::string& guid) { |
| 78 auto it = entries_.find(guid); | 80 auto it = entries_.find(guid); |
| 79 if (it == entries_.end()) | 81 if (it == entries_.end()) |
| 80 return base::nullopt; | 82 return base::nullopt; |
| 81 return it->second; | 83 return it->second; |
| 82 } | 84 } |
| 83 | 85 |
| 84 } // namespace downloads | 86 } // namespace downloads |
| OLD | NEW |