Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: omaha_request_params.h

Issue 6225001: AU: Don't allow stateful /etc/lsb-release override in normal boot mode... (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | omaha_request_params.cc » ('j') | omaha_request_params.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__
7 7
8 #include <string> 8 #include <string>
9 9
10 #include <base/basictypes.h> 10 #include <base/basictypes.h>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 // Returns the release track. On error, returns an empty string. 83 // Returns the release track. On error, returns an empty string.
84 static std::string GetDeviceTrack(); 84 static std::string GetDeviceTrack();
85 85
86 // For unit-tests. 86 // For unit-tests.
87 void set_root(const std::string& root) { root_ = root; } 87 void set_root(const std::string& root) { root_ = root; }
88 88
89 // Force build type for testing purposes. 89 // Force build type for testing purposes.
90 void SetBuildTypeOfficial(bool is_official); 90 void SetBuildTypeOfficial(bool is_official);
91 91
92 // Force boot mode for testing purposes.
93 void SetBootModeNormal(bool is_normal);
94
92 private: 95 private:
93 FRIEND_TEST(OmahaRequestDeviceParamsTest, IsValidTrackTest); 96 FRIEND_TEST(OmahaRequestDeviceParamsTest, IsValidTrackTest);
94 97
95 // Use a validator that is a non-static member of this class so that its 98 // Use a validator that is a non-static member of this class so that its
96 // inputs can be mocked in unit tests (e.g., build type for IsValidTrack). 99 // inputs can be mocked in unit tests (e.g., build type for IsValidTrack).
97 typedef bool(OmahaRequestDeviceParams::*ValueValidator)( 100 typedef bool(OmahaRequestDeviceParams::*ValueValidator)(
98 const std::string&) const; 101 const std::string&) const;
99 102
100 // Returns true if this is an official build, false otherwise. 103 // Returns true if this is an official build, false otherwise.
101 bool IsOfficialBuild() const; 104 bool IsOfficialBuild() const;
102 105
106 // Returns true if the current boot mode is normal, false other (e.g. dev or
107 // recovery mode).
108 bool IsNormalBootMode() const;
109
103 // Returns true if |track| is a valid track, false otherwise. This method 110 // Returns true if |track| is a valid track, false otherwise. This method
104 // restricts the track value only if the image is official (see 111 // restricts the track value only if the image is official (see
105 // IsOfficialBuild). 112 // IsOfficialBuild).
106 bool IsValidTrack(const std::string& track) const; 113 bool IsValidTrack(const std::string& track) const;
107 114
108 // Fetches the value for a given key from 115 // Fetches the value for a given key from
109 // /mnt/stateful_partition/etc/lsb-release if possible and |stateful_override| 116 // /mnt/stateful_partition/etc/lsb-release if possible and |stateful_override|
110 // is true. Failing that, it looks for the key in /etc/lsb-release. If 117 // is true. Failing that, it looks for the key in /etc/lsb-release. If
111 // |validator| is non-NULL, uses it to validate and ignore invalid valies. 118 // |validator| is non-NULL, uses it to validate and ignore invalid valies.
112 std::string GetLsbValue(const std::string& key, 119 std::string GetLsbValue(const std::string& key,
113 const std::string& default_value, 120 const std::string& default_value,
114 ValueValidator validator, 121 ValueValidator validator,
115 bool stateful_override) const; 122 bool stateful_override) const;
116 123
117 // Gets the machine type (e.g. "i686"). 124 // Gets the machine type (e.g. "i686").
118 std::string GetMachineType() const; 125 std::string GetMachineType() const;
119 126
120 // Returns the hardware qualification ID of the system, or empty 127 // Returns the hardware qualification ID of the system, or empty
121 // string if the HWID is unavailable. 128 // string if the HWID is unavailable.
122 std::string GetHardwareClass() const; 129 std::string GetHardwareClass() const;
123 130
124 // When reading files, prepend root_ to the paths. Useful for testing. 131 // When reading files, prepend root_ to the paths. Useful for testing.
125 std::string root_; 132 std::string root_;
126 133
127 // Force build type for testing purposes. 134 // Force build type for testing purposes.
128 bool force_build_type_; 135 bool force_build_type_;
129 bool forced_official_build_; 136 bool forced_official_build_;
130 137
138 // Force boot mode for testing purposes.
139 bool force_boot_mode_;
140 bool forced_normal_boot_;
141
131 DISALLOW_COPY_AND_ASSIGN(OmahaRequestDeviceParams); 142 DISALLOW_COPY_AND_ASSIGN(OmahaRequestDeviceParams);
132 }; 143 };
133 144
134 } // namespace chromeos_update_engine 145 } // namespace chromeos_update_engine
135 146
136 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__ 147 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_OMAHA_REQUEST_PARAMS_H__
OLDNEW
« no previous file with comments | « no previous file | omaha_request_params.cc » ('j') | omaha_request_params.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698