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 "content/public/test/mock_download_manager.h" | 5 #include "content/public/test/mock_download_manager.h" |
6 | 6 |
7 #include "content/browser/byte_stream.h" | 7 #include "content/browser/byte_stream.h" |
8 #include "content/browser/download/download_create_info.h" | 8 #include "content/browser/download/download_create_info.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( | 12 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( |
13 uint32 id, | 13 uint32 id, |
14 const base::FilePath& current_path, | 14 const base::FilePath& current_path, |
15 const base::FilePath& target_path, | 15 const base::FilePath& target_path, |
16 const std::vector<GURL>& url_chain, | 16 const std::vector<GURL>& url_chain, |
17 const GURL& referrer_url, | 17 const GURL& referrer_url, |
| 18 const std::string& mime_type, |
| 19 const std::string& original_mime_type, |
18 const base::Time& start_time, | 20 const base::Time& start_time, |
19 const base::Time& end_time, | 21 const base::Time& end_time, |
20 const std::string& etag, | 22 const std::string& etag, |
21 const std::string& last_modified, | 23 const std::string& last_modified, |
22 int64 received_bytes, | 24 int64 received_bytes, |
23 int64 total_bytes, | 25 int64 total_bytes, |
24 DownloadItem::DownloadState state, | 26 DownloadItem::DownloadState state, |
25 DownloadDangerType danger_type, | 27 DownloadDangerType danger_type, |
26 DownloadInterruptReason interrupt_reason, | 28 DownloadInterruptReason interrupt_reason, |
27 bool opened) | 29 bool opened) |
28 : id(id), | 30 : id(id), |
29 current_path(current_path), | 31 current_path(current_path), |
30 target_path(target_path), | 32 target_path(target_path), |
31 url_chain(url_chain), | 33 url_chain(url_chain), |
32 referrer_url(referrer_url), | 34 referrer_url(referrer_url), |
| 35 mime_type(mime_type), |
| 36 original_mime_type(original_mime_type), |
33 start_time(start_time), | 37 start_time(start_time), |
34 end_time(end_time), | 38 end_time(end_time), |
35 received_bytes(received_bytes), | 39 received_bytes(received_bytes), |
36 total_bytes(total_bytes), | 40 total_bytes(total_bytes), |
37 state(state), | 41 state(state), |
38 danger_type(danger_type), | 42 danger_type(danger_type), |
39 interrupt_reason(interrupt_reason), | 43 interrupt_reason(interrupt_reason), |
40 opened(opened) {} | 44 opened(opened) {} |
41 | 45 |
42 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( | 46 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( |
(...skipping 16 matching lines...) Loading... |
59 | 63 |
60 MockDownloadManager::CreateDownloadItemAdapter::~CreateDownloadItemAdapter() {} | 64 MockDownloadManager::CreateDownloadItemAdapter::~CreateDownloadItemAdapter() {} |
61 | 65 |
62 bool MockDownloadManager::CreateDownloadItemAdapter::operator==( | 66 bool MockDownloadManager::CreateDownloadItemAdapter::operator==( |
63 const CreateDownloadItemAdapter& rhs) { | 67 const CreateDownloadItemAdapter& rhs) { |
64 return (id == rhs.id && | 68 return (id == rhs.id && |
65 current_path == rhs.current_path && | 69 current_path == rhs.current_path && |
66 target_path == rhs.target_path && | 70 target_path == rhs.target_path && |
67 url_chain == rhs.url_chain && | 71 url_chain == rhs.url_chain && |
68 referrer_url == rhs.referrer_url && | 72 referrer_url == rhs.referrer_url && |
| 73 mime_type == rhs.mime_type && |
| 74 original_mime_type == rhs.original_mime_type && |
69 start_time == rhs.start_time && | 75 start_time == rhs.start_time && |
70 end_time == rhs.end_time && | 76 end_time == rhs.end_time && |
71 etag == rhs.etag && | 77 etag == rhs.etag && |
72 last_modified == rhs.last_modified && | 78 last_modified == rhs.last_modified && |
73 received_bytes == rhs.received_bytes && | 79 received_bytes == rhs.received_bytes && |
74 total_bytes == rhs.total_bytes && | 80 total_bytes == rhs.total_bytes && |
75 state == rhs.state && | 81 state == rhs.state && |
76 danger_type == rhs.danger_type && | 82 danger_type == rhs.danger_type && |
77 interrupt_reason == rhs.interrupt_reason && | 83 interrupt_reason == rhs.interrupt_reason && |
78 opened == rhs.opened); | 84 opened == rhs.opened); |
79 } | 85 } |
80 | 86 |
81 MockDownloadManager::MockDownloadManager() {} | 87 MockDownloadManager::MockDownloadManager() {} |
82 | 88 |
83 MockDownloadManager::~MockDownloadManager() {} | 89 MockDownloadManager::~MockDownloadManager() {} |
84 | 90 |
85 void MockDownloadManager::StartDownload( | 91 void MockDownloadManager::StartDownload( |
86 scoped_ptr<DownloadCreateInfo> info, | 92 scoped_ptr<DownloadCreateInfo> info, |
87 scoped_ptr<ByteStreamReader> stream, | 93 scoped_ptr<ByteStreamReader> stream, |
88 const DownloadUrlParameters::OnStartedCallback& callback) { | 94 const DownloadUrlParameters::OnStartedCallback& callback) { |
89 MockStartDownload(info.get(), stream.get()); | 95 MockStartDownload(info.get(), stream.get()); |
90 } | 96 } |
91 | 97 |
92 DownloadItem* MockDownloadManager::CreateDownloadItem( | 98 DownloadItem* MockDownloadManager::CreateDownloadItem( |
93 uint32 id, | 99 uint32 id, |
94 const base::FilePath& current_path, | 100 const base::FilePath& current_path, |
95 const base::FilePath& target_path, | 101 const base::FilePath& target_path, |
96 const std::vector<GURL>& url_chain, | 102 const std::vector<GURL>& url_chain, |
97 const GURL& referrer_url, | 103 const GURL& referrer_url, |
| 104 const std::string& mime_type, |
| 105 const std::string& original_mime_type, |
98 const base::Time& start_time, | 106 const base::Time& start_time, |
99 const base::Time& end_time, | 107 const base::Time& end_time, |
100 const std::string& etag, | 108 const std::string& etag, |
101 const std::string& last_modified, | 109 const std::string& last_modified, |
102 int64 received_bytes, | 110 int64 received_bytes, |
103 int64 total_bytes, | 111 int64 total_bytes, |
104 DownloadItem::DownloadState state, | 112 DownloadItem::DownloadState state, |
105 DownloadDangerType danger_type, | 113 DownloadDangerType danger_type, |
106 DownloadInterruptReason interrupt_reason, | 114 DownloadInterruptReason interrupt_reason, |
107 bool opened) { | 115 bool opened) { |
108 CreateDownloadItemAdapter adapter( | 116 CreateDownloadItemAdapter adapter( |
109 id, current_path, target_path, url_chain, referrer_url, start_time, | 117 id, current_path, target_path, url_chain, referrer_url, mime_type, |
110 end_time, etag, last_modified, received_bytes, total_bytes, state, | 118 original_mime_type, start_time, end_time, etag, last_modified, |
111 danger_type, interrupt_reason, opened); | 119 received_bytes, total_bytes, state, danger_type, interrupt_reason, |
| 120 opened); |
112 return MockCreateDownloadItem(adapter); | 121 return MockCreateDownloadItem(adapter); |
113 } | 122 } |
114 | 123 |
115 } // namespace content | 124 } // namespace content |
OLD | NEW |