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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/core/prefetch/prefetch_item.h
diff --git a/components/offline_pages/core/prefetch/prefetch_item.h b/components/offline_pages/core/prefetch/prefetch_item.h
new file mode 100644
index 0000000000000000000000000000000000000000..52c486f9e7595d71e5baf824d8d75f2733c5efd6
--- /dev/null
+++ b/components/offline_pages/core/prefetch/prefetch_item.h
@@ -0,0 +1,116 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_ITEM_H_
+#define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_ITEM_H_
+
+#include <string>
+
+#include "base/time/time.h"
+#include "components/offline_pages/core/offline_page_item.h"
+#include "url/gurl.h"
+
+namespace offline_pages {
+
+// Data object representing an item progressing through the prefetching process
+// from the moment a URL is requested by a client until its processing id done,
+// successfully or not.
+// 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.
+// prefetching persistent data store.
+struct PrefetchItem {
+ public:
+ const int64_t INVALID_ID = -1;
+
+ // The states the item can be at during its progress through the prefetching
+ // process. They follow somewhat the order below but some states might be
+ // skipped.
+ 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
+ // New request just received from the client.
+ NEW_REQ,
+ // The item has been included in a GeneratePageBundle RPC requesting the
+ // creation of an archive for its URL.
+ SENT_GPB,
+ // The archive was not immediately available (cached) upon the request and
+ // is now waiting for a GCM message notifying of its archiving operation
+ // completion.
+ WAIT_GCM,
+ // The GCM message notifying of the archiving operation completion was
+ // received for this item.
+ GOT_GCM,
+ // A GetOperation RPC was sent for this item to query for the final results
+ // of its archiving request.
+ SENT_GET_OP,
+ // Information was received about a successfully created archive for this
+ // item that can now be downloaded.
+ RECV_BUNDLE,
+ // This item's archive is currently being downloaded.
+ DL,
+ // Item has finished processing, successfully or otherwise and is waiting to
+ // be processed for stats reporting to UMA.
+ FIN,
+ // UMA stats have been reported and the item is being kept just long enough
+ // 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
+ ZOMBIE,
+ }
+
+ PrefetchItem() = default;
+ PrefetchItem(const PrefetchItem& other) = default;
+ ~PrefetchItem();
+
+ bool operator==(const PrefetchItem& other) const;
+
+ // Primary key/ID for this prefetch item.
+ 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.
+
+ // The |ClientID| specified by the prefetcher client to be used for the
+ // offline page that might be generated from this item, consolidating a
+ // namespace and a client ID.
+ ClientId client_id;
+
+ // Current prefetching progress state.
+ 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
+
+ // 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.
+ GURL url;
+
+ // The URL actually included in the archive after redirects if different from
+ // |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.
+ GURL final_archived_url;
+
+ // Number of times an attempt was made to generate an archive for this item.
+ 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.
+
+ // A long lasting operation name for the case when the service doesn't have
+ // 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
+ std::string operation_name;
+
+ // The name specific to this item's archive that can be used to build the URL
+ // to allow the downloading of that archive.
+ std::string archive_body_name;
+
+ // The final size of the generated archive that contains this item's page
+ // 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
+ int64_t archive_body_length = -1;
+
+ // 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
+ // item's page.
+ int download_operation_attempt_count = 0;
+
+ // An opaque identifier to the request being served to download this item's
+ // archive.
+ std::string download_id;
+
+ // Time when this item was inserted into the store with the URL to be
+ // prefetched.
+ base::Time creation_time;
+
+ // Time used for the expiration of the item depending on the applicable policy
+ // for its current state. Its value is "refreshed" to the current time on some
+ // state transitions considered significant for the prefetching process.
+ base::Time freshness_time;
+};
+
+} // namespace offline_pages
+
+#endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_ITEM_H_
« 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