OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 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/update_check_action.h" | 5 #include "update_engine/update_check_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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 : http_fetcher_(http_fetcher) {} | 100 : http_fetcher_(http_fetcher) {} |
101 | 101 |
102 UpdateCheckAction::~UpdateCheckAction() {} | 102 UpdateCheckAction::~UpdateCheckAction() {} |
103 | 103 |
104 void UpdateCheckAction::PerformAction() { | 104 void UpdateCheckAction::PerformAction() { |
105 CHECK(HasInputObject()); | 105 CHECK(HasInputObject()); |
106 params_ = GetInputObject(); | 106 params_ = GetInputObject(); |
107 http_fetcher_->set_delegate(this); | 107 http_fetcher_->set_delegate(this); |
108 string request_post(FormatRequest(params_)); | 108 string request_post(FormatRequest(params_)); |
109 http_fetcher_->SetPostData(request_post.data(), request_post.size()); | 109 http_fetcher_->SetPostData(request_post.data(), request_post.size()); |
| 110 LOG(INFO) << "Checking for update at " << params_.update_url; |
| 111 LOG(INFO) << "Request: " << request_post; |
110 http_fetcher_->BeginTransfer(params_.update_url); | 112 http_fetcher_->BeginTransfer(params_.update_url); |
111 } | 113 } |
112 | 114 |
113 void UpdateCheckAction::TerminateProcessing() { | 115 void UpdateCheckAction::TerminateProcessing() { |
114 http_fetcher_->TerminateTransfer(); | 116 http_fetcher_->TerminateTransfer(); |
115 } | 117 } |
116 | 118 |
117 // We just store the response in the buffer. Once we've received all bytes, | 119 // We just store the response in the buffer. Once we've received all bytes, |
118 // we'll look in the buffer and decide what to do. | 120 // we'll look in the buffer and decide what to do. |
119 void UpdateCheckAction::ReceivedBytes(HttpFetcher *fetcher, | 121 void UpdateCheckAction::ReceivedBytes(HttpFetcher *fetcher, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 return ret; | 185 return ret; |
184 } | 186 } |
185 } // namespace {} | 187 } // namespace {} |
186 | 188 |
187 // If the transfer was successful, this uses libxml2 to parse the response | 189 // If the transfer was successful, this uses libxml2 to parse the response |
188 // and fill in the appropriate fields of the output object. Also, notifies | 190 // and fill in the appropriate fields of the output object. Also, notifies |
189 // the processor that we're done. | 191 // the processor that we're done. |
190 void UpdateCheckAction::TransferComplete(HttpFetcher *fetcher, | 192 void UpdateCheckAction::TransferComplete(HttpFetcher *fetcher, |
191 bool successful) { | 193 bool successful) { |
192 ScopedActionCompleter completer(processor_, this); | 194 ScopedActionCompleter completer(processor_, this); |
193 if (!successful) | 195 LOG(INFO) << "Update check response: " << string(response_buffer_.begin(), |
| 196 response_buffer_.end()); |
| 197 if (!successful) { |
| 198 LOG(ERROR) << "Update check network transfer failed."; |
194 return; | 199 return; |
| 200 } |
195 if (!HasOutputPipe()) { | 201 if (!HasOutputPipe()) { |
196 // Just set success to whether or not the http transfer succeeded, | 202 // Just set success to whether or not the http transfer succeeded, |
197 // which must be true at this point in the code. | 203 // which must be true at this point in the code. |
198 completer.set_success(true); | 204 completer.set_success(true); |
199 return; | 205 return; |
200 } | 206 } |
201 | 207 |
202 // parse our response and fill the fields in the output object | 208 // parse our response and fill the fields in the output object |
203 scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> doc( | 209 scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> doc( |
204 xmlParseMemory(&response_buffer_[0], response_buffer_.size())); | 210 xmlParseMemory(&response_buffer_[0], response_buffer_.size())); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 output_object.hash = XmlGetProperty(updatecheck_node, "hash"); | 263 output_object.hash = XmlGetProperty(updatecheck_node, "hash"); |
258 output_object.size = ParseInt(XmlGetProperty(updatecheck_node, "size")); | 264 output_object.size = ParseInt(XmlGetProperty(updatecheck_node, "size")); |
259 output_object.needs_admin = | 265 output_object.needs_admin = |
260 XmlGetProperty(updatecheck_node, "needsadmin") == "true"; | 266 XmlGetProperty(updatecheck_node, "needsadmin") == "true"; |
261 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true"; | 267 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true"; |
262 SetOutputObject(output_object); | 268 SetOutputObject(output_object); |
263 return; | 269 return; |
264 } | 270 } |
265 | 271 |
266 }; // namespace chromeos_update_engine | 272 }; // namespace chromeos_update_engine |
OLD | NEW |