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

Side by Side Diff: update_attempter.h

Issue 3617002: AU: Fall back to full updates after a number of failed delta update attempts. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: remove leftover log Created 10 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « prefs_interface.h ('k') | update_attempter.cc » ('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 (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__
7 7
8 #include <time.h> 8 #include <time.h>
9 9
10 #include <tr1/memory> 10 #include <tr1/memory>
(...skipping 27 matching lines...) Expand all
38 UPDATE_STATUS_FINALIZING, 38 UPDATE_STATUS_FINALIZING,
39 UPDATE_STATUS_UPDATED_NEED_REBOOT, 39 UPDATE_STATUS_UPDATED_NEED_REBOOT,
40 UPDATE_STATUS_REPORTING_ERROR_EVENT, 40 UPDATE_STATUS_REPORTING_ERROR_EVENT,
41 }; 41 };
42 42
43 const char* UpdateStatusToString(UpdateStatus status); 43 const char* UpdateStatusToString(UpdateStatus status);
44 44
45 class UpdateAttempter : public ActionProcessorDelegate, 45 class UpdateAttempter : public ActionProcessorDelegate,
46 public DownloadActionDelegate { 46 public DownloadActionDelegate {
47 public: 47 public:
48 static const int kMaxDeltaUpdateFailures;
49
48 UpdateAttempter(PrefsInterface* prefs, MetricsLibraryInterface* metrics_lib); 50 UpdateAttempter(PrefsInterface* prefs, MetricsLibraryInterface* metrics_lib);
49 virtual ~UpdateAttempter(); 51 virtual ~UpdateAttempter();
50 52
51 // Checks for update and, if a newer version is available, attempts 53 // Checks for update and, if a newer version is available, attempts
52 // to update the system. Non-empty |in_app_version| or 54 // to update the system. Non-empty |in_app_version| or
53 // |in_update_url| prevents automatic detection of the parameter. 55 // |in_update_url| prevents automatic detection of the parameter.
54 virtual void Update(const std::string& app_version, 56 virtual void Update(const std::string& app_version,
55 const std::string& omaha_url); 57 const std::string& omaha_url);
56 58
57 // ActionProcessorDelegate methods: 59 // ActionProcessorDelegate methods:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Initiates a reboot if the current state is 101 // Initiates a reboot if the current state is
100 // UPDATED_NEED_REBOOT. Returns true on sucess, false otherwise. 102 // UPDATED_NEED_REBOOT. Returns true on sucess, false otherwise.
101 bool RebootIfNeeded(); 103 bool RebootIfNeeded();
102 104
103 // DownloadActionDelegate methods 105 // DownloadActionDelegate methods
104 void SetDownloadStatus(bool active); 106 void SetDownloadStatus(bool active);
105 void BytesReceived(uint64_t bytes_received, uint64_t total); 107 void BytesReceived(uint64_t bytes_received, uint64_t total);
106 108
107 private: 109 private:
108 friend class UpdateAttempterTest; 110 friend class UpdateAttempterTest;
111 FRIEND_TEST(UpdateAttempterTest, DisableDeltaUpdateIfNeededTest);
112 FRIEND_TEST(UpdateAttempterTest, MarkDeltaUpdateFailureTest);
109 FRIEND_TEST(UpdateAttempterTest, UpdateTest); 113 FRIEND_TEST(UpdateAttempterTest, UpdateTest);
110 114
111 // Sets the status to the given status and notifies a status update 115 // Sets the status to the given status and notifies a status update
112 // over dbus. 116 // over dbus.
113 void SetStatusAndNotify(UpdateStatus status); 117 void SetStatusAndNotify(UpdateStatus status);
114 118
115 // Creates an error event object in |error_event_| to be included in 119 // Creates an error event object in |error_event_| to be included in
116 // an OmahaRequestAction once the current action processor is done. 120 // an OmahaRequestAction once the current action processor is done.
117 void CreatePendingErrorEvent(AbstractAction* action, ActionExitCode code); 121 void CreatePendingErrorEvent(AbstractAction* action, ActionExitCode code);
118 122
(...skipping 16 matching lines...) Expand all
135 // timeout sources. 139 // timeout sources.
136 void CleanupPriorityManagement(); 140 void CleanupPriorityManagement();
137 141
138 // The process priority timeout source callback increases the 142 // The process priority timeout source callback increases the
139 // current priority by one step (low goes to normal, normal goes to 143 // current priority by one step (low goes to normal, normal goes to
140 // high). Returns true if the callback must be invoked again after a 144 // high). Returns true if the callback must be invoked again after a
141 // timeout, or false if GLib can destroy this timeout source. 145 // timeout, or false if GLib can destroy this timeout source.
142 static gboolean StaticManagePriorityCallback(gpointer data); 146 static gboolean StaticManagePriorityCallback(gpointer data);
143 bool ManagePriorityCallback(); 147 bool ManagePriorityCallback();
144 148
149 // Checks if a full update is needed and forces it by updating the Omaha
150 // request params.
151 void DisableDeltaUpdateIfNeeded();
152
153 // If this was a delta update attempt that failed, count it so that a full
154 // update can be tried when needed.
155 void MarkDeltaUpdateFailure();
156
145 // Last status notification timestamp used for throttling. Use 157 // Last status notification timestamp used for throttling. Use
146 // monotonic TimeTicks to ensure that notifications are sent even if 158 // monotonic TimeTicks to ensure that notifications are sent even if
147 // the system clock is set back in the middle of an update. 159 // the system clock is set back in the middle of an update.
148 base::TimeTicks last_notify_time_; 160 base::TimeTicks last_notify_time_;
149 161
150 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; 162 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_;
151 scoped_ptr<ActionProcessor> processor_; 163 scoped_ptr<ActionProcessor> processor_;
152 164
153 // If non-null, this UpdateAttempter will send status updates over this 165 // If non-null, this UpdateAttempter will send status updates over this
154 // dbus service. 166 // dbus service.
(...skipping 26 matching lines...) Expand all
181 // Set to true if an update download is active (and BytesReceived 193 // Set to true if an update download is active (and BytesReceived
182 // will be called), set to false otherwise. 194 // will be called), set to false otherwise.
183 bool download_active_; 195 bool download_active_;
184 196
185 // For status: 197 // For status:
186 UpdateStatus status_; 198 UpdateStatus status_;
187 double download_progress_; 199 double download_progress_;
188 int64_t last_checked_time_; 200 int64_t last_checked_time_;
189 std::string new_version_; 201 std::string new_version_;
190 int64_t new_size_; 202 int64_t new_size_;
203 bool is_full_update_;
191 204
192 // Device paramaters common to all Omaha requests. 205 // Device paramaters common to all Omaha requests.
193 OmahaRequestDeviceParams omaha_request_params_; 206 OmahaRequestDeviceParams omaha_request_params_;
194 207
195 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); 208 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter);
196 }; 209 };
197 210
198 } // namespace chromeos_update_engine 211 } // namespace chromeos_update_engine
199 212
200 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ 213 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__
OLDNEW
« no previous file with comments | « prefs_interface.h ('k') | update_attempter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698