OLD | NEW |
---|---|
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 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 | 8 |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 | 334 |
335 // If the transfer was successful, this uses libxml2 to parse the response | 335 // If the transfer was successful, this uses libxml2 to parse the response |
336 // and fill in the appropriate fields of the output object. Also, notifies | 336 // and fill in the appropriate fields of the output object. Also, notifies |
337 // the processor that we're done. | 337 // the processor that we're done. |
338 void OmahaRequestAction::TransferComplete(HttpFetcher *fetcher, | 338 void OmahaRequestAction::TransferComplete(HttpFetcher *fetcher, |
339 bool successful) { | 339 bool successful) { |
340 ScopedActionCompleter completer(processor_, this); | 340 ScopedActionCompleter completer(processor_, this); |
341 LOG(INFO) << "Omaha request response: " << string(response_buffer_.begin(), | 341 LOG(INFO) << "Omaha request response: " << string(response_buffer_.begin(), |
342 response_buffer_.end()); | 342 response_buffer_.end()); |
343 | 343 |
344 // Events are best effort transactions -- assume they always succeed. | |
345 if (IsEvent()) { | |
346 CHECK(!HasOutputPipe()) << "No output pipe allowed for event requests."; | |
347 completer.set_code(kActionCodeSuccess); | |
petkov
2011/01/12 01:10:22
Here you could:
if (event->result ==
OmahaEvent::
petkov
2011/01/12 01:17:08
Of course I meant:
if (event->result == OmahaEven
| |
348 return; | |
349 } | |
350 | |
351 if (!successful) { | 344 if (!successful) { |
352 LOG(ERROR) << "Omaha request network transfer failed."; | 345 LOG(ERROR) << "Omaha request network transfer failed."; |
353 int code = GetHTTPResponseCode(); | 346 int code = GetHTTPResponseCode(); |
354 // Makes sure we send sane error values. | 347 // Makes sure we send sane error values. |
355 if (code < 0 || code >= 1000) { | 348 if (code < 0 || code >= 1000) { |
356 code = 999; | 349 code = 999; |
357 } | 350 } |
358 completer.set_code(static_cast<ActionExitCode>( | 351 completer.set_code(static_cast<ActionExitCode>( |
359 kActionCodeOmahaRequestHTTPResponseBase + code)); | 352 kActionCodeOmahaRequestHTTPResponseBase + code)); |
360 return; | 353 return; |
361 } | 354 } |
355 | |
356 // Events are best effort transactions, but it's still okay to fail them, | |
petkov
2011/01/12 01:10:22
This is somewhat dangerous. The code runs for both
| |
357 // (which happens above) since we can use the failure code to decide if we | |
358 // should signal the crash reporter about a failure. | |
359 // If we get here, assume success for the Event. | |
360 if (IsEvent()) { | |
361 CHECK(!HasOutputPipe()) << "No output pipe allowed for event requests."; | |
362 completer.set_code(kActionCodeSuccess); | |
363 return; | |
364 } | |
365 | |
362 if (!HasOutputPipe()) { | 366 if (!HasOutputPipe()) { |
363 // Just set success to whether or not the http transfer succeeded, | 367 // Just set success to whether or not the http transfer succeeded, |
364 // which must be true at this point in the code. | 368 // which must be true at this point in the code. |
365 completer.set_code(kActionCodeSuccess); | 369 completer.set_code(kActionCodeSuccess); |
366 return; | 370 return; |
367 } | 371 } |
368 | 372 |
369 // parse our response and fill the fields in the output object | 373 // parse our response and fill the fields in the output object |
370 scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> doc( | 374 scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> doc( |
371 xmlParseMemory(&response_buffer_[0], response_buffer_.size())); | 375 xmlParseMemory(&response_buffer_[0], response_buffer_.size())); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 output_object.needs_admin = | 448 output_object.needs_admin = |
445 XmlGetProperty(updatecheck_node, "needsadmin") == "true"; | 449 XmlGetProperty(updatecheck_node, "needsadmin") == "true"; |
446 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true"; | 450 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true"; |
447 output_object.is_delta = | 451 output_object.is_delta = |
448 XmlGetProperty(updatecheck_node, "IsDelta") == "true"; | 452 XmlGetProperty(updatecheck_node, "IsDelta") == "true"; |
449 output_object.deadline = XmlGetProperty(updatecheck_node, "deadline"); | 453 output_object.deadline = XmlGetProperty(updatecheck_node, "deadline"); |
450 SetOutputObject(output_object); | 454 SetOutputObject(output_object); |
451 } | 455 } |
452 | 456 |
453 }; // namespace chromeos_update_engine | 457 }; // namespace chromeos_update_engine |
OLD | NEW |