blob: 83e47376e5363d0a2ee75e3b995eb76f11abb273 [file] [log] [blame]
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -07001// 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
3// found in the LICENSE file.
4
5#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__
7
8#include <tr1/memory>
9#include <string>
10#include <vector>
11#include <glib.h>
12#include "update_engine/action_processor.h"
13#include "update_engine/omaha_response_handler_action.h"
14
15namespace chromeos_update_engine {
16
17class UpdateAttempter : public ActionProcessorDelegate {
18 public:
19 explicit UpdateAttempter(GMainLoop *loop)
20 : full_update_(false),
21 loop_(loop) {}
22 void Update(bool force_full_update);
23
24 // Delegate method:
25 void ProcessingDone(const ActionProcessor* processor, bool success);
26
27 // Stop updating. An attempt will be made to record status to the disk
28 // so that updates can be resumed later.
29 void Terminate();
30
31 // Try to resume from a previously Terminate()d update.
32 void ResumeUpdating();
33
34 // Returns the current status in the out params. Returns true on success.
35 bool GetStatus(int64_t* last_checked_time,
36 double* progress,
37 std::string* current_operation,
38 std::string* new_version,
39 int64_t* new_size);
40
41 private:
42 bool full_update_;
43 std::vector<std::tr1::shared_ptr<AbstractAction> > actions_;
44 ActionProcessor processor_;
45 GMainLoop *loop_;
46
47 // pointer to the OmahaResponseHandlerAction in the actions_ vector;
48 std::tr1::shared_ptr<OmahaResponseHandlerAction> response_handler_action_;
49 DISALLOW_COPY_AND_ASSIGN(UpdateAttempter);
50};
51
52} // namespace chromeos_update_engine
53
54#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_ATTEMPTER_H__