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/offline_items_collection/core/offline_item.h" | 5 #include "components/offline_items_collection/core/offline_item.h" |
6 | 6 |
7 namespace offline_items_collection { | 7 namespace offline_items_collection { |
8 | 8 |
9 ContentId::ContentId() = default; | 9 ContentId::ContentId() = default; |
10 | 10 |
11 ContentId::ContentId(const ContentId& other) = default; | 11 ContentId::ContentId(const ContentId& other) = default; |
12 | 12 |
13 ContentId::ContentId(const std::string& name_space, const std::string& id) | 13 ContentId::ContentId(const std::string& name_space, const std::string& id) |
14 : name_space(name_space), id(id) { | 14 : name_space(name_space), id(id) { |
15 DCHECK_EQ(std::string::npos, name_space.find_first_of(",")); | 15 DCHECK_EQ(std::string::npos, name_space.find_first_of(",")); |
16 } | 16 } |
17 | 17 |
18 ContentId::~ContentId() = default; | 18 ContentId::~ContentId() = default; |
19 | 19 |
20 bool ContentId::operator==(const ContentId& content_id) const { | 20 bool ContentId::operator==(const ContentId& content_id) const { |
21 return name_space == content_id.name_space && id == content_id.id; | 21 return name_space == content_id.name_space && id == content_id.id; |
22 } | 22 } |
23 | 23 |
24 bool ContentId::operator<(const ContentId& content_id) const { | 24 bool ContentId::operator<(const ContentId& content_id) const { |
25 return std::tie(name_space, id) < | 25 return std::tie(name_space, id) < |
26 std::tie(content_id.name_space, content_id.id); | 26 std::tie(content_id.name_space, content_id.id); |
27 } | 27 } |
28 | 28 |
| 29 OfflineItem::Progress::Progress() |
| 30 : value(0), unit(OfflineItemProgressUnit::BYTES) {} |
| 31 |
| 32 OfflineItem::Progress::Progress(const OfflineItem::Progress& other) = default; |
| 33 |
| 34 OfflineItem::Progress::~Progress() = default; |
| 35 |
| 36 bool OfflineItem::Progress::operator==( |
| 37 const OfflineItem::Progress& other) const { |
| 38 return value == other.value && max == other.max && unit == other.unit; |
| 39 } |
| 40 |
29 OfflineItem::OfflineItem() | 41 OfflineItem::OfflineItem() |
30 : filter(OfflineItemFilter::FILTER_OTHER), | 42 : filter(OfflineItemFilter::FILTER_OTHER), |
31 is_transient(false), | 43 is_transient(false), |
32 total_size_bytes(0), | 44 total_size_bytes(0), |
33 externally_removed(false), | 45 externally_removed(false), |
34 is_openable(false), | 46 is_openable(false), |
35 is_off_the_record(false), | 47 is_off_the_record(false), |
36 state(OfflineItemState::COMPLETE), | 48 state(OfflineItemState::COMPLETE), |
37 is_resumable(false), | 49 is_resumable(false), |
38 allow_metered(false), | 50 allow_metered(false), |
39 received_bytes(0), | 51 received_bytes(0), |
40 percent_completed(0), | |
41 time_remaining_ms(0) {} | 52 time_remaining_ms(0) {} |
42 | 53 |
43 OfflineItem::OfflineItem(const OfflineItem& other) = default; | 54 OfflineItem::OfflineItem(const OfflineItem& other) = default; |
44 | 55 |
45 OfflineItem::OfflineItem(const ContentId& id) : OfflineItem() { | 56 OfflineItem::OfflineItem(const ContentId& id) : OfflineItem() { |
46 this->id = id; | 57 this->id = id; |
47 } | 58 } |
48 | 59 |
49 OfflineItem::~OfflineItem() = default; | 60 OfflineItem::~OfflineItem() = default; |
50 | 61 |
51 bool OfflineItem::operator==(const OfflineItem& offline_item) const { | 62 bool OfflineItem::operator==(const OfflineItem& offline_item) const { |
52 return id == offline_item.id && title == offline_item.title && | 63 return id == offline_item.id && title == offline_item.title && |
53 description == offline_item.description && | 64 description == offline_item.description && |
54 filter == offline_item.filter && | 65 filter == offline_item.filter && |
55 is_transient == offline_item.is_transient && | 66 is_transient == offline_item.is_transient && |
56 total_size_bytes == offline_item.total_size_bytes && | 67 total_size_bytes == offline_item.total_size_bytes && |
57 externally_removed == offline_item.externally_removed && | 68 externally_removed == offline_item.externally_removed && |
58 creation_time == offline_item.creation_time && | 69 creation_time == offline_item.creation_time && |
59 last_accessed_time == offline_item.last_accessed_time && | 70 last_accessed_time == offline_item.last_accessed_time && |
60 is_openable == offline_item.is_openable && | 71 is_openable == offline_item.is_openable && |
61 page_url == offline_item.page_url && | 72 page_url == offline_item.page_url && |
62 original_url == offline_item.original_url && | 73 original_url == offline_item.original_url && |
63 is_off_the_record == offline_item.is_off_the_record && | 74 is_off_the_record == offline_item.is_off_the_record && |
64 state == offline_item.state && | 75 state == offline_item.state && |
65 is_resumable == offline_item.is_resumable && | 76 is_resumable == offline_item.is_resumable && |
66 allow_metered == offline_item.allow_metered && | 77 allow_metered == offline_item.allow_metered && |
67 received_bytes == offline_item.received_bytes && | 78 received_bytes == offline_item.received_bytes && |
68 percent_completed == offline_item.percent_completed && | 79 progress == offline_item.progress && |
69 time_remaining_ms == offline_item.time_remaining_ms; | 80 time_remaining_ms == offline_item.time_remaining_ms; |
70 } | 81 } |
71 | 82 |
72 OfflineItemVisuals::OfflineItemVisuals() = default; | 83 OfflineItemVisuals::OfflineItemVisuals() = default; |
73 OfflineItemVisuals::OfflineItemVisuals(const OfflineItemVisuals& other) = | 84 OfflineItemVisuals::OfflineItemVisuals(const OfflineItemVisuals& other) = |
74 default; | 85 default; |
75 OfflineItemVisuals::~OfflineItemVisuals() = default; | 86 OfflineItemVisuals::~OfflineItemVisuals() = default; |
76 | 87 |
77 } // namespace offline_items_collection | 88 } // namespace offline_items_collection |
OLD | NEW |