1 // Copyright 2013 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 CHROME_BROWSER_COMPONENT_UPDATER_CRX_UPDATE_ITEM_H_
6 #define CHROME_BROWSER_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 "chrome/browser/component_updater/component_updater_service.h"
16 #include "chrome/browser/component_updater/crx_downloader.h"
18 namespace component_updater
{
20 class CUResourceThrottle
;
22 // This is the one and only per-item state structure. Designed to be hosted
23 // in a std::vector or a std::list. The two main members are |component|
24 // which is supplied by the the component updater client and |status| which
25 // is modified as the item is processed by the update pipeline. The expected
26 // transition graph is:
28 // on-demand on-demand
29 // +---------------------------> kNew <--------------+-------------+
32 // | +--------------------> kChecking -<-------+---|---<-----+ |
34 // | | error V no | | | |
35 // kNoUpdate <---------------- [update?] ->---- kUpToDate kUpdated
39 // | +-----------> kCanUpdate |
42 // | | [differential update?]->----+ |
46 // | +---------<- kDownloadingDiff | |
50 // | +---------<- kUpdatingDiff ->--------|-----------+ success
53 // +----------------------------------------- kDownloading |
56 // +------------------------------------------ kUpdating ->----+ success
58 struct CrxUpdateItem
{
73 // Call CrxUpdateService::ChangeItemState to change |status|. The function may
74 // enforce conditions or notify observers of the change.
78 CrxComponent component
;
80 base::Time last_check
;
82 // A component can be made available for download from several urls.
83 std::vector
<GURL
> crx_urls
;
84 std::vector
<GURL
> crx_diffurls
;
86 // The from/to version and fingerprint values.
87 Version previous_version
;
89 std::string previous_fp
;
92 // True if the current update check cycle is on-demand.
95 // True if the differential update failed for any reason.
96 bool diff_update_failed
;
98 // The error information for full and differential updates.
99 // The |error_category| contains a hint about which module in the component
100 // updater generated the error. The |error_code| constains the error and
101 // the |extra_code1| usually contains a system error, but it can contain
102 // any extended information that is relevant to either the category or the
107 int diff_error_category
;
109 int diff_extra_code1
;
111 std::vector
<CrxDownloader::DownloadMetrics
> download_metrics
;
113 std::vector
<base::WeakPtr
<CUResourceThrottle
> > throttles
;
118 // Function object used to find a specific component.
121 explicit FindById(const std::string
& id
) : id_(id
) {}
123 bool operator()(CrxUpdateItem
* item
) const { return item
->id
== id_
; }
126 const std::string
& id_
;
130 } // namespace component_updater
132 #endif // CHROME_BROWSER_COMPONENT_UPDATER_CRX_UPDATE_ITEM_H_