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

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

Issue 2690333002: Initial checkin of OfflineContentProvider. (Closed)
Patch Set: Moved files to components/offline_items_collection. Created 3 years, 10 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
(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 public:
qinmin 2017/02/22 07:39:17 nit: not needed
David Trainor- moved to gerrit 2017/03/03 00:34:12 Done.
20 // The namespace for the offline content. This will be used to associate this
21 // id with a particular OfflineContentProvider.
22 std::string name_space;
23
24 // The id of the offline item.
25 std::string id;
26
27 ContentId();
28 ContentId(const ContentId& other);
29 ContentId(const std::string& name_space, const std::string& id);
30
31 bool operator==(const ContentId& content_id) const;
32
33 bool operator<(const ContentId& content_id) const;
34 };
35
36 // This struct holds the relevant pieces of information to represent an abstract
37 // offline item to the front end. This is meant to be backed by components that
38 // need to both show content being offlined (downloading, saving, etc.) as well
39 // as content that should be exposed as available offline (downloads, pages,
40 // etc.).
41 //
42 // A new feature should expose these OfflineItems via an OfflineContentProvider.
43 struct OfflineItem {
44 public:
qinmin 2017/02/22 07:39:17 ditto
David Trainor- moved to gerrit 2017/03/03 00:34:12 Done.
45 OfflineItem();
46 OfflineItem(const OfflineItem& other);
47 explicit OfflineItem(const ContentId& id);
48
49 ~OfflineItem();
qinmin 2017/02/22 07:39:17 nit: ContentId doesn't declare a dtor, but this on
David Trainor- moved to gerrit 2017/03/03 00:34:12 Done.
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_size_bytes;
qinmin 2017/02/22 07:39:17 nit: received_bytes seems a more proper name
David Trainor- moved to gerrit 2017/03/03 00:34:12 Done.
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698