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> |
11 #include <vector> | 11 #include <vector> |
12 #include <glib.h> | 12 #include <glib.h> |
13 #include "update_engine/action_processor.h" | 13 #include "update_engine/action_processor.h" |
14 #include "update_engine/download_action.h" | 14 #include "update_engine/download_action.h" |
15 #include "update_engine/omaha_request_params.h" | 15 #include "update_engine/omaha_request_params.h" |
16 #include "update_engine/omaha_response_handler_action.h" | 16 #include "update_engine/omaha_response_handler_action.h" |
17 | 17 |
| 18 class MetricsLibraryInterface; |
18 struct UpdateEngineService; | 19 struct UpdateEngineService; |
19 | 20 |
20 namespace chromeos_update_engine { | 21 namespace chromeos_update_engine { |
21 | 22 |
22 extern const char* kUpdateCompletedMarker; | 23 extern const char* kUpdateCompletedMarker; |
23 | 24 |
24 enum UpdateStatus { | 25 enum UpdateStatus { |
25 UPDATE_STATUS_IDLE = 0, | 26 UPDATE_STATUS_IDLE = 0, |
26 UPDATE_STATUS_CHECKING_FOR_UPDATE, | 27 UPDATE_STATUS_CHECKING_FOR_UPDATE, |
27 UPDATE_STATUS_UPDATE_AVAILABLE, | 28 UPDATE_STATUS_UPDATE_AVAILABLE, |
28 UPDATE_STATUS_DOWNLOADING, | 29 UPDATE_STATUS_DOWNLOADING, |
29 UPDATE_STATUS_VERIFYING, | 30 UPDATE_STATUS_VERIFYING, |
30 UPDATE_STATUS_FINALIZING, | 31 UPDATE_STATUS_FINALIZING, |
31 UPDATE_STATUS_UPDATED_NEED_REBOOT | 32 UPDATE_STATUS_UPDATED_NEED_REBOOT |
32 }; | 33 }; |
33 | 34 |
34 const char* UpdateStatusToString(UpdateStatus status); | 35 const char* UpdateStatusToString(UpdateStatus status); |
35 | 36 |
36 class UpdateAttempter : public ActionProcessorDelegate, | 37 class UpdateAttempter : public ActionProcessorDelegate, |
37 public DownloadActionDelegate { | 38 public DownloadActionDelegate { |
38 public: | 39 public: |
39 UpdateAttempter() : dbus_service_(NULL), | 40 UpdateAttempter(MetricsLibraryInterface* metrics_lib) |
40 status_(UPDATE_STATUS_IDLE), | 41 : dbus_service_(NULL), |
41 download_progress_(0.0), | 42 metrics_lib_(metrics_lib), |
42 last_checked_time_(0), | 43 status_(UPDATE_STATUS_IDLE), |
43 new_version_("0.0.0.0"), | 44 download_progress_(0.0), |
44 new_size_(0) { | 45 last_checked_time_(0), |
| 46 new_version_("0.0.0.0"), |
| 47 new_size_(0) { |
45 last_notify_time_.tv_sec = 0; | 48 last_notify_time_.tv_sec = 0; |
46 last_notify_time_.tv_nsec = 0; | 49 last_notify_time_.tv_nsec = 0; |
47 if (utils::FileExists(kUpdateCompletedMarker)) | 50 if (utils::FileExists(kUpdateCompletedMarker)) |
48 status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT; | 51 status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT; |
49 } | 52 } |
50 void Update(); | 53 void Update(); |
51 | 54 |
52 // ActionProcessorDelegate methods: | 55 // ActionProcessorDelegate methods: |
53 void ProcessingDone(const ActionProcessor* processor, ActionExitCode code); | 56 void ProcessingDone(const ActionProcessor* processor, ActionExitCode code); |
54 void ProcessingStopped(const ActionProcessor* processor); | 57 void ProcessingStopped(const ActionProcessor* processor); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; | 92 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; |
90 ActionProcessor processor_; | 93 ActionProcessor processor_; |
91 | 94 |
92 // If non-null, this UpdateAttempter will send status updates over this | 95 // If non-null, this UpdateAttempter will send status updates over this |
93 // dbus service. | 96 // dbus service. |
94 UpdateEngineService* dbus_service_; | 97 UpdateEngineService* dbus_service_; |
95 | 98 |
96 // pointer to the OmahaResponseHandlerAction in the actions_ vector; | 99 // pointer to the OmahaResponseHandlerAction in the actions_ vector; |
97 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; | 100 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; |
98 | 101 |
| 102 // Pointer to the UMA metrics collection library. |
| 103 MetricsLibraryInterface* metrics_lib_; |
| 104 |
99 // For status: | 105 // For status: |
100 UpdateStatus status_; | 106 UpdateStatus status_; |
101 double download_progress_; | 107 double download_progress_; |
102 int64_t last_checked_time_; | 108 int64_t last_checked_time_; |
103 std::string new_version_; | 109 std::string new_version_; |
104 int64_t new_size_; | 110 int64_t new_size_; |
105 | 111 |
106 // Device paramaters common to all Omaha requests. | 112 // Device paramaters common to all Omaha requests. |
107 OmahaRequestDeviceParams omaha_request_params_; | 113 OmahaRequestDeviceParams omaha_request_params_; |
108 | 114 |
109 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); | 115 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); |
110 }; | 116 }; |
111 | 117 |
112 } // namespace chromeos_update_engine | 118 } // namespace chromeos_update_engine |
113 | 119 |
114 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ | 120 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ |
OLD | NEW |