| 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 #include <tr1/memory> | 9 #include <tr1/memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 extern const char* kUpdateCompletedMarker; | 23 extern const char* kUpdateCompletedMarker; |
| 24 | 24 |
| 25 enum UpdateStatus { | 25 enum UpdateStatus { |
| 26 UPDATE_STATUS_IDLE = 0, | 26 UPDATE_STATUS_IDLE = 0, |
| 27 UPDATE_STATUS_CHECKING_FOR_UPDATE, | 27 UPDATE_STATUS_CHECKING_FOR_UPDATE, |
| 28 UPDATE_STATUS_UPDATE_AVAILABLE, | 28 UPDATE_STATUS_UPDATE_AVAILABLE, |
| 29 UPDATE_STATUS_DOWNLOADING, | 29 UPDATE_STATUS_DOWNLOADING, |
| 30 UPDATE_STATUS_VERIFYING, | 30 UPDATE_STATUS_VERIFYING, |
| 31 UPDATE_STATUS_FINALIZING, | 31 UPDATE_STATUS_FINALIZING, |
| 32 UPDATE_STATUS_UPDATED_NEED_REBOOT | 32 UPDATE_STATUS_UPDATED_NEED_REBOOT, |
| 33 UPDATE_STATUS_REPORTING_ERROR_EVENT, |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 const char* UpdateStatusToString(UpdateStatus status); | 36 const char* UpdateStatusToString(UpdateStatus status); |
| 36 | 37 |
| 37 class UpdateAttempter : public ActionProcessorDelegate, | 38 class UpdateAttempter : public ActionProcessorDelegate, |
| 38 public DownloadActionDelegate { | 39 public DownloadActionDelegate { |
| 39 public: | 40 public: |
| 40 UpdateAttempter(MetricsLibraryInterface* metrics_lib) | 41 UpdateAttempter(MetricsLibraryInterface* metrics_lib) |
| 41 : dbus_service_(NULL), | 42 : dbus_service_(NULL), |
| 42 metrics_lib_(metrics_lib), | 43 metrics_lib_(metrics_lib), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 void CheckForUpdate(); | 81 void CheckForUpdate(); |
| 81 | 82 |
| 82 // DownloadActionDelegate method | 83 // DownloadActionDelegate method |
| 83 void BytesReceived(uint64_t bytes_received, uint64_t total); | 84 void BytesReceived(uint64_t bytes_received, uint64_t total); |
| 84 | 85 |
| 85 private: | 86 private: |
| 86 // Sets the status to the given status and notifies a status update | 87 // Sets the status to the given status and notifies a status update |
| 87 // over dbus. | 88 // over dbus. |
| 88 void SetStatusAndNotify(UpdateStatus status); | 89 void SetStatusAndNotify(UpdateStatus status); |
| 89 | 90 |
| 91 // Creates an error event object in |error_event_| to be included in |
| 92 // an OmahaRequestAction once the current action processor is done. |
| 93 void CreatePendingErrorEvent(ActionExitCode code); |
| 94 |
| 95 // If there's a pending error event allocated in |error_event_|, |
| 96 // schedules an OmahaRequestAction with that event in the current |
| 97 // processor, clears the pending event, updates the status and |
| 98 // returns true. Returns false otherwise. |
| 99 bool ScheduleErrorEventAction(); |
| 100 |
| 90 struct timespec last_notify_time_; | 101 struct timespec last_notify_time_; |
| 91 | 102 |
| 92 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; | 103 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; |
| 93 ActionProcessor processor_; | 104 ActionProcessor processor_; |
| 94 | 105 |
| 95 // If non-null, this UpdateAttempter will send status updates over this | 106 // If non-null, this UpdateAttempter will send status updates over this |
| 96 // dbus service. | 107 // dbus service. |
| 97 UpdateEngineService* dbus_service_; | 108 UpdateEngineService* dbus_service_; |
| 98 | 109 |
| 99 // pointer to the OmahaResponseHandlerAction in the actions_ vector; | 110 // pointer to the OmahaResponseHandlerAction in the actions_ vector; |
| 100 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; | 111 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; |
| 101 | 112 |
| 102 // Pointer to the UMA metrics collection library. | 113 // Pointer to the UMA metrics collection library. |
| 103 MetricsLibraryInterface* metrics_lib_; | 114 MetricsLibraryInterface* metrics_lib_; |
| 104 | 115 |
| 116 // Pending error event, if any. |
| 117 scoped_ptr<OmahaEvent> error_event_; |
| 118 |
| 105 // For status: | 119 // For status: |
| 106 UpdateStatus status_; | 120 UpdateStatus status_; |
| 107 double download_progress_; | 121 double download_progress_; |
| 108 int64_t last_checked_time_; | 122 int64_t last_checked_time_; |
| 109 std::string new_version_; | 123 std::string new_version_; |
| 110 int64_t new_size_; | 124 int64_t new_size_; |
| 111 | 125 |
| 112 // Device paramaters common to all Omaha requests. | 126 // Device paramaters common to all Omaha requests. |
| 113 OmahaRequestDeviceParams omaha_request_params_; | 127 OmahaRequestDeviceParams omaha_request_params_; |
| 114 | 128 |
| 115 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); | 129 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); |
| 116 }; | 130 }; |
| 117 | 131 |
| 118 } // namespace chromeos_update_engine | 132 } // namespace chromeos_update_engine |
| 119 | 133 |
| 120 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ | 134 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ |
| OLD | NEW |