| OLD | NEW |
| (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/prefetch/prefetch_types.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 in-memory representations of items in (or to be |
| 20 // inserted into) the persistent prefetching data store. |
| 21 struct PrefetchItem { |
| 22 PrefetchItem() = default; |
| 23 explicit PrefetchItem(const PrefetchItem& other) = default; |
| 24 |
| 25 ~PrefetchItem(){}; |
| 26 |
| 27 bool operator==(const PrefetchItem& other) const; |
| 28 |
| 29 // Primary key/ID for this prefetch item (See |base::GenerateGUID()|). This |
| 30 // value will be reused when communicating with other systems accepting GUID |
| 31 // identifiers for operations linked to this item. |
| 32 std::string guid; |
| 33 |
| 34 // The namespace from the prefetcher client to be used for the creation of an |
| 35 // offline page for this item. |
| 36 std::string name_space; |
| 37 |
| 38 // Current prefetching progress state. |
| 39 PrefetchItemState state = PrefetchItemState::NEW_REQUEST; |
| 40 |
| 41 // The URL of the page the client requested to be prefetched. |
| 42 GURL url; |
| 43 |
| 44 // The final URL whose page was actually included in a successfully created |
| 45 // archive after redirects, if it was different than the |url|. It will be |
| 46 // left empty if they are the same. |
| 47 GURL final_archived_url; |
| 48 |
| 49 // Number of times an attempt was made to generate an archive for this item. |
| 50 int request_archive_attempt_count = 0; |
| 51 |
| 52 // Name used to identify the archiving operation being executed by the |
| 53 // prefetching service for processing this item's URL. It is used as the |
| 54 // |operation_name| reported by an incoming GCM message and in the |
| 55 // |GetOperationRequest.name| field of the respective GetOperation RPC. |
| 56 std::string operation_name; |
| 57 |
| 58 // The name specific to this item's archive that can be used to build the URL |
| 59 // to allow the downloading of that archive. Will only be set when and if an |
| 60 // archive was successfully created for this item. It will be kept empty |
| 61 // otherwise. |
| 62 std::string archive_body_name; |
| 63 |
| 64 // The final size of the generated archive that contains this item's page |
| 65 // snapshot. The archive might also include other articles in a bundle so the |
| 66 // length is not necessarily directly related to this item's page contents. |
| 67 // Will only be set when and if an archive was successfully created for this |
| 68 // item. It holds a negative value otherwise. |
| 69 int64_t archive_body_length = -1; |
| 70 |
| 71 // Time when this item was inserted into the store with the URL to be |
| 72 // prefetched. |
| 73 base::Time creation_time; |
| 74 |
| 75 // Time used for the expiration of the item depending on the applicable policy |
| 76 // for its current state. It is initially set with the same value as |
| 77 // |creation_time|. Its value is "refreshed" to the current time on some state |
| 78 // transitions considered significant for the prefetching process. |
| 79 base::Time freshness_time; |
| 80 |
| 81 // The reason why the item was set to the FIN state. Should be disregarded |
| 82 // until reaching that state. |
| 83 PrefetchItemErrorCode error_code = PrefetchItemErrorCode::NO_ERROR; |
| 84 }; |
| 85 |
| 86 } // namespace offline_pages |
| 87 |
| 88 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_ITEM_H_ |
| OLD | NEW |