tuple: update to make use of C++11
[chromium-blink-merge.git] / content / public / test / mock_download_manager.cc
blobe81ca93ab58dce613703f2483090e3582b2b70df
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
3 // found in the LICENSE file.
5 #include "content/public/test/mock_download_manager.h"
7 #include "content/browser/byte_stream.h"
8 #include "content/browser/download/download_create_info.h"
10 namespace content {
12 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter(
13 uint32 id,
14 const base::FilePath& current_path,
15 const base::FilePath& target_path,
16 const std::vector<GURL>& url_chain,
17 const GURL& referrer_url,
18 const std::string& mime_type,
19 const std::string& original_mime_type,
20 const base::Time& start_time,
21 const base::Time& end_time,
22 const std::string& etag,
23 const std::string& last_modified,
24 int64 received_bytes,
25 int64 total_bytes,
26 DownloadItem::DownloadState state,
27 DownloadDangerType danger_type,
28 DownloadInterruptReason interrupt_reason,
29 bool opened)
30 : id(id),
31 current_path(current_path),
32 target_path(target_path),
33 url_chain(url_chain),
34 referrer_url(referrer_url),
35 mime_type(mime_type),
36 original_mime_type(original_mime_type),
37 start_time(start_time),
38 end_time(end_time),
39 received_bytes(received_bytes),
40 total_bytes(total_bytes),
41 state(state),
42 danger_type(danger_type),
43 interrupt_reason(interrupt_reason),
44 opened(opened) {}
46 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter(
47 const CreateDownloadItemAdapter& rhs)
48 : id(rhs.id),
49 current_path(rhs.current_path),
50 target_path(rhs.target_path),
51 url_chain(rhs.url_chain),
52 referrer_url(rhs.referrer_url),
53 start_time(rhs.start_time),
54 end_time(rhs.end_time),
55 etag(rhs.etag),
56 last_modified(rhs.last_modified),
57 received_bytes(rhs.received_bytes),
58 total_bytes(rhs.total_bytes),
59 state(rhs.state),
60 danger_type(rhs.danger_type),
61 interrupt_reason(rhs.interrupt_reason),
62 opened(rhs.opened) {}
64 MockDownloadManager::CreateDownloadItemAdapter::~CreateDownloadItemAdapter() {}
66 bool MockDownloadManager::CreateDownloadItemAdapter::operator==(
67 const CreateDownloadItemAdapter& rhs) const {
68 return (id == rhs.id &&
69 current_path == rhs.current_path &&
70 target_path == rhs.target_path &&
71 url_chain == rhs.url_chain &&
72 referrer_url == rhs.referrer_url &&
73 mime_type == rhs.mime_type &&
74 original_mime_type == rhs.original_mime_type &&
75 start_time == rhs.start_time &&
76 end_time == rhs.end_time &&
77 etag == rhs.etag &&
78 last_modified == rhs.last_modified &&
79 received_bytes == rhs.received_bytes &&
80 total_bytes == rhs.total_bytes &&
81 state == rhs.state &&
82 danger_type == rhs.danger_type &&
83 interrupt_reason == rhs.interrupt_reason &&
84 opened == rhs.opened);
87 MockDownloadManager::MockDownloadManager() {}
89 MockDownloadManager::~MockDownloadManager() {}
91 void MockDownloadManager::StartDownload(
92 scoped_ptr<DownloadCreateInfo> info,
93 scoped_ptr<ByteStreamReader> stream,
94 const DownloadUrlParameters::OnStartedCallback& callback) {
95 MockStartDownload(info.get(), stream.get());
98 DownloadItem* MockDownloadManager::CreateDownloadItem(
99 uint32 id,
100 const base::FilePath& current_path,
101 const base::FilePath& target_path,
102 const std::vector<GURL>& url_chain,
103 const GURL& referrer_url,
104 const std::string& mime_type,
105 const std::string& original_mime_type,
106 const base::Time& start_time,
107 const base::Time& end_time,
108 const std::string& etag,
109 const std::string& last_modified,
110 int64 received_bytes,
111 int64 total_bytes,
112 DownloadItem::DownloadState state,
113 DownloadDangerType danger_type,
114 DownloadInterruptReason interrupt_reason,
115 bool opened) {
116 CreateDownloadItemAdapter adapter(
117 id, current_path, target_path, url_chain, referrer_url, mime_type,
118 original_mime_type, start_time, end_time, etag, last_modified,
119 received_bytes, total_bytes, state, danger_type, interrupt_reason,
120 opened);
121 return MockCreateDownloadItem(adapter);
124 } // namespace content