1 // Copyright 2014 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.
5 #ifndef COMPONENTS_UPDATE_CLIENT_CRX_UPDATE_ITEM_H_
6 #define COMPONENTS_UPDATE_CLIENT_CRX_UPDATE_ITEM_H_
11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h"
13 #include "base/version.h"
14 #include "components/update_client/crx_downloader.h"
15 #include "components/update_client/update_client.h"
17 namespace update_client
{
19 // This is the one and only per-item state structure. Designed to be hosted
20 // in a std::vector or a std::list. The two main members are |component|
21 // which is supplied by the the component updater client and |status| which
22 // is modified as the item is processed by the update pipeline. The expected
23 // transition graph is:
25 // on-demand on-demand
26 // +---------------------------> kNew <--------------+-------------+
29 // | +--------------------> kChecking -<-------+---|---<-----+ |
31 // | | error V no | | | |
32 // kNoUpdate <---------------- [update?] ->---- kUpToDate kUpdated
36 // | +-----------> kCanUpdate |
39 // | | [differential update?]->----+ |
43 // | +---------<- kDownloadingDiff | |
47 // | +---------<- kUpdatingDiff ->--------|-----------+ success
50 // +----------------------------------------- kDownloading |
53 // +------------------------------------------ kUpdating ->----+ success
55 struct CrxUpdateItem
{
70 // Call CrxUpdateService::ChangeItemState to change |status|. The function may
71 // enforce conditions or notify observers of the change.
74 // True if the component was recently unregistered and will be uninstalled
75 // soon (after the currently operation is finished, if there is one).
79 CrxComponent component
;
81 base::Time last_check
;
83 // A component can be made available for download from several urls.
84 std::vector
<GURL
> crx_urls
;
85 std::vector
<GURL
> crx_diffurls
;
87 // The from/to version and fingerprint values.
88 Version previous_version
;
90 std::string previous_fp
;
93 // True if the current update check cycle is on-demand.
96 // True if the differential update failed for any reason.
97 bool diff_update_failed
;
99 // The error information for full and differential updates.
100 // The |error_category| contains a hint about which module in the component
101 // updater generated the error. The |error_code| constains the error and
102 // the |extra_code1| usually contains a system error, but it can contain
103 // any extended information that is relevant to either the category or the
108 int diff_error_category
;
110 int diff_extra_code1
;
112 std::vector
<CrxDownloader::DownloadMetrics
> download_metrics
;
114 std::vector
<base::Closure
> ready_callbacks
;
119 // Function object used to find a specific component.
122 explicit FindById(const std::string
& id
) : id_(id
) {}
124 bool operator()(CrxUpdateItem
* item
) const { return item
->id
== id_
; }
127 const std::string
& id_
;
131 } // namespace update_client
133 #endif // COMPONENTS_UPDATE_CLIENT_CRX_UPDATE_ITEM_H_