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

Side by Side Diff: components/offline_pages/core/prefetch/prefetch_item.h

Issue 2872933003: Add base persistence interfaces for Prefetching Offline Pages. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PAGES_CORE_PREFETCH_PREFETCH_ITEM_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_ITEM_H_
7
8 #include <string>
9
10 #include "base/time/time.h"
11 #include "components/offline_pages/core/offline_page_item.h"
12 #include "url/gurl.h"
13
14 namespace offline_pages {
15
16 // Data object representing an item progressing through the prefetching process
17 // from the moment a URL is requested by a client until its processing id done,
18 // successfully or not.
19 // Instances of this class are mainly used for communicating with the
dewittj 2017/05/09 22:41:24 Maybe this would be clearer as: Instances of this
carlosk 2017/05/09 23:57:40 Done.
20 // prefetching persistent data store.
21 struct PrefetchItem {
22 public:
23 const int64_t INVALID_ID = -1;
24
25 // The states the item can be at during its progress through the prefetching
26 // process. They follow somewhat the order below but some states might be
27 // skipped.
28 enum class State {
fgorski 2017/05/09 22:31:31 Is there a good reason to keep the names of enums
dewittj 2017/05/09 22:41:24 +1 This matches the DD but in code perhaps we sho
carlosk 2017/05/09 23:57:39 enums were moved to prefetch_constants.h and now h
29 // New request just received from the client.
30 NEW_REQ,
31 // The item has been included in a GeneratePageBundle RPC requesting the
32 // creation of an archive for its URL.
33 SENT_GPB,
34 // The archive was not immediately available (cached) upon the request and
35 // is now waiting for a GCM message notifying of its archiving operation
36 // completion.
37 WAIT_GCM,
38 // The GCM message notifying of the archiving operation completion was
39 // received for this item.
40 GOT_GCM,
41 // A GetOperation RPC was sent for this item to query for the final results
42 // of its archiving request.
43 SENT_GET_OP,
44 // Information was received about a successfully created archive for this
45 // item that can now be downloaded.
46 RECV_BUNDLE,
47 // This item's archive is currently being downloaded.
48 DL,
49 // Item has finished processing, successfully or otherwise and is waiting to
50 // be processed for stats reporting to UMA.
51 FIN,
52 // UMA stats have been reported and the item is being kept just long enough
53 // to confirm that the same URL is not being reported anymore by its client.
Dmitry Titov 2017/05/09 20:42:25 "is not being reported anymore" -> "is not being r
carlosk 2017/05/09 23:57:40 Rephrased (but this text moved to prefetch_constan
54 ZOMBIE,
55 }
56
57 PrefetchItem() = default;
58 PrefetchItem(const PrefetchItem& other) = default;
59 ~PrefetchItem();
60
61 bool operator==(const PrefetchItem& other) const;
62
63 // Primary key/ID for this prefetch item.
64 int64_t id = INVALID_ID;
Dmitry Titov 2017/05/09 20:42:25 Should we do a guid here? We need a guid for Downl
carlosk 2017/05/09 23:57:40 After reading the downloads design doc I was uncer
Dmitry Titov 2017/05/10 00:44:47 Not sure what you mean, we have to pass guid in wh
carlosk 2017/05/10 22:48:53 Indeed and SGTM. Changed to GUID.
65
66 // The |ClientID| specified by the prefetcher client to be used for the
67 // offline page that might be generated from this item, consolidating a
68 // namespace and a client ID.
69 ClientId client_id;
70
71 // Current prefetching progress state.
72 State state = NEW_REQ;
dewittj 2017/05/09 22:41:25 It might be better to insist that state be require
carlosk 2017/05/09 23:57:40 When would we create a new instance not in the NEW
73
74 // The URL pointing to the page the client requested to be prefetched.
dewittj 2017/05/09 22:41:25 URL of the page?
carlosk 2017/05/09 23:57:40 Done.
75 GURL url;
76
77 // The URL actually included in the archive after redirects if different from
78 // |prefetch_url|. It will be empty if they are the same.
Dmitry Titov 2017/05/09 20:42:26 typo: there is no prefetch_url
carlosk 2017/05/09 23:57:40 Done.
79 GURL final_archived_url;
80
81 // Number of times an attempt was made to generate an archive for this item.
82 int generate_archive_attempt_count = 0;
dewittj 2017/05/09 22:41:24 I think I prefer request_archive_attempt_count sin
carlosk 2017/05/09 23:57:39 Done.
83
84 // A long lasting operation name for the case when the service doesn't have
85 // the archive immediately available to download.
Dmitry Titov 2017/05/09 20:42:26 Add: "Normally corresponds to the operation_name r
carlosk 2017/05/09 23:57:39 It's also used when archiving failed. I rephrased
86 std::string operation_name;
87
88 // The name specific to this item's archive that can be used to build the URL
89 // to allow the downloading of that archive.
90 std::string archive_body_name;
91
92 // The final size of the generated archive that contains this item's page
93 // snapshot. The archive might also include other articles in a bundle.
dewittj 2017/05/09 22:41:24 document what -1 and other negatives represent
carlosk 2017/05/09 23:57:40 Done for this case and similarly the body name abo
94 int64_t archive_body_length = -1;
95
96 // Number of times an attempt was made to download the archive containing this
Dmitry Titov 2017/05/09 20:42:26 Don't we just try it once? The Download API should
carlosk 2017/05/09 23:57:39 I removed it. I'll remove this column from the des
Dmitry Titov 2017/05/10 00:44:47 I think this is reasonable assumptions about Downl
carlosk 2017/05/10 22:48:53 Extra note: I found this enum value in the Downloa
97 // item's page.
98 int download_operation_attempt_count = 0;
99
100 // An opaque identifier to the request being served to download this item's
101 // archive.
102 std::string download_id;
103
104 // Time when this item was inserted into the store with the URL to be
105 // prefetched.
106 base::Time creation_time;
107
108 // Time used for the expiration of the item depending on the applicable policy
109 // for its current state. Its value is "refreshed" to the current time on some
110 // state transitions considered significant for the prefetching process.
111 base::Time freshness_time;
112 };
113
114 } // namespace offline_pages
115
116 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_ITEM_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698