Chromium Code Reviews| 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/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "components/offline_items_collection/core/offline_item_filter.h" | 11 #include "components/offline_items_collection/core/offline_item_filter.h" |
| 12 #include "components/offline_items_collection/core/offline_item_progress_unit.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 { |
| 20 // The namespace for the offline content. This will be used to associate this | 21 // The namespace for the offline content. This will be used to associate this |
| 21 // id with a particular OfflineContentProvider. A name_space can include | 22 // id with a particular OfflineContentProvider. A name_space can include |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 // This struct holds the relevant pieces of information to represent an abstract | 42 // 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 | 43 // 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 | 44 // need to both show content being offlined (downloading, saving, etc.) as well |
| 44 // as content that should be exposed as available offline (downloads, pages, | 45 // as content that should be exposed as available offline (downloads, pages, |
| 45 // etc.). | 46 // etc.). |
| 46 // | 47 // |
| 47 // A new feature should expose these OfflineItems via an OfflineContentProvider. | 48 // A new feature should expose these OfflineItems via an OfflineContentProvider. |
| 48 struct OfflineItem { | 49 struct OfflineItem { |
| 50 // This struct holds the essential pieces of information to compute the | |
| 51 // download progress percentage for an offline item to display in the UI. | |
|
David Trainor- moved to gerrit
2017/05/03 22:06:32
remove "percentage"
shaktisahu
2017/05/05 02:09:37
Done.
| |
| 52 struct Progress { | |
| 53 Progress(); | |
| 54 Progress(const Progress& other); | |
| 55 ~Progress(); | |
| 56 | |
| 57 bool operator==(const Progress& progress) const; | |
| 58 | |
| 59 // Current value of the download progress. | |
| 60 int64_t value; | |
| 61 | |
| 62 // The maximum value of the download progress. -1 indicates indeterminate. | |
|
David Trainor- moved to gerrit
2017/05/03 22:06:32
Can this just be a base::Optional? If it's not th
shaktisahu
2017/05/05 02:09:37
Done.
| |
| 63 int64_t max; | |
| 64 | |
| 65 // The unit of progress to be displayed in the UI. | |
| 66 OfflineItemProgressUnit unit; | |
| 67 }; | |
| 68 | |
| 49 OfflineItem(); | 69 OfflineItem(); |
| 50 OfflineItem(const OfflineItem& other); | 70 OfflineItem(const OfflineItem& other); |
| 51 explicit OfflineItem(const ContentId& id); | 71 explicit OfflineItem(const ContentId& id); |
| 52 | 72 |
| 53 ~OfflineItem(); | 73 ~OfflineItem(); |
| 54 | 74 |
| 55 bool operator==(const OfflineItem& offline_item) const; | 75 bool operator==(const OfflineItem& offline_item) const; |
| 56 | 76 |
| 57 // The id of this OfflineItem. Used to identify this item across all relevant | 77 // The id of this OfflineItem. Used to identify this item across all relevant |
| 58 // systems. | 78 // systems. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 bool is_resumable; | 135 bool is_resumable; |
| 116 | 136 |
| 117 // Whether or not this OfflineItem can be downloaded using a metered | 137 // Whether or not this OfflineItem can be downloaded using a metered |
| 118 // connection. | 138 // connection. |
| 119 bool allow_metered; | 139 bool allow_metered; |
| 120 | 140 |
| 121 // The current amount of bytes received for this item. This field is not used | 141 // The current amount of bytes received for this item. This field is not used |
| 122 // if |state| is COMPLETE. | 142 // if |state| is COMPLETE. |
| 123 int64_t received_bytes; | 143 int64_t received_bytes; |
| 124 | 144 |
| 125 // How complete (from 0 to 100) the offlining process is for this item. -1 | 145 // Represents the current progress of this item. |
|
David Trainor- moved to gerrit
2017/05/03 22:06:32
Keep some of the information here. The field is n
shaktisahu
2017/05/05 02:09:37
Done.
| |
| 126 // represents that progress cannot be determined for this item and an | 146 Progress progress; |
| 127 // indeterminate progress bar should be used. This field is not used if | |
| 128 // |state| is COMPLETE. | |
| 129 int percent_completed; | |
| 130 | 147 |
| 131 // The estimated time remaining for the download in milliseconds. -1 | 148 // The estimated time remaining for the download in milliseconds. -1 |
| 132 // represents an unknown time remaining. This field is not used if |state| is | 149 // represents an unknown time remaining. This field is not used if |state| is |
| 133 // COMPLETE. | 150 // COMPLETE. |
| 134 int64_t time_remaining_ms; | 151 int64_t time_remaining_ms; |
| 135 }; | 152 }; |
| 136 | 153 |
| 137 // This struct holds any potentially expensive visuals for an OfflineItem. If | 154 // 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 | 155 // the front end requires the visuals it will ask for them through the |
| 139 // OfflineContentProvider interface asynchronously to give the backend time to | 156 // OfflineContentProvider interface asynchronously to give the backend time to |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 151 | 168 |
| 152 // The icon to use for displaying this item. The icon should be 64dp x 64dp. | 169 // 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 | 170 // TODO(dtrainor): Suggest icon size based on the icon size supported by the |
| 154 // current OS. | 171 // current OS. |
| 155 gfx::Image icon; | 172 gfx::Image icon; |
| 156 }; | 173 }; |
| 157 | 174 |
| 158 } // namespace offline_items_collection | 175 } // namespace offline_items_collection |
| 159 | 176 |
| 160 #endif // COMPONENTS_OFFLINE_ITEMS_COLLECTION_OFFLINE_ITEM_H_ | 177 #endif // COMPONENTS_OFFLINE_ITEMS_COLLECTION_OFFLINE_ITEM_H_ |
| OLD | NEW |