Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: components/update_client/crx_update_item.h

Issue 2835803002: Refactor the UpdateEngine and its actions in the component updater. (Closed)
Patch Set: feedback up to #6 Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/update_client/component.cc ('k') | components/update_client/ping_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_UPDATE_CLIENT_CRX_UPDATE_ITEM_H_ 5 #ifndef COMPONENTS_UPDATE_CLIENT_CRX_UPDATE_ITEM_H_
6 #define COMPONENTS_UPDATE_CLIENT_CRX_UPDATE_ITEM_H_ 6 #define COMPONENTS_UPDATE_CLIENT_CRX_UPDATE_ITEM_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "base/version.h" 15 #include "base/version.h"
16 #include "components/update_client/crx_downloader.h" 16 #include "components/update_client/crx_downloader.h"
17 #include "components/update_client/update_client.h" 17 #include "components/update_client/update_client.h"
18 18
19 namespace update_client { 19 namespace update_client {
20 20
21 // This is the one and only per-item state structure. Designed to be hosted
22 // in a std::vector or a std::list. The two main members are |component|
23 // which is supplied by the the component updater client and |status| which
24 // is modified as the item is processed by the update pipeline. The expected
25 // transition graph is:
26 //
27 // on-demand on-demand
28 // +---------------------------> kNew <--------------+-------------+
29 // | | | |
30 // | V | |
31 // | +--------------------> kChecking -<-------+---|---<-----+ |
32 // | | | | | | |
33 // | | error V no | | | |
34 // kNoUpdate <---------------- [update?] ->---- kUpToDate kUpdated
35 // ^ | ^
36 // | yes | |
37 // | diff=false V |
38 // | +-----------> kCanUpdate |
39 // | | | |
40 // | | V no |
41 // | | [differential update?]->----+ |
42 // | | | | |
43 // | | yes | | |
44 // | | error V | |
45 // | +---------<- kDownloadingDiff | |
46 // | | | | |
47 // | | | | |
48 // | | error V | |
49 // | +---------<- kUpdatingDiff ->--------|-----------+ success
50 // | | |
51 // | error V |
52 // +----------------------------------------- kDownloading |
53 // | | |
54 // | error V |
55 // +------------------------------------------ kUpdating ->----+ success
56 //
57 // TODO(sorin): this data structure will be further refactored once
58 // the new update service is in place. For the time being, it remains as-is,
59 // since it is used by the old component update service.
60 struct CrxUpdateItem { 21 struct CrxUpdateItem {
61 enum class State { 22 CrxUpdateItem();
62 kNew, 23 CrxUpdateItem(const CrxUpdateItem& other);
63 kChecking, 24 ~CrxUpdateItem();
64 kCanUpdate,
65 kDownloadingDiff,
66 kDownloading,
67 kDownloaded,
68 kUpdatingDiff,
69 kUpdating,
70 kUpdated,
71 kUpToDate,
72 kNoUpdate,
73 kUninstalled,
74 kLastStatus
75 };
76 25
77 // Call CrxUpdateService::ChangeItemState to change |status|. The function may 26 ComponentState state;
78 // enforce conditions or notify observers of the change.
79 State state;
80 27
81 std::string id; 28 std::string id;
82 CrxComponent component; 29 CrxComponent component;
83 30
84 // Time when an update check for this CRX has happened. 31 // Time when an update check for this CRX has happened.
85 base::TimeTicks last_check; 32 base::TimeTicks last_check;
86 33
87 // Time when the update of this CRX has begun.
88 base::TimeTicks update_begin;
89
90 // A component can be made available for download from several urls.
91 std::vector<GURL> crx_urls;
92 std::vector<GURL> crx_diffurls;
93
94 // The cryptographic hash values for the component payload.
95 std::string hash_sha256;
96 std::string hashdiff_sha256;
97
98 // The from/to version and fingerprint values.
99 base::Version previous_version;
100 base::Version next_version; 34 base::Version next_version;
101 std::string previous_fp;
102 std::string next_fp; 35 std::string next_fp;
103
104 // True if the current update check cycle is on-demand.
105 bool on_demand;
106
107 // True if the differential update failed for any reason.
108 bool diff_update_failed;
109
110 // The error information for full and differential updates.
111 // The |error_category| contains a hint about which module in the component
112 // updater generated the error. The |error_code| constains the error and
113 // the |extra_code1| usually contains a system error, but it can contain
114 // any extended information that is relevant to either the category or the
115 // error itself.
116 int error_category;
117 int error_code;
118 int extra_code1;
119 int diff_error_category;
120 int diff_error_code;
121 int diff_extra_code1;
122
123 std::vector<CrxDownloader::DownloadMetrics> download_metrics;
124
125 CrxUpdateItem();
126 CrxUpdateItem(const CrxUpdateItem& other);
127 ~CrxUpdateItem();
128
129 // Function object used to find a specific component.
130 class FindById {
131 public:
132 explicit FindById(const std::string& id) : id_(id) {}
133
134 bool operator()(CrxUpdateItem* item) const { return item->id == id_; }
135
136 private:
137 const std::string& id_;
138 };
139 }; 36 };
140 37
141 using IdToCrxUpdateItemMap =
142 std::map<std::string, std::unique_ptr<CrxUpdateItem>>;
143
144 } // namespace update_client 38 } // namespace update_client
145 39
146 #endif // COMPONENTS_UPDATE_CLIENT_CRX_UPDATE_ITEM_H_ 40 #endif // COMPONENTS_UPDATE_CLIENT_CRX_UPDATE_ITEM_H_
OLDNEW
« no previous file with comments | « components/update_client/component.cc ('k') | components/update_client/ping_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698