Revert of ui: Clean up damaged rects and clear them after painting. (patchset #2...
[chromium-blink-merge.git] / components / update_client / crx_update_item.h
blobf066ca230281ba26363ea06c5f0442481fd5a6fe
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_
8 #include <string>
9 #include <vector>
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 <--------------+-------------+
27 // | | | |
28 // | V | |
29 // | +--------------------> kChecking -<-------+---|---<-----+ |
30 // | | | | | | |
31 // | | error V no | | | |
32 // kNoUpdate <---------------- [update?] ->---- kUpToDate kUpdated
33 // ^ | ^
34 // | yes | |
35 // | diff=false V |
36 // | +-----------> kCanUpdate |
37 // | | | |
38 // | | V no |
39 // | | [differential update?]->----+ |
40 // | | | | |
41 // | | yes | | |
42 // | | error V | |
43 // | +---------<- kDownloadingDiff | |
44 // | | | | |
45 // | | | | |
46 // | | error V | |
47 // | +---------<- kUpdatingDiff ->--------|-----------+ success
48 // | | |
49 // | error V |
50 // +----------------------------------------- kDownloading |
51 // | | |
52 // | error V |
53 // +------------------------------------------ kUpdating ->----+ success
55 // TODO(sorin): this data structure will be further refactored once
56 // the new update service is in place. For the time being, it remains as-is,
57 // since it is used by the old component update service.
58 struct CrxUpdateItem {
59 enum class State {
60 kNew,
61 kChecking,
62 kCanUpdate,
63 kDownloadingDiff,
64 kDownloading,
65 kDownloaded,
66 kUpdatingDiff,
67 kUpdating,
68 kUpdated,
69 kUpToDate,
70 kNoUpdate,
71 kLastStatus
74 // Call CrxUpdateService::ChangeItemState to change |status|. The function may
75 // enforce conditions or notify observers of the change.
76 State state;
78 // True if the component was recently unregistered and will be uninstalled
79 // soon (after the currently operation is finished, if there is one).
80 bool unregistered;
82 std::string id;
83 CrxComponent component;
85 base::Time last_check;
87 // A component can be made available for download from several urls.
88 std::vector<GURL> crx_urls;
89 std::vector<GURL> crx_diffurls;
91 // The from/to version and fingerprint values.
92 Version previous_version;
93 Version next_version;
94 std::string previous_fp;
95 std::string next_fp;
97 // True if the current update check cycle is on-demand.
98 bool on_demand;
100 // True if the differential update failed for any reason.
101 bool diff_update_failed;
103 // The error information for full and differential updates.
104 // The |error_category| contains a hint about which module in the component
105 // updater generated the error. The |error_code| constains the error and
106 // the |extra_code1| usually contains a system error, but it can contain
107 // any extended information that is relevant to either the category or the
108 // error itself.
109 int error_category;
110 int error_code;
111 int extra_code1;
112 int diff_error_category;
113 int diff_error_code;
114 int diff_extra_code1;
116 std::vector<CrxDownloader::DownloadMetrics> download_metrics;
118 std::vector<base::Closure> ready_callbacks;
120 CrxUpdateItem();
121 ~CrxUpdateItem();
123 // Function object used to find a specific component.
124 class FindById {
125 public:
126 explicit FindById(const std::string& id) : id_(id) {}
128 bool operator()(CrxUpdateItem* item) const { return item->id == id_; }
130 private:
131 const std::string& id_;
135 } // namespace update_client
137 #endif // COMPONENTS_UPDATE_CLIENT_CRX_UPDATE_ITEM_H_