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

Unified Diff: components/offline_pages/core/prefetch/prefetch_item.h

Issue 2872933003: Add base persistence interfaces for Prefetching Offline Pages. (Closed)
Patch Set: Renamed constants file; removed ClientId dependency; and more. 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
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..48bcf33820608250d8dd7f820e28e45495e48572
--- /dev/null
+++ b/components/offline_pages/core/prefetch/prefetch_item.h
@@ -0,0 +1,88 @@
+// 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/prefetch/prefetch_types.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 in-memory representations of items in (or to be
+// inserted into) the persistent prefetching data store.
+struct PrefetchItem {
+ PrefetchItem() = default;
+ explicit PrefetchItem(const PrefetchItem& other) = default;
+
+ ~PrefetchItem(){};
+
+ bool operator==(const PrefetchItem& other) const;
+
+ // Primary key/ID for this prefetch item (See |base::GenerateGUID()|). This
+ // value will be reused when communicating with other systems accepting GUID
+ // identifiers for operations linked to this item.
+ std::string guid;
+
+ // The namespace from the prefetcher client to be used for the creation of an
+ // offline page for this item.
+ std::string name_space;
+
+ // Current prefetching progress state.
+ PrefetchItemState state = PrefetchItemState::NEW_REQUEST;
+
+ // The URL of the page the client requested to be prefetched.
+ GURL url;
+
+ // The final URL whose page was actually included in a successfully created
+ // archive after redirects, if it was different than the |url|. It will be
+ // left empty if they are the same.
+ GURL final_archived_url;
+
+ // Number of times an attempt was made to generate an archive for this item.
+ int request_archive_attempt_count = 0;
+
+ // Name used to identify the archiving operation being executed by the
+ // prefetching service for processing this item's URL. It is used as the
+ // |operation_name| reported by an incoming GCM message and in the
+ // |GetOperationRequest.name| field of the respective GetOperation RPC.
+ 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. Will only be set when and if an
+ // archive was successfully created for this item. It will be kept empty
+ // otherwise.
+ 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 so the
+ // length is not necessarily directly related to this item's page contents.
+ // Will only be set when and if an archive was successfully created for this
+ // item. It holds a negative value otherwise.
+ int64_t archive_body_length = -1;
+
+ // 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. It is initially set with the same value as
+ // |creation_time|. Its value is "refreshed" to the current time on some state
+ // transitions considered significant for the prefetching process.
+ base::Time freshness_time;
+
+ // The reason why the item was set to the FIN state. Should be disregarded
+ // until reaching that state.
+ PrefetchItemErrorCode error_code = PrefetchItemErrorCode::NO_ERROR;
+};
+
+} // namespace offline_pages
+
+#endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_ITEM_H_

Powered by Google App Engine
This is Rietveld 408576698