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

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: Addressed comments and other changes; added constants file. 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
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 "components/offline_pages/core/prefetch/prefetch_constants.h"
13 #include "url/gurl.h"
14
15 namespace offline_pages {
16
17 // Data object representing an item progressing through the prefetching process
18 // from the moment a URL is requested by a client until its processing id done,
19 // successfully or not.
20 // Instances of this class are in-memory representations of items in (or to be
21 // inserted into) the persistent prefetching data store.
22 struct PrefetchItem {
23 public:
fgorski 2017/05/10 05:02:53 nit: struct implies public.
carlosk 2017/05/10 22:48:54 Done.
24 const int64_t INVALID_ID = -1;
fgorski 2017/05/10 05:02:53 will you only allow positive numbers? If negative
carlosk 2017/05/10 22:48:53 As we moved to a string guid this was now removed.
25
26 PrefetchItem() = default;
27 explicit PrefetchItem(const PrefetchItem& other) = default;
28
29 ~PrefetchItem(){};
30
31 bool operator==(const PrefetchItem& other) const;
32
33 // Primary key/ID for this prefetch item.
34 int64_t id = INVALID_ID;
35
36 // The |ClientID| specified by the prefetcher client to be used for the
37 // offline page that might be generated from this item, consolidating a
38 // namespace and a client ID.
39 ClientId client_id;
40
41 // Current prefetching progress state.
42 PrefetchItemState state = PrefetchItemState::NEW_REQ;
43
44 // The URL of the page the client requested to be prefetched.
45 GURL url;
46
47 // The final URL whose page was actually included in a successfully created
48 // archive after redirects, if it was different than the |url|. It will be
49 // left empty if they are the same.
50 GURL final_archived_url;
51
52 // Number of times an attempt was made to generate an archive for this item.
53 int request_archive_attempt_count = 0;
54
55 // Name used to identify the archiving operation being executed by the
56 // prefetching service for processing this item's URL. It is used as the
57 // |operation_name| reported by an incoming GCM message and in the
58 // |GetOperationRequest.name| field of the respective GetOperation RPC.
59 std::string operation_name;
60
61 // The name specific to this item's archive that can be used to build the URL
62 // to allow the downloading of that archive. Will only be set when and if an
63 // archive was successfully created for this item. It will be kept empty
64 // otherwise.
65 std::string archive_body_name;
66
67 // The final size of the generated archive that contains this item's page
68 // snapshot. The archive might also include other articles in a bundle so the
69 // length is not necessarily directly related to this item's page contents.
70 // Will only be set when and if an archive was successfully created for this
71 // item. It holds a negative value otherwise.
72 int64_t archive_body_length = -1;
73
74 // An opaque identifier to the request being served to download this item's
75 // archive.
76 std::string download_id;
77
78 // Time when this item was inserted into the store with the URL to be
79 // prefetched.
80 base::Time creation_time;
81
82 // Time used for the expiration of the item depending on the applicable policy
83 // for its current state. It is initially set with the same value as
84 // |creation_time|. Its value is "refreshed" to the current time on some state
85 // transitions considered significant for the prefetching process.
86 base::Time freshness_time;
87
88 // The reason why a the item was set to the FIN state. Until then its value is
fgorski 2017/05/10 05:02:53 nit: "why a the"?
carlosk 2017/05/10 22:48:53 Done.
89 // meaningless.
90 PrefetchItemErrorCode error_code = PrefetchItemErrorCode::NO_ERROR;
91 };
92
93 } // namespace offline_pages
94
95 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698