OLD | NEW |
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 private: | 109 private: |
110 friend class UpdateAttempterTest; | 110 friend class UpdateAttempterTest; |
111 FRIEND_TEST(UpdateAttempterTest, DisableDeltaUpdateIfNeededTest); | 111 FRIEND_TEST(UpdateAttempterTest, DisableDeltaUpdateIfNeededTest); |
112 FRIEND_TEST(UpdateAttempterTest, MarkDeltaUpdateFailureTest); | 112 FRIEND_TEST(UpdateAttempterTest, MarkDeltaUpdateFailureTest); |
113 FRIEND_TEST(UpdateAttempterTest, UpdateTest); | 113 FRIEND_TEST(UpdateAttempterTest, UpdateTest); |
114 | 114 |
115 // 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 |
116 // over dbus. | 116 // over dbus. |
117 void SetStatusAndNotify(UpdateStatus status); | 117 void SetStatusAndNotify(UpdateStatus status); |
118 | 118 |
119 // Creates an error event object in |error_event_| to be included in | 119 // Sets up the download parameters after receiving the update check response. |
120 // an OmahaRequestAction once the current action processor is done. | 120 void SetupDownload(); |
| 121 |
| 122 // Creates an error event object in |error_event_| to be included in an |
| 123 // OmahaRequestAction once the current action processor is done. |
121 void CreatePendingErrorEvent(AbstractAction* action, ActionExitCode code); | 124 void CreatePendingErrorEvent(AbstractAction* action, ActionExitCode code); |
122 | 125 |
123 // If there's a pending error event allocated in |error_event_|, | 126 // If there's a pending error event allocated in |error_event_|, schedules an |
124 // schedules an OmahaRequestAction with that event in the current | 127 // OmahaRequestAction with that event in the current processor, clears the |
125 // processor, clears the pending event, updates the status and | 128 // pending event, updates the status and returns true. Returns false |
126 // returns true. Returns false otherwise. | 129 // otherwise. |
127 bool ScheduleErrorEventAction(); | 130 bool ScheduleErrorEventAction(); |
128 | 131 |
129 // Sets the process priority to |priority| and updates |priority_| | 132 // Sets the process priority to |priority| and updates |priority_| if the new |
130 // if the new |priority| is different than the current |priority_|, | 133 // |priority| is different than the current |priority_|, otherwise simply |
131 // otherwise simply returns. | 134 // returns. |
132 void SetPriority(utils::ProcessPriority priority); | 135 void SetPriority(utils::ProcessPriority priority); |
133 | 136 |
134 // Set the process priority to low and sets up timeout events to | 137 // Set the process priority to low and sets up timeout events to increase the |
135 // increase the priority gradually to high. | 138 // priority gradually to high. |
136 void SetupPriorityManagement(); | 139 void SetupPriorityManagement(); |
137 | 140 |
138 // Resets the process priority to normal and destroys any scheduled | 141 // Resets the process priority to normal and destroys any scheduled timeout |
139 // timeout sources. | 142 // sources. |
140 void CleanupPriorityManagement(); | 143 void CleanupPriorityManagement(); |
141 | 144 |
142 // The process priority timeout source callback increases the | 145 // The process priority timeout source callback increases the current priority |
143 // current priority by one step (low goes to normal, normal goes to | 146 // by one step (low goes to normal, normal goes to high). Returns true if the |
144 // high). Returns true if the callback must be invoked again after a | 147 // callback must be invoked again after a timeout, or false if GLib can |
145 // timeout, or false if GLib can destroy this timeout source. | 148 // destroy this timeout source. |
146 static gboolean StaticManagePriorityCallback(gpointer data); | 149 static gboolean StaticManagePriorityCallback(gpointer data); |
147 bool ManagePriorityCallback(); | 150 bool ManagePriorityCallback(); |
148 | 151 |
149 // Checks if a full update is needed and forces it by updating the Omaha | 152 // Checks if a full update is needed and forces it by updating the Omaha |
150 // request params. | 153 // request params. |
151 void DisableDeltaUpdateIfNeeded(); | 154 void DisableDeltaUpdateIfNeeded(); |
152 | 155 |
153 // If this was a delta update attempt that failed, count it so that a full | 156 // If this was a delta update attempt that failed, count it so that a full |
154 // update can be tried when needed. | 157 // update can be tried when needed. |
155 void MarkDeltaUpdateFailure(); | 158 void MarkDeltaUpdateFailure(); |
156 | 159 |
157 // Last status notification timestamp used for throttling. Use | 160 // Last status notification timestamp used for throttling. Use monotonic |
158 // monotonic TimeTicks to ensure that notifications are sent even if | 161 // TimeTicks to ensure that notifications are sent even if the system clock is |
159 // the system clock is set back in the middle of an update. | 162 // set back in the middle of an update. |
160 base::TimeTicks last_notify_time_; | 163 base::TimeTicks last_notify_time_; |
161 | 164 |
162 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; | 165 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; |
163 scoped_ptr<ActionProcessor> processor_; | 166 scoped_ptr<ActionProcessor> processor_; |
164 | 167 |
165 // If non-null, this UpdateAttempter will send status updates over this | 168 // If non-null, this UpdateAttempter will send status updates over this |
166 // dbus service. | 169 // dbus service. |
167 UpdateEngineService* dbus_service_; | 170 UpdateEngineService* dbus_service_; |
168 | 171 |
169 // pointer to the OmahaResponseHandlerAction in the actions_ vector; | 172 // Pointer to the OmahaResponseHandlerAction in the actions_ vector. |
170 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; | 173 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; |
171 | 174 |
| 175 // Pointer to the DownloadAction in the actions_ vector. |
| 176 std::tr1::shared_ptr<DownloadAction> download_action_; |
| 177 |
172 // Pointer to the preferences store interface. | 178 // Pointer to the preferences store interface. |
173 PrefsInterface* prefs_; | 179 PrefsInterface* prefs_; |
174 | 180 |
175 // Pointer to the UMA metrics collection library. | 181 // Pointer to the UMA metrics collection library. |
176 MetricsLibraryInterface* metrics_lib_; | 182 MetricsLibraryInterface* metrics_lib_; |
177 | 183 |
178 // The current UpdateCheckScheduler to notify of state transitions. | 184 // The current UpdateCheckScheduler to notify of state transitions. |
179 UpdateCheckScheduler* update_check_scheduler_; | 185 UpdateCheckScheduler* update_check_scheduler_; |
180 | 186 |
181 // Pending error event, if any. | 187 // Pending error event, if any. |
(...skipping 22 matching lines...) Expand all Loading... |
204 | 210 |
205 // Device paramaters common to all Omaha requests. | 211 // Device paramaters common to all Omaha requests. |
206 OmahaRequestDeviceParams omaha_request_params_; | 212 OmahaRequestDeviceParams omaha_request_params_; |
207 | 213 |
208 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); | 214 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); |
209 }; | 215 }; |
210 | 216 |
211 } // namespace chromeos_update_engine | 217 } // namespace chromeos_update_engine |
212 | 218 |
213 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ | 219 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ |
OLD | NEW |