| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include <glib.h> | 14 #include <glib.h> |
| 15 #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| 15 | 16 |
| 16 #include "base/time.h" | 17 #include "base/time.h" |
| 17 #include "update_engine/action_processor.h" | 18 #include "update_engine/action_processor.h" |
| 18 #include "update_engine/download_action.h" | 19 #include "update_engine/download_action.h" |
| 19 #include "update_engine/omaha_request_params.h" | 20 #include "update_engine/omaha_request_params.h" |
| 20 #include "update_engine/omaha_response_handler_action.h" | 21 #include "update_engine/omaha_response_handler_action.h" |
| 21 | 22 |
| 22 class MetricsLibraryInterface; | 23 class MetricsLibraryInterface; |
| 23 struct UpdateEngineService; | 24 struct UpdateEngineService; |
| 24 | 25 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 98 |
| 98 // Initiates a reboot if the current state is | 99 // Initiates a reboot if the current state is |
| 99 // UPDATED_NEED_REBOOT. Returns true on sucess, false otherwise. | 100 // UPDATED_NEED_REBOOT. Returns true on sucess, false otherwise. |
| 100 bool RebootIfNeeded(); | 101 bool RebootIfNeeded(); |
| 101 | 102 |
| 102 // DownloadActionDelegate methods | 103 // DownloadActionDelegate methods |
| 103 void SetDownloadStatus(bool active); | 104 void SetDownloadStatus(bool active); |
| 104 void BytesReceived(uint64_t bytes_received, uint64_t total); | 105 void BytesReceived(uint64_t bytes_received, uint64_t total); |
| 105 | 106 |
| 106 private: | 107 private: |
| 108 friend class UpdateAttempterTest; |
| 109 FRIEND_TEST(UpdateAttempterTest, UpdateTest); |
| 110 |
| 107 // Sets the status to the given status and notifies a status update | 111 // Sets the status to the given status and notifies a status update |
| 108 // over dbus. | 112 // over dbus. |
| 109 void SetStatusAndNotify(UpdateStatus status); | 113 void SetStatusAndNotify(UpdateStatus status); |
| 110 | 114 |
| 111 // Creates an error event object in |error_event_| to be included in | 115 // Creates an error event object in |error_event_| to be included in |
| 112 // an OmahaRequestAction once the current action processor is done. | 116 // an OmahaRequestAction once the current action processor is done. |
| 113 void CreatePendingErrorEvent(AbstractAction* action, ActionExitCode code); | 117 void CreatePendingErrorEvent(AbstractAction* action, ActionExitCode code); |
| 114 | 118 |
| 115 // If there's a pending error event allocated in |error_event_|, | 119 // If there's a pending error event allocated in |error_event_|, |
| 116 // schedules an OmahaRequestAction with that event in the current | 120 // schedules an OmahaRequestAction with that event in the current |
| (...skipping 20 matching lines...) Expand all Loading... |
| 137 // timeout, or false if GLib can destroy this timeout source. | 141 // timeout, or false if GLib can destroy this timeout source. |
| 138 static gboolean StaticManagePriorityCallback(gpointer data); | 142 static gboolean StaticManagePriorityCallback(gpointer data); |
| 139 bool ManagePriorityCallback(); | 143 bool ManagePriorityCallback(); |
| 140 | 144 |
| 141 // Last status notification timestamp used for throttling. Use | 145 // Last status notification timestamp used for throttling. Use |
| 142 // monotonic TimeTicks to ensure that notifications are sent even if | 146 // monotonic TimeTicks to ensure that notifications are sent even if |
| 143 // the system clock is set back in the middle of an update. | 147 // the system clock is set back in the middle of an update. |
| 144 base::TimeTicks last_notify_time_; | 148 base::TimeTicks last_notify_time_; |
| 145 | 149 |
| 146 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; | 150 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; |
| 147 ActionProcessor processor_; | 151 scoped_ptr<ActionProcessor> processor_; |
| 148 | 152 |
| 149 // If non-null, this UpdateAttempter will send status updates over this | 153 // If non-null, this UpdateAttempter will send status updates over this |
| 150 // dbus service. | 154 // dbus service. |
| 151 UpdateEngineService* dbus_service_; | 155 UpdateEngineService* dbus_service_; |
| 152 | 156 |
| 153 // pointer to the OmahaResponseHandlerAction in the actions_ vector; | 157 // pointer to the OmahaResponseHandlerAction in the actions_ vector; |
| 154 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; | 158 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; |
| 155 | 159 |
| 156 // Pointer to the preferences store interface. | 160 // Pointer to the preferences store interface. |
| 157 PrefsInterface* prefs_; | 161 PrefsInterface* prefs_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 186 | 190 |
| 187 // Device paramaters common to all Omaha requests. | 191 // Device paramaters common to all Omaha requests. |
| 188 OmahaRequestDeviceParams omaha_request_params_; | 192 OmahaRequestDeviceParams omaha_request_params_; |
| 189 | 193 |
| 190 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); | 194 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); |
| 191 }; | 195 }; |
| 192 | 196 |
| 193 } // namespace chromeos_update_engine | 197 } // namespace chromeos_update_engine |
| 194 | 198 |
| 195 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ | 199 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ |
| OLD | NEW |