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