| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_OFFLINE_ITEMS_COLLECTION_CORE_OFFLINE_ITEM_H_ |
| 6 #define COMPONENTS_OFFLINE_ITEMS_COLLECTION_CORE_OFFLINE_ITEM_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #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_state.h" |
| 13 #include "url/gurl.h" |
| 14 |
| 15 namespace offline_items_collection { |
| 16 |
| 17 // An id that uniquely represents a piece of offline content. |
| 18 struct ContentId { |
| 19 // The namespace for the offline content. This will be used to associate this |
| 20 // id with a particular OfflineContentProvider. |
| 21 std::string name_space; |
| 22 |
| 23 // The id of the offline item. |
| 24 std::string id; |
| 25 |
| 26 ContentId(); |
| 27 ContentId(const ContentId& other); |
| 28 ContentId(const std::string& name_space, const std::string& id); |
| 29 |
| 30 ~ContentId(); |
| 31 |
| 32 bool operator==(const ContentId& content_id) const; |
| 33 |
| 34 bool operator<(const ContentId& content_id) const; |
| 35 }; |
| 36 |
| 37 // This struct holds the relevant pieces of information to represent an abstract |
| 38 // offline item to the front end. This is meant to be backed by components that |
| 39 // need to both show content being offlined (downloading, saving, etc.) as well |
| 40 // as content that should be exposed as available offline (downloads, pages, |
| 41 // etc.). |
| 42 // |
| 43 // A new feature should expose these OfflineItems via an OfflineContentProvider. |
| 44 struct OfflineItem { |
| 45 OfflineItem(); |
| 46 OfflineItem(const OfflineItem& other); |
| 47 explicit OfflineItem(const ContentId& id); |
| 48 |
| 49 ~OfflineItem(); |
| 50 |
| 51 bool operator==(const OfflineItem& offline_item) const; |
| 52 |
| 53 // The id of this OfflineItem. Used to identify this item across all relevant |
| 54 // systems. |
| 55 ContentId id; |
| 56 |
| 57 // Display Metadata. |
| 58 // --------------------------------------------------------------------------- |
| 59 // The title of the OfflineItem to display in the UI. |
| 60 std::string title; |
| 61 |
| 62 // The description of the OfflineItem to display in the UI (may or may not be |
| 63 // displayed depending on the specific UI component). |
| 64 std::string description; |
| 65 |
| 66 // The type of offline item this is. This can be used for filtering offline |
| 67 // items as well as for determining which default icon to use. |
| 68 OfflineItemFilter filter; |
| 69 |
| 70 // TODO(dtrainor): Build out custom per-item icon support. |
| 71 |
| 72 // Content Metadata. |
| 73 // --------------------------------------------------------------------------- |
| 74 // The total size of the offline item as best known at the current time. |
| 75 int64_t total_size_bytes; |
| 76 |
| 77 // Whether or not this item has been removed externally (not by Chrome). |
| 78 bool externally_removed; |
| 79 |
| 80 // The time when the underlying offline content was created. |
| 81 base::Time creation_time; |
| 82 |
| 83 // The last time the underlying offline content was accessed. |
| 84 base::Time last_accessed_time; |
| 85 |
| 86 // Request Metadata. |
| 87 // --------------------------------------------------------------------------- |
| 88 // The URL of the top level frame at the time the content was offlined. |
| 89 GURL page_url; |
| 90 |
| 91 // The URL that represents the original request (before any redirection). |
| 92 GURL original_url; |
| 93 |
| 94 // Whether or not this item is off the record. |
| 95 bool is_off_the_record; |
| 96 |
| 97 // In Progress Metadata. |
| 98 // --------------------------------------------------------------------------- |
| 99 // The current state of the OfflineItem. |
| 100 OfflineItemState state; |
| 101 |
| 102 // Whether or not the offlining of this content can be resumed if it was |
| 103 // paused or interrupted. |
| 104 bool is_resumable; |
| 105 |
| 106 // The current amount of bytes received for this item. This field is not used |
| 107 // if |state| is COMPLETE. |
| 108 int64_t received_bytes; |
| 109 |
| 110 // How complete (from 0 to 100) the offlining process is for this item. -1 |
| 111 // represents that progress cannot be determined for this item and an |
| 112 // indeterminate progress bar should be used. This field is not used if |
| 113 // |state| is COMPLETE. |
| 114 int percent_completed; |
| 115 |
| 116 // The estimated time remaining for the download in milliseconds. -1 |
| 117 // represents an unknown time remaining. This field is not used if |state| is |
| 118 // COMPLETE. |
| 119 int64_t time_remaining_ms; |
| 120 }; |
| 121 |
| 122 } // namespace offline_items_collection |
| 123 |
| 124 #endif // COMPONENTS_OFFLINE_ITEMS_COLLECTION_OFFLINE_ITEM_H_ |
| OLD | NEW |