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 20 matching lines...) Expand all Loading... |
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 UPDATE_STATUS_REPORTING_ERROR_EVENT, |
34 }; | 34 }; |
35 | 35 |
36 const char* UpdateStatusToString(UpdateStatus status); | 36 const char* UpdateStatusToString(UpdateStatus status); |
37 | 37 |
38 class UpdateAttempter : public ActionProcessorDelegate, | 38 class UpdateAttempter : public ActionProcessorDelegate, |
39 public DownloadActionDelegate { | 39 public DownloadActionDelegate { |
40 public: | 40 public: |
41 UpdateAttempter(MetricsLibraryInterface* metrics_lib) | 41 UpdateAttempter(PrefsInterface* prefs, MetricsLibraryInterface* metrics_lib) |
42 : dbus_service_(NULL), | 42 : dbus_service_(NULL), |
| 43 prefs_(prefs), |
43 metrics_lib_(metrics_lib), | 44 metrics_lib_(metrics_lib), |
44 status_(UPDATE_STATUS_IDLE), | 45 status_(UPDATE_STATUS_IDLE), |
45 download_progress_(0.0), | 46 download_progress_(0.0), |
46 last_checked_time_(0), | 47 last_checked_time_(0), |
47 new_version_("0.0.0.0"), | 48 new_version_("0.0.0.0"), |
48 new_size_(0) { | 49 new_size_(0) { |
49 last_notify_time_.tv_sec = 0; | 50 last_notify_time_.tv_sec = 0; |
50 last_notify_time_.tv_nsec = 0; | 51 last_notify_time_.tv_nsec = 0; |
51 if (utils::FileExists(kUpdateCompletedMarker)) | 52 if (utils::FileExists(kUpdateCompletedMarker)) |
52 status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT; | 53 status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; | 114 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; |
114 ActionProcessor processor_; | 115 ActionProcessor processor_; |
115 | 116 |
116 // If non-null, this UpdateAttempter will send status updates over this | 117 // If non-null, this UpdateAttempter will send status updates over this |
117 // dbus service. | 118 // dbus service. |
118 UpdateEngineService* dbus_service_; | 119 UpdateEngineService* dbus_service_; |
119 | 120 |
120 // pointer to the OmahaResponseHandlerAction in the actions_ vector; | 121 // pointer to the OmahaResponseHandlerAction in the actions_ vector; |
121 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; | 122 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; |
122 | 123 |
| 124 // Pointer to the preferences store interface. |
| 125 PrefsInterface* prefs_; |
| 126 |
123 // Pointer to the UMA metrics collection library. | 127 // Pointer to the UMA metrics collection library. |
124 MetricsLibraryInterface* metrics_lib_; | 128 MetricsLibraryInterface* metrics_lib_; |
125 | 129 |
126 // Pending error event, if any. | 130 // Pending error event, if any. |
127 scoped_ptr<OmahaEvent> error_event_; | 131 scoped_ptr<OmahaEvent> error_event_; |
128 | 132 |
129 // For status: | 133 // For status: |
130 UpdateStatus status_; | 134 UpdateStatus status_; |
131 double download_progress_; | 135 double download_progress_; |
132 int64_t last_checked_time_; | 136 int64_t last_checked_time_; |
133 std::string new_version_; | 137 std::string new_version_; |
134 int64_t new_size_; | 138 int64_t new_size_; |
135 | 139 |
136 // Device paramaters common to all Omaha requests. | 140 // Device paramaters common to all Omaha requests. |
137 OmahaRequestDeviceParams omaha_request_params_; | 141 OmahaRequestDeviceParams omaha_request_params_; |
138 | 142 |
139 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); | 143 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); |
140 }; | 144 }; |
141 | 145 |
142 } // namespace chromeos_update_engine | 146 } // namespace chromeos_update_engine |
143 | 147 |
144 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ | 148 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ |
OLD | NEW |