OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 "components/update_client/update_response.h" | 5 #include "components/update_client/update_response.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 if (updates.empty()) { | 280 if (updates.empty()) { |
281 *error = "Missing updatecheck on app."; | 281 *error = "Missing updatecheck on app."; |
282 return false; | 282 return false; |
283 } | 283 } |
284 | 284 |
285 return ParseUpdateCheckTag(updates[0], result, error); | 285 return ParseUpdateCheckTag(updates[0], result, error); |
286 } | 286 } |
287 | 287 |
288 bool UpdateResponse::Parse(const std::string& response_xml) { | 288 bool UpdateResponse::Parse(const std::string& response_xml) { |
289 results_.daystart_elapsed_seconds = kNoDaystart; | 289 results_.daystart_elapsed_seconds = kNoDaystart; |
| 290 results_.daystart_elapsed_days = kNoDaystart; |
290 results_.list.clear(); | 291 results_.list.clear(); |
291 errors_.clear(); | 292 errors_.clear(); |
292 | 293 |
293 if (response_xml.length() < 1) { | 294 if (response_xml.length() < 1) { |
294 ParseError("Empty xml"); | 295 ParseError("Empty xml"); |
295 return false; | 296 return false; |
296 } | 297 } |
297 | 298 |
298 std::string xml_errors; | 299 std::string xml_errors; |
299 ScopedXmlErrorFunc error_func(&xml_errors, &XmlErrorFunc); | 300 ScopedXmlErrorFunc error_func(&xml_errors, &XmlErrorFunc); |
(...skipping 28 matching lines...) Expand all Loading... |
328 | 329 |
329 // Parse the first <daystart> if it is present. | 330 // Parse the first <daystart> if it is present. |
330 std::vector<xmlNode*> daystarts = GetChildren(root, "daystart"); | 331 std::vector<xmlNode*> daystarts = GetChildren(root, "daystart"); |
331 if (!daystarts.empty()) { | 332 if (!daystarts.empty()) { |
332 xmlNode* first = daystarts[0]; | 333 xmlNode* first = daystarts[0]; |
333 std::string elapsed_seconds = GetAttribute(first, "elapsed_seconds"); | 334 std::string elapsed_seconds = GetAttribute(first, "elapsed_seconds"); |
334 int parsed_elapsed = kNoDaystart; | 335 int parsed_elapsed = kNoDaystart; |
335 if (base::StringToInt(elapsed_seconds, &parsed_elapsed)) { | 336 if (base::StringToInt(elapsed_seconds, &parsed_elapsed)) { |
336 results_.daystart_elapsed_seconds = parsed_elapsed; | 337 results_.daystart_elapsed_seconds = parsed_elapsed; |
337 } | 338 } |
| 339 std::string elapsed_days = GetAttribute(first, "elapsed_days"); |
| 340 parsed_elapsed = kNoDaystart; |
| 341 if (base::StringToInt(elapsed_days, &parsed_elapsed)) { |
| 342 results_.daystart_elapsed_days = parsed_elapsed; |
| 343 } |
338 } | 344 } |
339 | 345 |
340 // Parse each of the <app> tags. | 346 // Parse each of the <app> tags. |
341 std::vector<xmlNode*> apps = GetChildren(root, "app"); | 347 std::vector<xmlNode*> apps = GetChildren(root, "app"); |
342 for (size_t i = 0; i != apps.size(); ++i) { | 348 for (size_t i = 0; i != apps.size(); ++i) { |
343 Result result; | 349 Result result; |
344 std::string error; | 350 std::string error; |
345 if (ParseAppTag(apps[i], &result, &error)) { | 351 if (ParseAppTag(apps[i], &result, &error)) { |
346 results_.list.push_back(result); | 352 results_.list.push_back(result); |
347 } else { | 353 } else { |
348 ParseError("%s", error.c_str()); | 354 ParseError("%s", error.c_str()); |
349 } | 355 } |
350 } | 356 } |
351 | 357 |
352 return true; | 358 return true; |
353 } | 359 } |
354 | 360 |
355 } // namespace update_client | 361 } // namespace update_client |
OLD | NEW |