blob: ca7fd178a53fc8b14eedeb3702c2e61de689d91a [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_OMAHA_RESQUEST_PREP_ACTION_H__
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_RESQUEST_PREP_ACTION_H__
7
8#include <string>
9#include "update_engine/action.h"
10#include "update_engine/update_check_action.h"
11
12// This gathers local system information and prepares info used by the
13// update check action.
14
15namespace chromeos_update_engine {
16
17class OmahaRequestPrepAction;
18class NoneType;
19
20template<>
21class ActionTraits<OmahaRequestPrepAction> {
22 public:
23 typedef NoneType InputObjectType;
24 typedef UpdateCheckParams OutputObjectType;
25};
26
27class OmahaRequestPrepAction : public Action<OmahaRequestPrepAction> {
28 public:
29 explicit OmahaRequestPrepAction(bool force_full_update)
30 : force_full_update_(force_full_update) {}
31 typedef ActionTraits<OmahaRequestPrepAction>::InputObjectType
32 InputObjectType;
33 typedef ActionTraits<OmahaRequestPrepAction>::OutputObjectType
34 OutputObjectType;
35 void PerformAction();
36
37 // This is a synchronous action, and thus TerminateProcessing() should
38 // never be called
39 void TerminateProcessing() { CHECK(false); }
40
41 // Debugging/logging
42 static std::string StaticType() { return "OmahaRequestPrepAction"; }
43 std::string Type() const { return StaticType(); }
44
45 // For unit-tests.
46 void set_root(const std::string& root) {
47 root_ = root;
48 }
49
50 private:
51 // Gets a machine-local ID (for now, first MAC address we find)
52 std::string GetMachineId() const;
53
54 // Fetches the value for a given key from
55 // /mnt/stateful_partition/etc/lsb-release if possible. Failing that,
56 // it looks for the key in /etc/lsb-release .
57 std::string GetLsbValue(const std::string& key) const;
58
59 // Gets the machine type (e.g. "i686")
60 std::string GetMachineType() const;
61
62 // Set to true if this should set up the Update Check Action to do
63 // a full update
64 bool force_full_update_;
65
66 // When reading files, prepend root_ to the paths. Useful for testing.
67 std::string root_;
68
69 DISALLOW_COPY_AND_ASSIGN(OmahaRequestPrepAction);
70};
71
72} // namespace chromeos_update_engine
73
74#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_RESQUEST_PREP_ACTION_H__