| OLD | NEW |
| 1 // Copyright (c) 2009 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> |
| 11 #include <libxml/xpathInternals.h> | 11 #include <libxml/xpathInternals.h> |
| 12 | 12 |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "chromeos/obsolete_logging.h" | 14 #include "chromeos/obsolete_logging.h" |
| 15 #include "update_engine/action_pipe.h" | 15 #include "update_engine/action_pipe.h" |
| 16 #include "update_engine/omaha_request_params.h" |
| 16 #include "update_engine/utils.h" | 17 #include "update_engine/utils.h" |
| 17 | 18 |
| 18 using std::string; | 19 using std::string; |
| 19 | 20 |
| 20 namespace chromeos_update_engine { | 21 namespace chromeos_update_engine { |
| 21 | 22 |
| 22 const char* const OmahaRequestParams::kAppId( | 23 const char* const OmahaRequestParams::kAppId( |
| 23 "{87efface-864d-49a5-9bb3-4b050a7c227a}"); | 24 "{87efface-864d-49a5-9bb3-4b050a7c227a}"); |
| 24 const char* const OmahaRequestParams::kOsPlatform("Chrome OS"); | 25 const char* const OmahaRequestParams::kOsPlatform("Chrome OS"); |
| 25 const char* const OmahaRequestParams::kOsVersion("Indy"); | 26 const char* const OmahaRequestParams::kOsVersion("Indy"); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // xmlNewDoc(ConstXMLStr("1.0"))); | 103 // xmlNewDoc(ConstXMLStr("1.0"))); |
| 103 // if (!xml_doc.get()) { | 104 // if (!xml_doc.get()) { |
| 104 // LOG(ERROR) << "Unable to create xmlDoc"; | 105 // LOG(ERROR) << "Unable to create xmlDoc"; |
| 105 // return ""; | 106 // return ""; |
| 106 // } | 107 // } |
| 107 scoped_ptr_malloc<xmlChar, ScopedPtrXmlFree> str( | 108 scoped_ptr_malloc<xmlChar, ScopedPtrXmlFree> str( |
| 108 xmlEncodeEntitiesReentrant(NULL, ConstXMLStr(input.c_str()))); | 109 xmlEncodeEntitiesReentrant(NULL, ConstXMLStr(input.c_str()))); |
| 109 return string(reinterpret_cast<const char *>(str.get())); | 110 return string(reinterpret_cast<const char *>(str.get())); |
| 110 } | 111 } |
| 111 | 112 |
| 112 OmahaRequestAction::OmahaRequestAction(OmahaEvent* event, | 113 OmahaRequestAction::OmahaRequestAction(const OmahaRequestParams& params, |
| 114 OmahaEvent* event, |
| 113 HttpFetcher* http_fetcher) | 115 HttpFetcher* http_fetcher) |
| 114 : event_(event), | 116 : params_(params), |
| 117 event_(event), |
| 115 http_fetcher_(http_fetcher) {} | 118 http_fetcher_(http_fetcher) {} |
| 116 | 119 |
| 117 OmahaRequestAction::~OmahaRequestAction() {} | 120 OmahaRequestAction::~OmahaRequestAction() {} |
| 118 | 121 |
| 119 void OmahaRequestAction::PerformAction() { | 122 void OmahaRequestAction::PerformAction() { |
| 120 CHECK(HasInputObject()); | |
| 121 params_ = GetInputObject(); | |
| 122 http_fetcher_->set_delegate(this); | 123 http_fetcher_->set_delegate(this); |
| 123 string request_post(FormatRequest(event_.get(), params_)); | 124 string request_post(FormatRequest(event_.get(), params_)); |
| 124 http_fetcher_->SetPostData(request_post.data(), request_post.size()); | 125 http_fetcher_->SetPostData(request_post.data(), request_post.size()); |
| 125 LOG(INFO) << "Posting an Omaha request to " << params_.update_url; | 126 LOG(INFO) << "Posting an Omaha request to " << params_.update_url; |
| 126 LOG(INFO) << "Request: " << request_post; | 127 LOG(INFO) << "Request: " << request_post; |
| 127 http_fetcher_->BeginTransfer(params_.update_url); | 128 http_fetcher_->BeginTransfer(params_.update_url); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void OmahaRequestAction::TerminateProcessing() { | 131 void OmahaRequestAction::TerminateProcessing() { |
| 131 http_fetcher_->TerminateTransfer(); | 132 http_fetcher_->TerminateTransfer(); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 output_object.hash = XmlGetProperty(updatecheck_node, "hash"); | 287 output_object.hash = XmlGetProperty(updatecheck_node, "hash"); |
| 287 output_object.size = ParseInt(XmlGetProperty(updatecheck_node, "size")); | 288 output_object.size = ParseInt(XmlGetProperty(updatecheck_node, "size")); |
| 288 output_object.needs_admin = | 289 output_object.needs_admin = |
| 289 XmlGetProperty(updatecheck_node, "needsadmin") == "true"; | 290 XmlGetProperty(updatecheck_node, "needsadmin") == "true"; |
| 290 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true"; | 291 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true"; |
| 291 SetOutputObject(output_object); | 292 SetOutputObject(output_object); |
| 292 return; | 293 return; |
| 293 } | 294 } |
| 294 | 295 |
| 295 }; // namespace chromeos_update_engine | 296 }; // namespace chromeos_update_engine |
| OLD | NEW |