OLD | NEW |
| (Empty) |
1 // 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/omaha_request_action.h" | |
11 | |
12 // This gathers local system information and prepares info used by the | |
13 // update check action. | |
14 | |
15 namespace chromeos_update_engine { | |
16 | |
17 class OmahaRequestPrepAction; | |
18 class NoneType; | |
19 | |
20 template<> | |
21 class ActionTraits<OmahaRequestPrepAction> { | |
22 public: | |
23 typedef NoneType InputObjectType; | |
24 typedef OmahaRequestParams OutputObjectType; | |
25 }; | |
26 | |
27 class 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 bool GetMachineId(std::string* out_id) 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, | |
58 const std::string& default_value) const; | |
59 | |
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__ | |
OLD | NEW |