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

Side by Side Diff: omaha_request_action.cc

Issue 3022008: For actions, switch bool success into an exit code. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: switch to all positive error codes. Created 10 years, 5 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 | « integration_unittest.cc ('k') | omaha_request_action_unittest.cc » ('j') | no next file with comments »
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 #include "update_engine/omaha_request_action.h" 5 #include "update_engine/omaha_request_action.h"
6 #include <inttypes.h> 6 #include <inttypes.h>
7 #include <sstream> 7 #include <sstream>
8 8
9 #include <libxml/parser.h> 9 #include <libxml/parser.h>
10 #include <libxml/xpath.h> 10 #include <libxml/xpath.h>
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // the processor that we're done. 208 // the processor that we're done.
209 void OmahaRequestAction::TransferComplete(HttpFetcher *fetcher, 209 void OmahaRequestAction::TransferComplete(HttpFetcher *fetcher,
210 bool successful) { 210 bool successful) {
211 ScopedActionCompleter completer(processor_, this); 211 ScopedActionCompleter completer(processor_, this);
212 LOG(INFO) << "Omaha request response: " << string(response_buffer_.begin(), 212 LOG(INFO) << "Omaha request response: " << string(response_buffer_.begin(),
213 response_buffer_.end()); 213 response_buffer_.end());
214 214
215 // Events are best effort transactions -- assume they always succeed. 215 // Events are best effort transactions -- assume they always succeed.
216 if (IsEvent()) { 216 if (IsEvent()) {
217 CHECK(!HasOutputPipe()) << "No output pipe allowed for event requests."; 217 CHECK(!HasOutputPipe()) << "No output pipe allowed for event requests.";
218 completer.set_success(true); 218 completer.set_code(kActionCodeSuccess);
219 return; 219 return;
220 } 220 }
221 221
222 if (!successful) { 222 if (!successful) {
223 LOG(ERROR) << "Omaha request network transfer failed."; 223 LOG(ERROR) << "Omaha request network transfer failed.";
224 return; 224 return;
225 } 225 }
226 if (!HasOutputPipe()) { 226 if (!HasOutputPipe()) {
227 // Just set success to whether or not the http transfer succeeded, 227 // Just set success to whether or not the http transfer succeeded,
228 // which must be true at this point in the code. 228 // which must be true at this point in the code.
229 completer.set_success(true); 229 completer.set_code(kActionCodeSuccess);
230 return; 230 return;
231 } 231 }
232 232
233 // parse our response and fill the fields in the output object 233 // parse our response and fill the fields in the output object
234 scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> doc( 234 scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> doc(
235 xmlParseMemory(&response_buffer_[0], response_buffer_.size())); 235 xmlParseMemory(&response_buffer_[0], response_buffer_.size()));
236 if (!doc.get()) { 236 if (!doc.get()) {
237 LOG(ERROR) << "Omaha response not valid XML"; 237 LOG(ERROR) << "Omaha response not valid XML";
238 return; 238 return;
239 } 239 }
(...skipping 20 matching lines...) Expand all
260 LOG(ERROR) << "Response missing status"; 260 LOG(ERROR) << "Response missing status";
261 return; 261 return;
262 } 262 }
263 263
264 const string status(XmlGetProperty(updatecheck_node, "status")); 264 const string status(XmlGetProperty(updatecheck_node, "status"));
265 OmahaResponse output_object; 265 OmahaResponse output_object;
266 if (status == "noupdate") { 266 if (status == "noupdate") {
267 LOG(INFO) << "No update."; 267 LOG(INFO) << "No update.";
268 output_object.update_exists = false; 268 output_object.update_exists = false;
269 SetOutputObject(output_object); 269 SetOutputObject(output_object);
270 completer.set_success(true); 270 completer.set_code(kActionCodeSuccess);
271 return; 271 return;
272 } 272 }
273 273
274 if (status != "ok") { 274 if (status != "ok") {
275 LOG(ERROR) << "Unknown status: " << status; 275 LOG(ERROR) << "Unknown status: " << status;
276 return; 276 return;
277 } 277 }
278 278
279 // In best-effort fashion, fetch the rest of the expected attributes 279 // In best-effort fashion, fetch the rest of the expected attributes
280 // from the updatecheck node, then return the object 280 // from the updatecheck node, then return the object
281 output_object.update_exists = true; 281 output_object.update_exists = true;
282 completer.set_success(true); 282 completer.set_code(kActionCodeSuccess);
283 283
284 output_object.display_version = 284 output_object.display_version =
285 XmlGetProperty(updatecheck_node, "DisplayVersion"); 285 XmlGetProperty(updatecheck_node, "DisplayVersion");
286 output_object.codebase = XmlGetProperty(updatecheck_node, "codebase"); 286 output_object.codebase = XmlGetProperty(updatecheck_node, "codebase");
287 output_object.more_info_url = XmlGetProperty(updatecheck_node, "MoreInfo"); 287 output_object.more_info_url = XmlGetProperty(updatecheck_node, "MoreInfo");
288 output_object.hash = XmlGetProperty(updatecheck_node, "hash"); 288 output_object.hash = XmlGetProperty(updatecheck_node, "hash");
289 output_object.size = ParseInt(XmlGetProperty(updatecheck_node, "size")); 289 output_object.size = ParseInt(XmlGetProperty(updatecheck_node, "size"));
290 output_object.needs_admin = 290 output_object.needs_admin =
291 XmlGetProperty(updatecheck_node, "needsadmin") == "true"; 291 XmlGetProperty(updatecheck_node, "needsadmin") == "true";
292 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true"; 292 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true";
293 output_object.is_delta = 293 output_object.is_delta =
294 XmlGetProperty(updatecheck_node, "IsDelta") == "true"; 294 XmlGetProperty(updatecheck_node, "IsDelta") == "true";
295 SetOutputObject(output_object); 295 SetOutputObject(output_object);
296 return; 296 return;
297 } 297 }
298 298
299 }; // namespace chromeos_update_engine 299 }; // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « integration_unittest.cc ('k') | omaha_request_action_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698