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