Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: components/offline_items_collection/core/offline_item.cc

Issue 2861863002: offline_items_collection : Added helper class to determine progress (Closed)
Patch Set: more Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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() : value(0), max(-1), unit(BYTES) {}
30
31 OfflineItem::Progress::Progress(const Progress& other) = default;
32
33 OfflineItem::Progress::~Progress() = default;
34
35 bool OfflineItem::Progress::operator==(const Progress& other) const {
36 return value == other.value && max == other.max && unit == other.unit;
37 }
38
29 OfflineItem::OfflineItem() 39 OfflineItem::OfflineItem()
30 : filter(OfflineItemFilter::FILTER_OTHER), 40 : filter(OfflineItemFilter::FILTER_OTHER),
31 is_transient(false), 41 is_transient(false),
32 total_size_bytes(0), 42 total_size_bytes(0),
33 externally_removed(false), 43 externally_removed(false),
34 is_openable(false), 44 is_openable(false),
35 is_off_the_record(false), 45 is_off_the_record(false),
36 state(OfflineItemState::COMPLETE), 46 state(OfflineItemState::COMPLETE),
37 is_resumable(false), 47 is_resumable(false),
38 allow_metered(false), 48 allow_metered(false),
39 received_bytes(0), 49 received_bytes(0),
40 percent_completed(0),
41 time_remaining_ms(0) {} 50 time_remaining_ms(0) {}
42 51
43 OfflineItem::OfflineItem(const OfflineItem& other) = default; 52 OfflineItem::OfflineItem(const OfflineItem& other) = default;
44 53
45 OfflineItem::OfflineItem(const ContentId& id) : OfflineItem() { 54 OfflineItem::OfflineItem(const ContentId& id) : OfflineItem() {
46 this->id = id; 55 this->id = id;
47 } 56 }
48 57
49 OfflineItem::~OfflineItem() = default; 58 OfflineItem::~OfflineItem() = default;
50 59
51 bool OfflineItem::operator==(const OfflineItem& offline_item) const { 60 bool OfflineItem::operator==(const OfflineItem& offline_item) const {
52 return id == offline_item.id && title == offline_item.title && 61 return id == offline_item.id && title == offline_item.title &&
53 description == offline_item.description && 62 description == offline_item.description &&
54 filter == offline_item.filter && 63 filter == offline_item.filter &&
55 is_transient == offline_item.is_transient && 64 is_transient == offline_item.is_transient &&
56 total_size_bytes == offline_item.total_size_bytes && 65 total_size_bytes == offline_item.total_size_bytes &&
57 externally_removed == offline_item.externally_removed && 66 externally_removed == offline_item.externally_removed &&
58 creation_time == offline_item.creation_time && 67 creation_time == offline_item.creation_time &&
59 last_accessed_time == offline_item.last_accessed_time && 68 last_accessed_time == offline_item.last_accessed_time &&
60 is_openable == offline_item.is_openable && 69 is_openable == offline_item.is_openable &&
61 page_url == offline_item.page_url && 70 page_url == offline_item.page_url &&
62 original_url == offline_item.original_url && 71 original_url == offline_item.original_url &&
63 is_off_the_record == offline_item.is_off_the_record && 72 is_off_the_record == offline_item.is_off_the_record &&
64 state == offline_item.state && 73 state == offline_item.state &&
65 is_resumable == offline_item.is_resumable && 74 is_resumable == offline_item.is_resumable &&
66 allow_metered == offline_item.allow_metered && 75 allow_metered == offline_item.allow_metered &&
67 received_bytes == offline_item.received_bytes && 76 received_bytes == offline_item.received_bytes &&
68 percent_completed == offline_item.percent_completed && 77 progress == offline_item.progress &&
69 time_remaining_ms == offline_item.time_remaining_ms; 78 time_remaining_ms == offline_item.time_remaining_ms;
70 } 79 }
71 80
72 OfflineItemVisuals::OfflineItemVisuals() = default; 81 OfflineItemVisuals::OfflineItemVisuals() = default;
73 OfflineItemVisuals::OfflineItemVisuals(const OfflineItemVisuals& other) = 82 OfflineItemVisuals::OfflineItemVisuals(const OfflineItemVisuals& other) =
74 default; 83 default;
75 OfflineItemVisuals::~OfflineItemVisuals() = default; 84 OfflineItemVisuals::~OfflineItemVisuals() = default;
76 85
77 } // namespace offline_items_collection 86 } // namespace offline_items_collection
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698