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

Unified Diff: src/platform/update_engine/update_attempter.h

Issue 2037002: AU: DBus support. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: fixes for review Created 10 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: src/platform/update_engine/update_attempter.h
diff --git a/src/platform/update_engine/update_attempter.h b/src/platform/update_engine/update_attempter.h
index 83e47376e5363d0a2ee75e3b995eb76f11abb273..76fe3fb4a4ddd6c7a13bfea41ebfc28151af766e 100644
--- a/src/platform/update_engine/update_attempter.h
+++ b/src/platform/update_engine/update_attempter.h
@@ -5,24 +5,52 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__
+#include <time.h>
#include <tr1/memory>
#include <string>
#include <vector>
#include <glib.h>
#include "update_engine/action_processor.h"
+#include "update_engine/download_action.h"
#include "update_engine/omaha_response_handler_action.h"
+struct UpdateEngineService;
+
namespace chromeos_update_engine {
-class UpdateAttempter : public ActionProcessorDelegate {
+enum UpdateStatus {
+ UPDATE_STATUS_IDLE = 0,
+ UPDATE_STATUS_CHECKING_FOR_UPDATE,
+ UPDATE_STATUS_UPDATE_AVAILABLE,
+ UPDATE_STATUS_DOWNLOADING,
+ UPDATE_STATUS_VERIFYING,
+ UPDATE_STATUS_FINALIZING,
+ UPDATE_STATUS_UPDATED_NEED_REBOOT
+};
+
+const char* UpdateStatusToString(UpdateStatus status);
+
+class UpdateAttempter : public ActionProcessorDelegate,
+ public DownloadActionDelegate {
public:
- explicit UpdateAttempter(GMainLoop *loop)
- : full_update_(false),
- loop_(loop) {}
+ UpdateAttempter() : full_update_(false),
+ dbus_service_(NULL),
+ status_(UPDATE_STATUS_IDLE),
+ download_progress_(0.0),
+ last_checked_time_(0),
+ new_version_("0.0.0.0"),
+ new_size_(0) {
+ last_notify_time_.tv_sec = 0;
+ last_notify_time_.tv_nsec = 0;
+ }
void Update(bool force_full_update);
- // Delegate method:
+ // ActionProcessorDelegate methods:
void ProcessingDone(const ActionProcessor* processor, bool success);
+ void ProcessingStopped(const ActionProcessor* processor);
+ void ActionCompleted(ActionProcessor* processor,
+ AbstractAction* action,
+ bool success);
// Stop updating. An attempt will be made to record status to the disk
// so that updates can be resumed later.
@@ -38,14 +66,40 @@ class UpdateAttempter : public ActionProcessorDelegate {
std::string* new_version,
int64_t* new_size);
+ void set_dbus_service(struct UpdateEngineService* dbus_service) {
+ dbus_service_ = dbus_service;
+ }
+
+ void CheckForUpdate();
+
+ // DownloadActionDelegate method
+ void BytesReceived(uint64_t bytes_received, uint64_t total);
+
private:
+ // Sets the status to the given status and notifies a status update
+ // over dbus.
+ void SetStatusAndNotify(UpdateStatus status);
+
+ struct timespec last_notify_time_;
+
bool full_update_;
std::vector<std::tr1::shared_ptr<AbstractAction> > actions_;
ActionProcessor processor_;
- GMainLoop *loop_;
+
+ // If non-null, this UpdateAttempter will send status updates over this
+ // dbus service.
+ UpdateEngineService* dbus_service_;
// pointer to the OmahaResponseHandlerAction in the actions_ vector;
std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_;
+
+ // For status:
+ UpdateStatus status_;
+ double download_progress_;
+ int64_t last_checked_time_;
+ std::string new_version_;
+ int64_t new_size_;
+
DISALLOW_COPY_AND_ASSIGN(UpdateAttempter);
};

Powered by Google App Engine
This is Rietveld 408576698