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_COMPONENT_UPDATER_CRX_UPDATE_ITEM_H_
6 #define COMPONENTS_COMPONENT_UPDATER_CRX_UPDATE_ITEM_H_
11 #include "base/basictypes.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h"
14 #include "base/version.h"
15 #include "components/component_updater/component_updater_service.h"
16 #include "components/component_updater/crx_downloader.h"
18 namespace component_updater
{
20 // This is the one and only per-item state structure. Designed to be hosted
21 // in a std::vector or a std::list. The two main members are |component|
22 // which is supplied by the the component updater client and |status| which
23 // is modified as the item is processed by the update pipeline. The expected
24 // transition graph is:
26 // on-demand on-demand
27 // +---------------------------> kNew <--------------+-------------+
30 // | +--------------------> kChecking -<-------+---|---<-----+ |
32 // | | error V no | | | |
33 // kNoUpdate <---------------- [update?] ->---- kUpToDate kUpdated
37 // | +-----------> kCanUpdate |
40 // | | [differential update?]->----+ |
44 // | +---------<- kDownloadingDiff | |
48 // | +---------<- kUpdatingDiff ->--------|-----------+ success
51 // +----------------------------------------- kDownloading |
54 // +------------------------------------------ kUpdating ->----+ success
56 struct CrxUpdateItem
{
71 // Call CrxUpdateService::ChangeItemState to change |status|. The function may
72 // enforce conditions or notify observers of the change.
76 CrxComponent component
;
78 base::Time last_check
;
80 // A component can be made available for download from several urls.
81 std::vector
<GURL
> crx_urls
;
82 std::vector
<GURL
> crx_diffurls
;
84 // The from/to version and fingerprint values.
85 Version previous_version
;
87 std::string previous_fp
;
90 // True if the current update check cycle is on-demand.
93 // True if the differential update failed for any reason.
94 bool diff_update_failed
;
96 // The error information for full and differential updates.
97 // The |error_category| contains a hint about which module in the component
98 // updater generated the error. The |error_code| constains the error and
99 // the |extra_code1| usually contains a system error, but it can contain
100 // any extended information that is relevant to either the category or the
105 int diff_error_category
;
107 int diff_extra_code1
;
109 std::vector
<CrxDownloader::DownloadMetrics
> download_metrics
;
111 std::vector
<base::Closure
> ready_callbacks
;
116 // Function object used to find a specific component.
119 explicit FindById(const std::string
& id
) : id_(id
) {}
121 bool operator()(CrxUpdateItem
* item
) const { return item
->id
== id_
; }
124 const std::string
& id_
;
128 } // namespace component_updater
130 #endif // COMPONENTS_COMPONENT_UPDATER_CRX_UPDATE_ITEM_H_