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 const std::string& guid, | 13 const std::string& guid, |
14 uint32_t id, | 14 uint32_t id, |
15 const base::FilePath& current_path, | 15 const base::FilePath& current_path, |
16 const base::FilePath& target_path, | 16 const base::FilePath& target_path, |
17 const std::vector<GURL>& url_chain, | 17 const std::vector<GURL>& url_chain, |
18 const GURL& referrer_url, | 18 const GURL& referrer_url, |
| 19 const GURL& site_instance_url, |
19 const GURL& tab_url, | 20 const GURL& tab_url, |
20 const GURL& tab_referrer_url, | 21 const GURL& tab_referrer_url, |
21 const std::string& mime_type, | 22 const std::string& mime_type, |
22 const std::string& original_mime_type, | 23 const std::string& original_mime_type, |
23 const base::Time& start_time, | 24 const base::Time& start_time, |
24 const base::Time& end_time, | 25 const base::Time& end_time, |
25 const std::string& etag, | 26 const std::string& etag, |
26 const std::string& last_modified, | 27 const std::string& last_modified, |
27 int64_t received_bytes, | 28 int64_t received_bytes, |
28 int64_t total_bytes, | 29 int64_t total_bytes, |
29 const std::string& hash, | 30 const std::string& hash, |
30 DownloadItem::DownloadState state, | 31 DownloadItem::DownloadState state, |
31 DownloadDangerType danger_type, | 32 DownloadDangerType danger_type, |
32 DownloadInterruptReason interrupt_reason, | 33 DownloadInterruptReason interrupt_reason, |
33 bool opened) | 34 bool opened) |
34 : guid(guid), | 35 : guid(guid), |
35 id(id), | 36 id(id), |
36 current_path(current_path), | 37 current_path(current_path), |
37 target_path(target_path), | 38 target_path(target_path), |
38 url_chain(url_chain), | 39 url_chain(url_chain), |
39 referrer_url(referrer_url), | 40 referrer_url(referrer_url), |
| 41 site_instance_url(site_instance_url), |
40 tab_url(tab_url), | 42 tab_url(tab_url), |
41 tab_referrer_url(tab_referrer_url), | 43 tab_referrer_url(tab_referrer_url), |
42 mime_type(mime_type), | 44 mime_type(mime_type), |
43 original_mime_type(original_mime_type), | 45 original_mime_type(original_mime_type), |
44 start_time(start_time), | 46 start_time(start_time), |
45 end_time(end_time), | 47 end_time(end_time), |
46 received_bytes(received_bytes), | 48 received_bytes(received_bytes), |
47 total_bytes(total_bytes), | 49 total_bytes(total_bytes), |
48 hash(hash), | 50 hash(hash), |
49 state(state), | 51 state(state), |
50 danger_type(danger_type), | 52 danger_type(danger_type), |
51 interrupt_reason(interrupt_reason), | 53 interrupt_reason(interrupt_reason), |
52 opened(opened) {} | 54 opened(opened) {} |
53 | 55 |
54 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( | 56 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( |
55 const CreateDownloadItemAdapter& rhs) | 57 const CreateDownloadItemAdapter& rhs) |
56 : guid(rhs.guid), | 58 : guid(rhs.guid), |
57 id(rhs.id), | 59 id(rhs.id), |
58 current_path(rhs.current_path), | 60 current_path(rhs.current_path), |
59 target_path(rhs.target_path), | 61 target_path(rhs.target_path), |
60 url_chain(rhs.url_chain), | 62 url_chain(rhs.url_chain), |
61 referrer_url(rhs.referrer_url), | 63 referrer_url(rhs.referrer_url), |
| 64 site_instance_url(rhs.site_instance_url), |
62 tab_url(rhs.tab_url), | 65 tab_url(rhs.tab_url), |
63 tab_referrer_url(rhs.tab_referrer_url), | 66 tab_referrer_url(rhs.tab_referrer_url), |
64 start_time(rhs.start_time), | 67 start_time(rhs.start_time), |
65 end_time(rhs.end_time), | 68 end_time(rhs.end_time), |
66 etag(rhs.etag), | 69 etag(rhs.etag), |
67 last_modified(rhs.last_modified), | 70 last_modified(rhs.last_modified), |
68 received_bytes(rhs.received_bytes), | 71 received_bytes(rhs.received_bytes), |
69 total_bytes(rhs.total_bytes), | 72 total_bytes(rhs.total_bytes), |
70 state(rhs.state), | 73 state(rhs.state), |
71 danger_type(rhs.danger_type), | 74 danger_type(rhs.danger_type), |
72 interrupt_reason(rhs.interrupt_reason), | 75 interrupt_reason(rhs.interrupt_reason), |
73 opened(rhs.opened) {} | 76 opened(rhs.opened) {} |
74 | 77 |
75 MockDownloadManager::CreateDownloadItemAdapter::~CreateDownloadItemAdapter() {} | 78 MockDownloadManager::CreateDownloadItemAdapter::~CreateDownloadItemAdapter() {} |
76 | 79 |
77 bool MockDownloadManager::CreateDownloadItemAdapter::operator==( | 80 bool MockDownloadManager::CreateDownloadItemAdapter::operator==( |
78 const CreateDownloadItemAdapter& rhs) const { | 81 const CreateDownloadItemAdapter& rhs) const { |
79 return ( | 82 return ( |
80 guid == rhs.guid && id == rhs.id && current_path == rhs.current_path && | 83 guid == rhs.guid && id == rhs.id && current_path == rhs.current_path && |
81 target_path == rhs.target_path && url_chain == rhs.url_chain && | 84 target_path == rhs.target_path && url_chain == rhs.url_chain && |
82 referrer_url == rhs.referrer_url && tab_url == rhs.tab_url && | 85 referrer_url == rhs.referrer_url && |
| 86 site_instance_url == rhs.site_instance_url && tab_url == rhs.tab_url && |
83 tab_referrer_url == rhs.tab_referrer_url && mime_type == rhs.mime_type && | 87 tab_referrer_url == rhs.tab_referrer_url && mime_type == rhs.mime_type && |
84 original_mime_type == rhs.original_mime_type && | 88 original_mime_type == rhs.original_mime_type && |
85 start_time == rhs.start_time && end_time == rhs.end_time && | 89 start_time == rhs.start_time && end_time == rhs.end_time && |
86 etag == rhs.etag && last_modified == rhs.last_modified && | 90 etag == rhs.etag && last_modified == rhs.last_modified && |
87 received_bytes == rhs.received_bytes && total_bytes == rhs.total_bytes && | 91 received_bytes == rhs.received_bytes && total_bytes == rhs.total_bytes && |
88 state == rhs.state && danger_type == rhs.danger_type && | 92 state == rhs.state && danger_type == rhs.danger_type && |
89 interrupt_reason == rhs.interrupt_reason && opened == rhs.opened); | 93 interrupt_reason == rhs.interrupt_reason && opened == rhs.opened); |
90 } | 94 } |
91 | 95 |
92 MockDownloadManager::MockDownloadManager() {} | 96 MockDownloadManager::MockDownloadManager() {} |
93 | 97 |
94 MockDownloadManager::~MockDownloadManager() {} | 98 MockDownloadManager::~MockDownloadManager() {} |
95 | 99 |
96 void MockDownloadManager::StartDownload( | 100 void MockDownloadManager::StartDownload( |
97 std::unique_ptr<DownloadCreateInfo> info, | 101 std::unique_ptr<DownloadCreateInfo> info, |
98 std::unique_ptr<ByteStreamReader> stream, | 102 std::unique_ptr<ByteStreamReader> stream, |
99 const DownloadUrlParameters::OnStartedCallback& callback) { | 103 const DownloadUrlParameters::OnStartedCallback& callback) { |
100 MockStartDownload(info.get(), stream.get()); | 104 MockStartDownload(info.get(), stream.get()); |
101 } | 105 } |
102 | 106 |
103 DownloadItem* MockDownloadManager::CreateDownloadItem( | 107 DownloadItem* MockDownloadManager::CreateDownloadItem( |
104 const std::string& guid, | 108 const std::string& guid, |
105 uint32_t id, | 109 uint32_t id, |
106 const base::FilePath& current_path, | 110 const base::FilePath& current_path, |
107 const base::FilePath& target_path, | 111 const base::FilePath& target_path, |
108 const std::vector<GURL>& url_chain, | 112 const std::vector<GURL>& url_chain, |
109 const GURL& referrer_url, | 113 const GURL& referrer_url, |
| 114 const GURL& site_instance_url, |
110 const GURL& tab_url, | 115 const GURL& tab_url, |
111 const GURL& tab_referrer_url, | 116 const GURL& tab_referrer_url, |
112 const std::string& mime_type, | 117 const std::string& mime_type, |
113 const std::string& original_mime_type, | 118 const std::string& original_mime_type, |
114 const base::Time& start_time, | 119 const base::Time& start_time, |
115 const base::Time& end_time, | 120 const base::Time& end_time, |
116 const std::string& etag, | 121 const std::string& etag, |
117 const std::string& last_modified, | 122 const std::string& last_modified, |
118 int64_t received_bytes, | 123 int64_t received_bytes, |
119 int64_t total_bytes, | 124 int64_t total_bytes, |
120 const std::string& hash, | 125 const std::string& hash, |
121 DownloadItem::DownloadState state, | 126 DownloadItem::DownloadState state, |
122 DownloadDangerType danger_type, | 127 DownloadDangerType danger_type, |
123 DownloadInterruptReason interrupt_reason, | 128 DownloadInterruptReason interrupt_reason, |
124 bool opened) { | 129 bool opened) { |
125 CreateDownloadItemAdapter adapter( | 130 CreateDownloadItemAdapter adapter( |
126 guid, id, current_path, target_path, url_chain, referrer_url, tab_url, | 131 guid, id, current_path, target_path, url_chain, referrer_url, |
127 tab_referrer_url, mime_type, original_mime_type, start_time, end_time, | 132 site_instance_url, tab_url, tab_referrer_url, mime_type, |
128 etag, last_modified, received_bytes, total_bytes, hash, state, | 133 original_mime_type, start_time, end_time, etag, last_modified, |
129 danger_type, interrupt_reason, opened); | 134 received_bytes, total_bytes, hash, state, danger_type, interrupt_reason, |
| 135 opened); |
130 return MockCreateDownloadItem(adapter); | 136 return MockCreateDownloadItem(adapter); |
131 } | 137 } |
132 | 138 |
133 } // namespace content | 139 } // namespace content |
OLD | NEW |