Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 5 | #ifndef UPDATE_ENGINE_OMAHA_REQUEST_ACTION_H_ |
| 6 | #define UPDATE_ENGINE_OMAHA_REQUEST_ACTION_H_ |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 7 | |
Alex Vakulenko | 44cab30 | 2014-07-23 13:12:15 -0700 | [diff] [blame] | 8 | #include <fcntl.h> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 9 | #include <sys/stat.h> |
Andrew de los Reyes | 09e56d6 | 2010-04-23 13:45:53 -0700 | [diff] [blame] | 10 | #include <sys/types.h> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 11 | |
Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 12 | #include <memory> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 13 | #include <string> |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 14 | #include <vector> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 15 | |
| 16 | #include <curl/curl.h> |
| 17 | |
Andrew de los Reyes | 09e56d6 | 2010-04-23 13:45:53 -0700 | [diff] [blame] | 18 | #include "update_engine/action.h" |
| 19 | #include "update_engine/http_fetcher.h" |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 20 | #include "update_engine/omaha_response.h" |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 21 | |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 22 | // The Omaha Request action makes a request to Omaha and can output |
| 23 | // the response on the output ActionPipe. |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 24 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 25 | namespace chromeos_update_engine { |
| 26 | |
| 27 | // Encodes XML entities in a given string with libxml2. input must be |
| 28 | // UTF-8 formatted. Output will be UTF-8 formatted. |
| 29 | std::string XmlEncode(const std::string& input); |
| 30 | |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 31 | // This struct encapsulates the Omaha event information. For a |
| 32 | // complete list of defined event types and results, see |
| 33 | // http://code.google.com/p/omaha/wiki/ServerProtocol#event |
| 34 | struct OmahaEvent { |
Jay Srinivasan | 56d5aa4 | 2012-03-26 14:27:59 -0700 | [diff] [blame] | 35 | // The Type values correspond to EVENT_TYPE values of Omaha. |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 36 | enum Type { |
| 37 | kTypeUnknown = 0, |
| 38 | kTypeDownloadComplete = 1, |
| 39 | kTypeInstallComplete = 2, |
| 40 | kTypeUpdateComplete = 3, |
Darin Petkov | 8c2980e | 2010-07-16 15:16:49 -0700 | [diff] [blame] | 41 | kTypeUpdateDownloadStarted = 13, |
| 42 | kTypeUpdateDownloadFinished = 14, |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 43 | }; |
| 44 | |
Jay Srinivasan | 56d5aa4 | 2012-03-26 14:27:59 -0700 | [diff] [blame] | 45 | // The Result values correspond to EVENT_RESULT values of Omaha. |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 46 | enum Result { |
| 47 | kResultError = 0, |
| 48 | kResultSuccess = 1, |
Darin Petkov | 95508da | 2011-01-05 12:42:29 -0800 | [diff] [blame] | 49 | kResultSuccessReboot = 2, |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 50 | kResultUpdateDeferred = 9, // When we ignore/defer updates due to policy. |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | OmahaEvent() |
| 54 | : type(kTypeUnknown), |
| 55 | result(kResultError), |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 56 | error_code(ErrorCode::kError) {} |
Darin Petkov | e17f86b | 2010-07-20 09:12:01 -0700 | [diff] [blame] | 57 | explicit OmahaEvent(Type in_type) |
| 58 | : type(in_type), |
| 59 | result(kResultSuccess), |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 60 | error_code(ErrorCode::kSuccess) {} |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 61 | OmahaEvent(Type in_type, Result in_result, ErrorCode in_error_code) |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 62 | : type(in_type), |
| 63 | result(in_result), |
| 64 | error_code(in_error_code) {} |
| 65 | |
| 66 | Type type; |
| 67 | Result result; |
David Zeuthen | a99981f | 2013-04-29 13:42:47 -0700 | [diff] [blame] | 68 | ErrorCode error_code; |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 71 | class NoneType; |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 72 | class OmahaRequestAction; |
Yunlian Jiang | a178e5e | 2013-04-05 14:41:56 -0700 | [diff] [blame] | 73 | class OmahaRequestParams; |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 74 | class PrefsInterface; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 75 | |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 76 | // This struct is declared in the .cc file. |
| 77 | struct OmahaParserData; |
| 78 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 79 | template<> |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 80 | class ActionTraits<OmahaRequestAction> { |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 81 | public: |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 82 | // Takes parameters on the input pipe. |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 83 | typedef NoneType InputObjectType; |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 84 | // On UpdateCheck success, puts the Omaha response on output. Event |
| 85 | // requests do not have an output pipe. |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 86 | typedef OmahaResponse OutputObjectType; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 87 | }; |
| 88 | |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 89 | class OmahaRequestAction : public Action<OmahaRequestAction>, |
| 90 | public HttpFetcherDelegate { |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 91 | public: |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 92 | static const int kNeverPinged = -1; |
| 93 | static const int kPingTimeJump = -2; |
Jay Srinivasan | 2b5a0f0 | 2012-12-19 17:25:56 -0800 | [diff] [blame] | 94 | // We choose this value of 10 as a heuristic for a work day in trying |
| 95 | // each URL, assuming we check roughly every 45 mins. This is a good time to |
| 96 | // wait - neither too long nor too little - so we don't give up the preferred |
| 97 | // URLs that appear earlier in list too quickly before moving on to the |
| 98 | // fallback ones. |
| 99 | static const int kDefaultMaxFailureCountPerUrl = 10; |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 100 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 101 | // These are the possible outcome upon checking whether we satisfied |
| 102 | // the wall-clock-based-wait. |
| 103 | enum WallClockWaitResult { |
| 104 | kWallClockWaitNotSatisfied, |
| 105 | kWallClockWaitDoneButUpdateCheckWaitRequired, |
| 106 | kWallClockWaitDoneAndUpdateCheckWaitNotRequired, |
| 107 | }; |
| 108 | |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 109 | // The ctor takes in all the parameters that will be used for making |
| 110 | // the request to Omaha. For some of them we have constants that |
| 111 | // should be used. |
| 112 | // |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 113 | // Takes ownership of the passed in HttpFetcher. Useful for testing. |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 114 | // |
Alex Vakulenko | 88b591f | 2014-08-28 16:48:57 -0700 | [diff] [blame] | 115 | // Takes ownership of the passed in OmahaEvent. If |event| is null, |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 116 | // this is an UpdateCheck request, otherwise it's an Event request. |
| 117 | // Event requests always succeed. |
| 118 | // |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 119 | // A good calling pattern is: |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 120 | // OmahaRequestAction(..., new OmahaEvent(...), new WhateverHttpFetcher); |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 121 | // or |
Alex Vakulenko | 88b591f | 2014-08-28 16:48:57 -0700 | [diff] [blame] | 122 | // OmahaRequestAction(..., nullptr, new WhateverHttpFetcher); |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 123 | OmahaRequestAction(SystemState* system_state, |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 124 | OmahaEvent* event, |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 125 | HttpFetcher* http_fetcher, |
| 126 | bool ping_only); |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 127 | virtual ~OmahaRequestAction(); |
| 128 | typedef ActionTraits<OmahaRequestAction>::InputObjectType InputObjectType; |
| 129 | typedef ActionTraits<OmahaRequestAction>::OutputObjectType OutputObjectType; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 130 | void PerformAction(); |
| 131 | void TerminateProcessing(); |
David Zeuthen | 33bae49 | 2014-02-25 16:16:18 -0800 | [diff] [blame] | 132 | void ActionCompleted(ErrorCode code); |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 133 | |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 134 | int GetHTTPResponseCode() { return http_fetcher_->http_response_code(); } |
| 135 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 136 | // Debugging/logging |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 137 | static std::string StaticType() { return "OmahaRequestAction"; } |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 138 | std::string Type() const { return StaticType(); } |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 139 | |
| 140 | // Delegate methods (see http_fetcher.h) |
| 141 | virtual void ReceivedBytes(HttpFetcher *fetcher, |
| 142 | const char* bytes, int length); |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 143 | |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 144 | virtual void TransferComplete(HttpFetcher *fetcher, bool successful); |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 145 | // Returns true if this is an Event request, false if it's an UpdateCheck. |
Alex Vakulenko | 88b591f | 2014-08-28 16:48:57 -0700 | [diff] [blame] | 146 | bool IsEvent() const { return event_.get() != nullptr; } |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 147 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 148 | private: |
Alex Deymo | e1e3afe | 2014-10-30 13:02:49 -0700 | [diff] [blame^] | 149 | FRIEND_TEST(OmahaRequestActionTest, GetInstallDateWhenNoPrefsNorOOBE); |
| 150 | FRIEND_TEST(OmahaRequestActionTest, |
| 151 | GetInstallDateWhenOOBECompletedWithInvalidDate); |
| 152 | FRIEND_TEST(OmahaRequestActionTest, |
| 153 | GetInstallDateWhenOOBECompletedWithValidDate); |
| 154 | FRIEND_TEST(OmahaRequestActionTest, |
| 155 | GetInstallDateWhenOOBECompletedDateChanges); |
David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 156 | |
| 157 | // Enumeration used in PersistInstallDate(). |
| 158 | enum InstallDateProvisioningSource { |
| 159 | kProvisionedFromOmahaResponse, |
| 160 | kProvisionedFromOOBEMarker, |
| 161 | |
| 162 | // kProvisionedMax is the count of the number of enums above. Add |
| 163 | // any new enums above this line only. |
| 164 | kProvisionedMax |
| 165 | }; |
| 166 | |
| 167 | // Gets the install date, expressed as the number of PST8PDT |
| 168 | // calendar weeks since January 1st 2007, times seven. Returns -1 if |
| 169 | // unknown. See http://crbug.com/336838 for details about this value. |
| 170 | static int GetInstallDate(SystemState* system_state); |
| 171 | |
| 172 | // Parses the Omaha Response in |doc| and sets the |
| 173 | // |install_date_days| field of |output_object| to the value of the |
| 174 | // elapsed_days attribute of the daystart element. Returns True if |
| 175 | // the value was set, False if it wasn't found. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 176 | static bool ParseInstallDate(OmahaParserData* parser_data, |
David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 177 | OmahaResponse* output_object); |
| 178 | |
| 179 | // Returns True if the kPrefsInstallDateDays state variable is set, |
| 180 | // False otherwise. |
| 181 | static bool HasInstallDate(SystemState *system_state); |
| 182 | |
| 183 | // Writes |install_date_days| into the kPrefsInstallDateDays state |
| 184 | // variable and emits an UMA stat for the |source| used. Returns |
| 185 | // True if the value was written, False if an error occurred. |
| 186 | static bool PersistInstallDate(SystemState *system_state, |
| 187 | int install_date_days, |
| 188 | InstallDateProvisioningSource source); |
| 189 | |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 190 | // If this is an update check request, initializes |
| 191 | // |ping_active_days_| and |ping_roll_call_days_| to values that may |
| 192 | // be sent as pings to Omaha. |
| 193 | void InitPingDays(); |
| 194 | |
Darin Petkov | 84c763c | 2010-07-29 16:27:58 -0700 | [diff] [blame] | 195 | // Based on the persistent preference store values, calculates the |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 196 | // number of days since the last ping sent for |key|. |
| 197 | int CalculatePingDays(const std::string& key); |
| 198 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 199 | // Returns true if the download of a new update should be deferred. |
| 200 | // False if the update can be downloaded. |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 201 | bool ShouldDeferDownload(OmahaResponse* output_object); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 202 | |
| 203 | // Returns true if the basic wall-clock-based waiting period has been |
| 204 | // satisfied based on the scattering policy setting. False otherwise. |
| 205 | // If true, it also indicates whether the additional update-check-count-based |
| 206 | // waiting period also needs to be satisfied before the download can begin. |
| 207 | WallClockWaitResult IsWallClockBasedWaitingSatisfied( |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 208 | OmahaResponse* output_object); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 209 | |
| 210 | // Returns true if the update-check-count-based waiting period has been |
| 211 | // satisfied. False otherwise. |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 212 | bool IsUpdateCheckCountBasedWaitingSatisfied(); |
| 213 | |
| 214 | // Parses the response from Omaha that's available in |doc| using the other |
| 215 | // helper methods below and populates the |output_object| with the relevant |
| 216 | // values. Returns true if we should continue the parsing. False otherwise, |
| 217 | // in which case it sets any error code using |completer|. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 218 | bool ParseResponse(OmahaParserData* parser_data, |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 219 | OmahaResponse* output_object, |
| 220 | ScopedActionCompleter* completer); |
| 221 | |
| 222 | // Parses the status property in the given update_check_node and populates |
| 223 | // |output_object| if valid. Returns true if we should continue the parsing. |
| 224 | // False otherwise, in which case it sets any error code using |completer|. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 225 | bool ParseStatus(OmahaParserData* parser_data, |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 226 | OmahaResponse* output_object, |
| 227 | ScopedActionCompleter* completer); |
| 228 | |
| 229 | // Parses the URL nodes in the given XML document and populates |
| 230 | // |output_object| if valid. Returns true if we should continue the parsing. |
| 231 | // False otherwise, in which case it sets any error code using |completer|. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 232 | bool ParseUrls(OmahaParserData* parser_data, |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 233 | OmahaResponse* output_object, |
| 234 | ScopedActionCompleter* completer); |
| 235 | |
| 236 | // Parses the package node in the given XML document and populates |
| 237 | // |output_object| if valid. Returns true if we should continue the parsing. |
| 238 | // False otherwise, in which case it sets any error code using |completer|. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 239 | bool ParsePackage(OmahaParserData* parser_data, |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 240 | OmahaResponse* output_object, |
| 241 | ScopedActionCompleter* completer); |
| 242 | |
| 243 | // Parses the other parameters in the given XML document and populates |
| 244 | // |output_object| if valid. Returns true if we should continue the parsing. |
| 245 | // False otherwise, in which case it sets any error code using |completer|. |
David Zeuthen | e8ed863 | 2014-07-24 13:38:10 -0400 | [diff] [blame] | 246 | bool ParseParams(OmahaParserData* parser_data, |
Jay Srinivasan | 23b92a5 | 2012-10-27 02:00:21 -0700 | [diff] [blame] | 247 | OmahaResponse* output_object, |
| 248 | ScopedActionCompleter* completer); |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 249 | |
David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 250 | // Called by TransferComplete() to complete processing, either |
| 251 | // asynchronously after looking up resources via p2p or directly. |
| 252 | void CompleteProcessing(); |
| 253 | |
| 254 | // Helper to asynchronously look up payload on the LAN. |
| 255 | void LookupPayloadViaP2P(const OmahaResponse& response); |
| 256 | |
| 257 | // Callback used by LookupPayloadViaP2P(). |
| 258 | void OnLookupPayloadViaP2PCompleted(const std::string& url); |
| 259 | |
Chris Sosa | 77f79e8 | 2014-06-02 18:16:24 -0700 | [diff] [blame] | 260 | // Returns true if the current update should be ignored. |
| 261 | bool ShouldIgnoreUpdate(const OmahaResponse& response) const; |
| 262 | |
| 263 | // Returns true if updates are allowed over the current type of connection. |
| 264 | // False otherwise. |
| 265 | bool IsUpdateAllowedOverCurrentConnection() const; |
| 266 | |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 267 | // Global system context. |
| 268 | SystemState* system_state_; |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 269 | |
Jay Srinivasan | 480ddfa | 2012-06-01 19:15:26 -0700 | [diff] [blame] | 270 | // Contains state that is relevant in the processing of the Omaha request. |
| 271 | OmahaRequestParams* params_; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 272 | |
Alex Vakulenko | 88b591f | 2014-08-28 16:48:57 -0700 | [diff] [blame] | 273 | // Pointer to the OmahaEvent info. This is an UpdateCheck request if null. |
Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 274 | std::unique_ptr<OmahaEvent> event_; |
Darin Petkov | 0dc8e9a | 2010-07-14 14:51:57 -0700 | [diff] [blame] | 275 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 276 | // pointer to the HttpFetcher that does the http work |
Ben Chan | 02f7c1d | 2014-10-18 15:18:02 -0700 | [diff] [blame] | 277 | std::unique_ptr<HttpFetcher> http_fetcher_; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 278 | |
Thieu Le | 116fda3 | 2011-04-19 11:01:54 -0700 | [diff] [blame] | 279 | // If true, only include the <ping> element in the request. |
| 280 | bool ping_only_; |
| 281 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 282 | // Stores the response from the omaha server |
| 283 | std::vector<char> response_buffer_; |
| 284 | |
Darin Petkov | 1cbd78f | 2010-07-29 12:38:34 -0700 | [diff] [blame] | 285 | // Initialized by InitPingDays to values that may be sent to Omaha |
| 286 | // as part of a ping message. Note that only positive values and -1 |
| 287 | // are sent to Omaha. |
| 288 | int ping_active_days_; |
| 289 | int ping_roll_call_days_; |
| 290 | |
Darin Petkov | 6a5b322 | 2010-07-13 14:55:28 -0700 | [diff] [blame] | 291 | DISALLOW_COPY_AND_ASSIGN(OmahaRequestAction); |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 292 | }; |
| 293 | |
| 294 | } // namespace chromeos_update_engine |
| 295 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 296 | #endif // UPDATE_ENGINE_OMAHA_REQUEST_ACTION_H_ |