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

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

Issue 2690333002: Initial checkin of OfflineContentProvider. (Closed)
Patch Set: ItemsAvailable -> AreItemsAvailable 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_CONTENT_CORE_OFFLINE_ITEM_H_
6 #define COMPONENTS_OFFLINE_CONTENT_CORE_OFFLINE_ITEM_H_
7
8 #include <string>
9
10 #include "base/time/time.h"
11 #include "components/offline_content/core/offline_item_file_extension.h"
12 #include "components/offline_content/core/offline_item_filter.h"
13 #include "components/offline_content/core/offline_item_state.h"
14 #include "url/gurl.h"
15
16 namespace offline_content {
17
18 // An id that uniquely represents a piece of offline content.
19 struct ContentId {
20 public:
21 // The namespace for the offline content. This will be used to associate this
22 // id with a particular OfflineContentProvider.
23 std::string name_space;
24
25 // The id of the offline item.
26 std::string guid;
Dmitry Titov 2017/02/14 05:41:31 This can be any id scoped to the name space provid
David Trainor- moved to gerrit 2017/02/22 01:23:12 Good idea! I think that's ok. Updating it.
27
28 ContentId();
29 ContentId(const ContentId& other);
30 ContentId(const std::string& name_space, const std::string& guid);
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 {
David Trainor- moved to gerrit 2017/02/22 01:23:12 Quick note on all of these fields: I pulled most
45 public:
46 OfflineItem();
47 OfflineItem(const OfflineItem& other);
48 explicit OfflineItem(const ContentId& id);
49
50 ~OfflineItem();
51
52 bool operator==(const OfflineItem& offline_item) const;
53
54 // The id of this OfflineItem. Used to identify this item across all relevant
55 // systems.
56 ContentId id;
57
58 // Display Metadata.
59 // ---------------------------------------------------------------------------
60 // The title of the OfflineItem to display in the UI.
61 std::string title;
62
63 // The description of the OfflineItem to display in the UI (may or may not be
64 // displayed depending on the specific UI component).
65 std::string description;
66
67 // The URL of the icon that should be used to represent this offline item. If
68 // |icon_url| is empty a default one will be used based on |filter|.
69 std::string icon_url;
Dmitry Titov 2017/02/14 05:41:31 What about offline scenarios, is this supposed to
David Trainor- moved to gerrit 2017/02/22 01:23:12 Will remove in the short term. Good point. It mi
70
71 // The type of offline item this is. This can be used for filtering offline
72 // items as well as for determining which default icon to use.
73 OfflineItemFilter filter;
Dmitry Titov 2017/02/14 05:41:31 This feels related to "file extension" field below
David Trainor- moved to gerrit 2017/02/22 01:23:12 Can we detect offline pages via the mime type? Cu
74
75 // Content Metadata.
76 // ---------------------------------------------------------------------------
77 // The total size of the offline item as best known at the current time.
78 int64_t total_size_bytes;
79
80 // The extension type of the offline content. Can be |FILE_EXTENSION_OTHER|
81 // if there is no appropriate file extension for the offline content.
82 OfflineItemFileExtension file_type;
Dmitry Titov 2017/02/14 05:41:31 Is this for the same reason as mime-type would be
qinmin 2017/02/14 07:37:20 why extension, not mime type?
David Trainor- moved to gerrit 2017/02/22 01:23:12 Yeah you guys have a good point. See my comment o
83
84 // Whether or not this item has been removed externally (not by Chrome).
85 bool externally_removed;
86
87 // The time when the underlying offline content was created.
88 base::Time creation_time;
89
90 // The last time the underlying offline content was accessed.
91 base::Time last_accessed_time;
92
93 // Request Metadata.
94 // ---------------------------------------------------------------------------
95 // The URL of the top level frame at the time the content was offlined.
96 std::string page_url;
97
98 // The URL that represents the original request (before any redirection).
99 std::string original_url;
100
101 // The referrer URL for the request.
102 std::string referrer_url;
Dmitry Titov 2017/02/14 05:41:31 Might not exist... Does UI need to know?
David Trainor- moved to gerrit 2017/02/22 01:23:12 We need to know to add files to the Android downlo
103
104 // Whether or not this item request started from a user gesture.
105 bool is_user_gesture;
Dmitry Titov 2017/02/14 05:41:31 What is this used for? This may be not an easy bit
David Trainor- moved to gerrit 2017/02/22 01:23:12 Used to determine whether or not to automatically
106
107 // Whether or not this item is off the record.
108 bool is_off_the_record;
109
110 // In Progress Metadata.
111 // ---------------------------------------------------------------------------
112 // The current state of the OfflineItem.
113 OfflineItemState state;
114
115 // Whether or not the offlining of this content can be resumed if it was
116 // paused or interrupted.
117 bool is_resumable;
118
119 // The current amount of bytes received for this item.
120 int64_t received_size_bytes;
Dmitry Titov 2017/02/14 05:41:31 Comment could also say what happens when item beco
David Trainor- moved to gerrit 2017/02/22 01:23:12 Marked them as unused if |state| is COMPLETE. Let
121
122 // How complete (from 0 to 100) the offlining process is for this item. -1
123 // represents that progress cannot be determined for this item and an
124 // indeterminate progress bar should be used.
125 int percent_completed;
126
127 // The estimated time remaining for the download in milliseconds. -1
128 // represents an unknown time remaining.
129 int64_t time_remaining_ms;
130 };
131
132 } // namespace offline_content
133
134 #endif // COMPONENTS_OFFLINE_CONTENT_OFFLINE_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698