Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: update_attempter.h

Issue 2836053: Turn OmahaRequestPrepAction into OmahaRequestDeviceParams. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Update copyrights. Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « omaha_request_prep_action.h ('k') | update_attempter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_response_handler_action.h" 16 #include "update_engine/omaha_response_handler_action.h"
16 17
17 struct UpdateEngineService; 18 struct UpdateEngineService;
18 19
19 namespace chromeos_update_engine { 20 namespace chromeos_update_engine {
20 21
21 extern const char* kUpdateCompletedMarker; 22 extern const char* kUpdateCompletedMarker;
22 23
23 enum UpdateStatus { 24 enum UpdateStatus {
24 UPDATE_STATUS_IDLE = 0, 25 UPDATE_STATUS_IDLE = 0,
25 UPDATE_STATUS_CHECKING_FOR_UPDATE, 26 UPDATE_STATUS_CHECKING_FOR_UPDATE,
26 UPDATE_STATUS_UPDATE_AVAILABLE, 27 UPDATE_STATUS_UPDATE_AVAILABLE,
27 UPDATE_STATUS_DOWNLOADING, 28 UPDATE_STATUS_DOWNLOADING,
28 UPDATE_STATUS_VERIFYING, 29 UPDATE_STATUS_VERIFYING,
29 UPDATE_STATUS_FINALIZING, 30 UPDATE_STATUS_FINALIZING,
30 UPDATE_STATUS_UPDATED_NEED_REBOOT 31 UPDATE_STATUS_UPDATED_NEED_REBOOT
31 }; 32 };
32 33
33 const char* UpdateStatusToString(UpdateStatus status); 34 const char* UpdateStatusToString(UpdateStatus status);
34 35
35 class UpdateAttempter : public ActionProcessorDelegate, 36 class UpdateAttempter : public ActionProcessorDelegate,
36 public DownloadActionDelegate { 37 public DownloadActionDelegate {
37 public: 38 public:
38 UpdateAttempter() : full_update_(false), 39 UpdateAttempter() : dbus_service_(NULL),
39 dbus_service_(NULL),
40 status_(UPDATE_STATUS_IDLE), 40 status_(UPDATE_STATUS_IDLE),
41 download_progress_(0.0), 41 download_progress_(0.0),
42 last_checked_time_(0), 42 last_checked_time_(0),
43 new_version_("0.0.0.0"), 43 new_version_("0.0.0.0"),
44 new_size_(0) { 44 new_size_(0) {
45 last_notify_time_.tv_sec = 0; 45 last_notify_time_.tv_sec = 0;
46 last_notify_time_.tv_nsec = 0; 46 last_notify_time_.tv_nsec = 0;
47 if (utils::FileExists(kUpdateCompletedMarker)) 47 if (utils::FileExists(kUpdateCompletedMarker))
48 status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT; 48 status_ = UPDATE_STATUS_UPDATED_NEED_REBOOT;
49 } 49 }
50 void Update(bool force_full_update); 50 void Update();
51 51
52 // ActionProcessorDelegate methods: 52 // ActionProcessorDelegate methods:
53 void ProcessingDone(const ActionProcessor* processor, bool success); 53 void ProcessingDone(const ActionProcessor* processor, bool success);
54 void ProcessingStopped(const ActionProcessor* processor); 54 void ProcessingStopped(const ActionProcessor* processor);
55 void ActionCompleted(ActionProcessor* processor, 55 void ActionCompleted(ActionProcessor* processor,
56 AbstractAction* action, 56 AbstractAction* action,
57 bool success); 57 bool success);
58 58
59 // Stop updating. An attempt will be made to record status to the disk 59 // Stop updating. An attempt will be made to record status to the disk
60 // so that updates can be resumed later. 60 // so that updates can be resumed later.
61 void Terminate(); 61 void Terminate();
62 62
63 // Try to resume from a previously Terminate()d update. 63 // Try to resume from a previously Terminate()d update.
64 void ResumeUpdating(); 64 void ResumeUpdating();
65 65
66 // Returns the current status in the out params. Returns true on success. 66 // Returns the current status in the out params. Returns true on success.
67 bool GetStatus(int64_t* last_checked_time, 67 bool GetStatus(int64_t* last_checked_time,
68 double* progress, 68 double* progress,
69 std::string* current_operation, 69 std::string* current_operation,
70 std::string* new_version, 70 std::string* new_version,
71 int64_t* new_size); 71 int64_t* new_size);
72 72
73 void set_dbus_service(struct UpdateEngineService* dbus_service) { 73 void set_dbus_service(struct UpdateEngineService* dbus_service) {
74 dbus_service_ = dbus_service; 74 dbus_service_ = dbus_service;
75 } 75 }
76 76
77 void CheckForUpdate(); 77 void CheckForUpdate();
78 78
79 // DownloadActionDelegate method 79 // DownloadActionDelegate method
80 void BytesReceived(uint64_t bytes_received, uint64_t total); 80 void BytesReceived(uint64_t bytes_received, uint64_t total);
81 81
82 private: 82 private:
83 // Sets the status to the given status and notifies a status update 83 // Sets the status to the given status and notifies a status update
84 // over dbus. 84 // over dbus.
85 void SetStatusAndNotify(UpdateStatus status); 85 void SetStatusAndNotify(UpdateStatus status);
86 86
87 struct timespec last_notify_time_; 87 struct timespec last_notify_time_;
88 88
89 bool full_update_;
90 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_; 89 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_;
91 ActionProcessor processor_; 90 ActionProcessor processor_;
92 91
93 // If non-null, this UpdateAttempter will send status updates over this 92 // If non-null, this UpdateAttempter will send status updates over this
94 // dbus service. 93 // dbus service.
95 UpdateEngineService* dbus_service_; 94 UpdateEngineService* dbus_service_;
96 95
97 // pointer to the OmahaResponseHandlerAction in the actions_ vector; 96 // pointer to the OmahaResponseHandlerAction in the actions_ vector;
98 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_; 97 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_;
99 98
100 // For status: 99 // For status:
101 UpdateStatus status_; 100 UpdateStatus status_;
102 double download_progress_; 101 double download_progress_;
103 int64_t last_checked_time_; 102 int64_t last_checked_time_;
104 std::string new_version_; 103 std::string new_version_;
105 int64_t new_size_; 104 int64_t new_size_;
106 105
106 // Device paramaters common to all Omaha requests.
107 OmahaRequestDeviceParams omaha_request_params_;
108
107 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter); 109 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter);
108 }; 110 };
109 111
110 } // namespace chromeos_update_engine 112 } // namespace chromeos_update_engine
111 113
112 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__ 114 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__
OLDNEW
« no previous file with comments | « omaha_request_prep_action.h ('k') | update_attempter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698