blob: 794cfb719a084395148ffa309b1e1f870b563931 [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"
Darin Petkov6a5b3222010-07-13 14:55:28 -070010#include "update_engine/omaha_request_action.h"
adlr@google.com3defe6a2009-12-04 20:57:17 +000011
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;
Darin Petkov6a5b3222010-07-13 14:55:28 -070024 typedef OmahaRequestParams OutputObjectType;
adlr@google.com3defe6a2009-12-04 20:57:17 +000025};
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)
Andrew de los Reyes970bb282009-12-09 16:34:04 -080052 bool GetMachineId(std::string* out_id) const;
adlr@google.com3defe6a2009-12-04 20:57:17 +000053
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 .
Andrew de los Reyesf9714432010-05-04 10:21:23 -070057 std::string GetLsbValue(const std::string& key,
58 const std::string& default_value) const;
adlr@google.com3defe6a2009-12-04 20:57:17 +000059
60 // Gets the machine type (e.g. "i686")
61 std::string GetMachineType() const;
62
63 // Set to true if this should set up the Update Check Action to do
64 // a full update
65 bool force_full_update_;
66
67 // When reading files, prepend root_ to the paths. Useful for testing.
68 std::string root_;
69
70 DISALLOW_COPY_AND_ASSIGN(OmahaRequestPrepAction);
71};
72
73} // namespace chromeos_update_engine
74
75#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_RESQUEST_PREP_ACTION_H__