Chromium Code Reviews| 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..48d03a71ae0142d05e0bde8a3ce42a6408fd5c56 |
| --- /dev/null |
| +++ b/components/offline_pages/core/prefetch/prefetch_item.h |
| @@ -0,0 +1,95 @@ |
| +// 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 "components/offline_pages/core/prefetch/prefetch_constants.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 { |
| + public: |
|
fgorski
2017/05/10 05:02:53
nit: struct implies public.
carlosk
2017/05/10 22:48:54
Done.
|
| + 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.
|
| + |
| + PrefetchItem() = default; |
| + explicit PrefetchItem(const PrefetchItem& other) = default; |
| + |
| + ~PrefetchItem(){}; |
| + |
| + bool operator==(const PrefetchItem& other) const; |
| + |
| + // Primary key/ID for this prefetch item. |
| + int64_t id = INVALID_ID; |
| + |
| + // 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. |
| + PrefetchItemState state = PrefetchItemState::NEW_REQ; |
| + |
| + // 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; |
| + |
| + // 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. 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 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.
|
| + // meaningless. |
| + PrefetchItemErrorCode error_code = PrefetchItemErrorCode::NO_ERROR; |
| +}; |
| + |
| +} // namespace offline_pages |
| + |
| +#endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_ITEM_H_ |