| 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 #ifndef COMPONENTS_OFFLINE_ITEMS_COLLECTION_CORE_OFFLINE_ITEM_H_ | 5 #ifndef COMPONENTS_OFFLINE_ITEMS_COLLECTION_CORE_OFFLINE_ITEM_H_ |
| 6 #define COMPONENTS_OFFLINE_ITEMS_COLLECTION_CORE_OFFLINE_ITEM_H_ | 6 #define COMPONENTS_OFFLINE_ITEMS_COLLECTION_CORE_OFFLINE_ITEM_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/optional.h" |
| 10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 11 #include "components/offline_items_collection/core/offline_item_filter.h" | 12 #include "components/offline_items_collection/core/offline_item_filter.h" |
| 12 #include "components/offline_items_collection/core/offline_item_state.h" | 13 #include "components/offline_items_collection/core/offline_item_state.h" |
| 13 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 namespace offline_items_collection { | 17 namespace offline_items_collection { |
| 17 | 18 |
| 18 // An id that uniquely represents a piece of offline content. | 19 // An id that uniquely represents a piece of offline content. |
| 19 struct ContentId { | 20 struct ContentId { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 31 ContentId(const ContentId& other); | 32 ContentId(const ContentId& other); |
| 32 ContentId(const std::string& name_space, const std::string& id); | 33 ContentId(const std::string& name_space, const std::string& id); |
| 33 | 34 |
| 34 ~ContentId(); | 35 ~ContentId(); |
| 35 | 36 |
| 36 bool operator==(const ContentId& content_id) const; | 37 bool operator==(const ContentId& content_id) const; |
| 37 | 38 |
| 38 bool operator<(const ContentId& content_id) const; | 39 bool operator<(const ContentId& content_id) const; |
| 39 }; | 40 }; |
| 40 | 41 |
| 42 // A Java counterpart will be generated for this enum. |
| 43 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.offline_items_collection |
| 44 enum class OfflineItemProgressUnit { |
| 45 BYTES, |
| 46 FILES, |
| 47 PERCENTAGE, |
| 48 }; |
| 49 |
| 41 // This struct holds the relevant pieces of information to represent an abstract | 50 // This struct holds the relevant pieces of information to represent an abstract |
| 42 // offline item to the front end. This is meant to be backed by components that | 51 // offline item to the front end. This is meant to be backed by components that |
| 43 // need to both show content being offlined (downloading, saving, etc.) as well | 52 // need to both show content being offlined (downloading, saving, etc.) as well |
| 44 // as content that should be exposed as available offline (downloads, pages, | 53 // as content that should be exposed as available offline (downloads, pages, |
| 45 // etc.). | 54 // etc.). |
| 46 // | 55 // |
| 47 // A new feature should expose these OfflineItems via an OfflineContentProvider. | 56 // A new feature should expose these OfflineItems via an OfflineContentProvider. |
| 48 struct OfflineItem { | 57 struct OfflineItem { |
| 58 // This struct holds the essential pieces of information to compute the |
| 59 // download progress for an offline item to display in the UI. |
| 60 struct Progress { |
| 61 Progress(); |
| 62 Progress(const Progress& other); |
| 63 ~Progress(); |
| 64 |
| 65 bool operator==(const Progress& progress) const; |
| 66 |
| 67 // Current value of the download progress. |
| 68 int64_t value; |
| 69 |
| 70 // The maximum value of the download progress. Absence of the value implies |
| 71 // indeterminate progress. |
| 72 base::Optional<int64_t> max; |
| 73 |
| 74 // The unit of progress to be displayed in the UI. |
| 75 OfflineItemProgressUnit unit; |
| 76 }; |
| 77 |
| 49 OfflineItem(); | 78 OfflineItem(); |
| 50 OfflineItem(const OfflineItem& other); | 79 OfflineItem(const OfflineItem& other); |
| 51 explicit OfflineItem(const ContentId& id); | 80 explicit OfflineItem(const ContentId& id); |
| 52 | 81 |
| 53 ~OfflineItem(); | 82 ~OfflineItem(); |
| 54 | 83 |
| 55 bool operator==(const OfflineItem& offline_item) const; | 84 bool operator==(const OfflineItem& offline_item) const; |
| 56 | 85 |
| 57 // The id of this OfflineItem. Used to identify this item across all relevant | 86 // The id of this OfflineItem. Used to identify this item across all relevant |
| 58 // systems. | 87 // systems. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 bool is_resumable; | 144 bool is_resumable; |
| 116 | 145 |
| 117 // Whether or not this OfflineItem can be downloaded using a metered | 146 // Whether or not this OfflineItem can be downloaded using a metered |
| 118 // connection. | 147 // connection. |
| 119 bool allow_metered; | 148 bool allow_metered; |
| 120 | 149 |
| 121 // The current amount of bytes received for this item. This field is not used | 150 // The current amount of bytes received for this item. This field is not used |
| 122 // if |state| is COMPLETE. | 151 // if |state| is COMPLETE. |
| 123 int64_t received_bytes; | 152 int64_t received_bytes; |
| 124 | 153 |
| 125 // How complete (from 0 to 100) the offlining process is for this item. -1 | 154 // Represents the current progress of this item. This field is not used if |
| 126 // represents that progress cannot be determined for this item and an | |
| 127 // indeterminate progress bar should be used. This field is not used if | |
| 128 // |state| is COMPLETE. | 155 // |state| is COMPLETE. |
| 129 int percent_completed; | 156 Progress progress; |
| 130 | 157 |
| 131 // The estimated time remaining for the download in milliseconds. -1 | 158 // The estimated time remaining for the download in milliseconds. -1 |
| 132 // represents an unknown time remaining. This field is not used if |state| is | 159 // represents an unknown time remaining. This field is not used if |state| is |
| 133 // COMPLETE. | 160 // COMPLETE. |
| 134 int64_t time_remaining_ms; | 161 int64_t time_remaining_ms; |
| 135 }; | 162 }; |
| 136 | 163 |
| 137 // This struct holds any potentially expensive visuals for an OfflineItem. If | 164 // This struct holds any potentially expensive visuals for an OfflineItem. If |
| 138 // the front end requires the visuals it will ask for them through the | 165 // the front end requires the visuals it will ask for them through the |
| 139 // OfflineContentProvider interface asynchronously to give the backend time to | 166 // OfflineContentProvider interface asynchronously to give the backend time to |
| (...skipping 11 matching lines...) Expand all Loading... |
| 151 | 178 |
| 152 // The icon to use for displaying this item. The icon should be 64dp x 64dp. | 179 // The icon to use for displaying this item. The icon should be 64dp x 64dp. |
| 153 // TODO(dtrainor): Suggest icon size based on the icon size supported by the | 180 // TODO(dtrainor): Suggest icon size based on the icon size supported by the |
| 154 // current OS. | 181 // current OS. |
| 155 gfx::Image icon; | 182 gfx::Image icon; |
| 156 }; | 183 }; |
| 157 | 184 |
| 158 } // namespace offline_items_collection | 185 } // namespace offline_items_collection |
| 159 | 186 |
| 160 #endif // COMPONENTS_OFFLINE_ITEMS_COLLECTION_OFFLINE_ITEM_H_ | 187 #endif // COMPONENTS_OFFLINE_ITEMS_COLLECTION_OFFLINE_ITEM_H_ |
| OLD | NEW |