blob: 1169af99d5b0939c560bb5aabf82697e09451684 [file] [log] [blame]
adlr@google.com3defe6a2009-12-04 20:57:17 +00001// Copyright (c) 2009 The Chromium 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_POSTINSTALL_RUNNER_ACTION_H__
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H__
7
8#include <string>
9#include "update_engine/action.h"
Andrew de los Reyesf9714432010-05-04 10:21:23 -070010#include "update_engine/install_plan.h"
adlr@google.com3defe6a2009-12-04 20:57:17 +000011
12// The Postinstall Runner Action is responsible for running the postinstall
13// script of a successfully downloaded update.
14
15namespace chromeos_update_engine {
16
17class PostinstallRunnerAction;
18class NoneType;
19
20template<>
21class ActionTraits<PostinstallRunnerAction> {
22 public:
23 // Takes the device path as input
Andrew de los Reyesf9714432010-05-04 10:21:23 -070024 typedef InstallPlan InputObjectType;
adlr@google.com3defe6a2009-12-04 20:57:17 +000025 // Passes the device path as output
Andrew de los Reyesf9714432010-05-04 10:21:23 -070026 typedef InstallPlan OutputObjectType;
adlr@google.com3defe6a2009-12-04 20:57:17 +000027};
28
29class PostinstallRunnerAction : public Action<PostinstallRunnerAction> {
30 public:
Andrew de los Reyesf9714432010-05-04 10:21:23 -070031 explicit PostinstallRunnerAction(bool precommit) : precommit_(precommit) {}
adlr@google.com3defe6a2009-12-04 20:57:17 +000032 typedef ActionTraits<PostinstallRunnerAction>::InputObjectType
33 InputObjectType;
34 typedef ActionTraits<PostinstallRunnerAction>::OutputObjectType
35 OutputObjectType;
36 void PerformAction();
37
38 // This is a synchronous action, and thus TerminateProcessing() should
39 // never be called
40 void TerminateProcessing() { CHECK(false); }
41
42 // Debugging/logging
43 static std::string StaticType() { return "PostinstallRunnerAction"; }
44 std::string Type() const { return StaticType(); }
45
46 private:
Andrew de los Reyesf9714432010-05-04 10:21:23 -070047 // If true, this action runs before we've committed to the new update
48 // (by marking it as bootable in the partition table).
49 bool precommit_;
50
adlr@google.com3defe6a2009-12-04 20:57:17 +000051 DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction);
52};
53
54} // namespace chromeos_update_engine
55
56#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H__