blob: 178513823e5fa9ad81bf08858f3e89416bf00b76 [file] [log] [blame]
Darin Petkov73058b42010-10-06 16:32:19 -07001// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
adlr@google.com3defe6a2009-12-04 20:57:17 +00002// 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_OMAHA_RESPONSE_HANDLER_ACTION_H__
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_RESPONSE_HANDLER_ACTION_H__
7
8#include <string>
9#include "update_engine/action.h"
10#include "update_engine/install_plan.h"
Darin Petkov6a5b3222010-07-13 14:55:28 -070011#include "update_engine/omaha_request_action.h"
adlr@google.com3defe6a2009-12-04 20:57:17 +000012
13// This class reads in an Omaha response and converts what it sees into
14// an install plan which is passed out.
15
16namespace chromeos_update_engine {
17
18class OmahaResponseHandlerAction;
Darin Petkov73058b42010-10-06 16:32:19 -070019class PrefsInterface;
adlr@google.com3defe6a2009-12-04 20:57:17 +000020
21template<>
22class ActionTraits<OmahaResponseHandlerAction> {
23 public:
Darin Petkov6a5b3222010-07-13 14:55:28 -070024 typedef OmahaResponse InputObjectType;
adlr@google.com3defe6a2009-12-04 20:57:17 +000025 typedef InstallPlan OutputObjectType;
26};
27
28class OmahaResponseHandlerAction : public Action<OmahaResponseHandlerAction> {
29 public:
Darin Petkov6c118642010-10-21 12:06:30 -070030 static const char kDeadlineFile[];
31
Darin Petkovabc7bc02011-02-23 14:39:43 -080032 OmahaResponseHandlerAction(PrefsInterface* prefs);
adlr@google.com3defe6a2009-12-04 20:57:17 +000033 typedef ActionTraits<OmahaResponseHandlerAction>::InputObjectType
34 InputObjectType;
35 typedef ActionTraits<OmahaResponseHandlerAction>::OutputObjectType
36 OutputObjectType;
37 void PerformAction();
38
39 // This is a synchronous action, and thus TerminateProcessing() should
40 // never be called
41 void TerminateProcessing() { CHECK(false); }
42
43 // For unit-testing
44 void set_boot_device(const std::string& boot_device) {
45 boot_device_ = boot_device;
46 }
Darin Petkov6a5b3222010-07-13 14:55:28 -070047
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -080048 bool GotNoUpdateResponse() const { return got_no_update_response_; }
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070049 const InstallPlan& install_plan() const { return install_plan_; }
adlr@google.com3defe6a2009-12-04 20:57:17 +000050
51 // Debugging/logging
52 static std::string StaticType() { return "OmahaResponseHandlerAction"; }
53 std::string Type() const { return StaticType(); }
Darin Petkovabc7bc02011-02-23 14:39:43 -080054 void set_key_path(const std::string& path) { key_path_ = path; }
adlr@google.com3defe6a2009-12-04 20:57:17 +000055
56 private:
57 // Assumes you want to install on the "other" device, where the other
58 // device is what you get if you swap 1 for 2 or 3 for 4 or vice versa
59 // for the number at the end of the boot device. E.g., /dev/sda1 -> /dev/sda2
60 // or /dev/sda4 -> /dev/sda3
61 static bool GetInstallDev(const std::string& boot_dev,
62 std::string* install_dev);
63
Darin Petkov73058b42010-10-06 16:32:19 -070064 // Update Engine preference store.
65 PrefsInterface* prefs_;
66
adlr@google.com3defe6a2009-12-04 20:57:17 +000067 // set to non-empty in unit tests
68 std::string boot_device_;
Darin Petkov6a5b3222010-07-13 14:55:28 -070069
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070070 // The install plan, if we have an update.
71 InstallPlan install_plan_;
Darin Petkov6a5b3222010-07-13 14:55:28 -070072
Andrew de los Reyes4fe15d02009-12-10 19:01:36 -080073 // True only if we got a response and the response said no updates
74 bool got_no_update_response_;
adlr@google.com3defe6a2009-12-04 20:57:17 +000075
Darin Petkovabc7bc02011-02-23 14:39:43 -080076 // Public key path to use for payload verification.
77 std::string key_path_;
78
adlr@google.com3defe6a2009-12-04 20:57:17 +000079 DISALLOW_COPY_AND_ASSIGN(OmahaResponseHandlerAction);
80};
81
82} // namespace chromeos_update_engine
83
84#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_RESPONSE_HANDLER_ACTION_H__