| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/action_update_check.h" | 5 #include "components/update_client/action_update_check.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "components/update_client/utils.h" | 22 #include "components/update_client/utils.h" |
| 23 | 23 |
| 24 using std::string; | 24 using std::string; |
| 25 using std::vector; | 25 using std::vector; |
| 26 | 26 |
| 27 namespace update_client { | 27 namespace update_client { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // Returns true if the |proposed| version is newer than |current| version. | 31 // Returns true if the |proposed| version is newer than |current| version. |
| 32 bool IsVersionNewer(const Version& current, const std::string& proposed) { | 32 bool IsVersionNewer(const base::Version& current, const std::string& proposed) { |
| 33 Version proposed_ver(proposed); | 33 base::Version proposed_ver(proposed); |
| 34 return proposed_ver.IsValid() && current.CompareTo(proposed_ver) < 0; | 34 return proposed_ver.IsValid() && current.CompareTo(proposed_ver) < 0; |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 ActionUpdateCheck::ActionUpdateCheck( | 39 ActionUpdateCheck::ActionUpdateCheck( |
| 40 std::unique_ptr<UpdateChecker> update_checker, | 40 std::unique_ptr<UpdateChecker> update_checker, |
| 41 const base::Version& browser_version, | 41 const base::Version& browser_version, |
| 42 const std::string& extra_request_parameters) | 42 const std::string& extra_request_parameters) |
| 43 : update_checker_(std::move(update_checker)), | 43 : update_checker_(std::move(update_checker)), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 63 for (size_t i = 0; i != crx_components.size(); ++i) { | 63 for (size_t i = 0; i != crx_components.size(); ++i) { |
| 64 std::unique_ptr<CrxUpdateItem> item(new CrxUpdateItem); | 64 std::unique_ptr<CrxUpdateItem> item(new CrxUpdateItem); |
| 65 const CrxComponent& crx_component = crx_components[i]; | 65 const CrxComponent& crx_component = crx_components[i]; |
| 66 | 66 |
| 67 item->id = GetCrxComponentID(crx_component); | 67 item->id = GetCrxComponentID(crx_component); |
| 68 item->component = crx_component; | 68 item->component = crx_component; |
| 69 item->last_check = base::Time::Now(); | 69 item->last_check = base::Time::Now(); |
| 70 item->crx_urls.clear(); | 70 item->crx_urls.clear(); |
| 71 item->crx_diffurls.clear(); | 71 item->crx_diffurls.clear(); |
| 72 item->previous_version = crx_component.version; | 72 item->previous_version = crx_component.version; |
| 73 item->next_version = Version(); | 73 item->next_version = base::Version(); |
| 74 item->previous_fp = crx_component.fingerprint; | 74 item->previous_fp = crx_component.fingerprint; |
| 75 item->next_fp.clear(); | 75 item->next_fp.clear(); |
| 76 item->on_demand = update_context->is_foreground; | 76 item->on_demand = update_context->is_foreground; |
| 77 item->diff_update_failed = false; | 77 item->diff_update_failed = false; |
| 78 item->error_category = 0; | 78 item->error_category = 0; |
| 79 item->error_code = 0; | 79 item->error_code = 0; |
| 80 item->extra_code1 = 0; | 80 item->extra_code1 = 0; |
| 81 item->diff_error_category = 0; | 81 item->diff_error_category = 0; |
| 82 item->diff_error_code = 0; | 82 item->diff_error_code = 0; |
| 83 item->diff_extra_code1 = 0; | 83 item->diff_extra_code1 = 0; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 149 } |
| 150 | 150 |
| 151 if (it->manifest.packages.size() != 1) { | 151 if (it->manifest.packages.size() != 1) { |
| 152 // Assume one and only one package per CRX. | 152 // Assume one and only one package per CRX. |
| 153 VLOG(1) << "Ignoring multiple packages for CRX: " << crx->id; | 153 VLOG(1) << "Ignoring multiple packages for CRX: " << crx->id; |
| 154 ChangeItemState(crx, CrxUpdateItem::State::kNoUpdate); | 154 ChangeItemState(crx, CrxUpdateItem::State::kNoUpdate); |
| 155 continue; | 155 continue; |
| 156 } | 156 } |
| 157 | 157 |
| 158 // Parse the members of the result and queue an upgrade for this CRX. | 158 // Parse the members of the result and queue an upgrade for this CRX. |
| 159 crx->next_version = Version(it->manifest.version); | 159 crx->next_version = base::Version(it->manifest.version); |
| 160 | 160 |
| 161 VLOG(1) << "Update found for CRX: " << crx->id; | 161 VLOG(1) << "Update found for CRX: " << crx->id; |
| 162 | 162 |
| 163 const auto& package(it->manifest.packages[0]); | 163 const auto& package(it->manifest.packages[0]); |
| 164 crx->next_fp = package.fingerprint; | 164 crx->next_fp = package.fingerprint; |
| 165 | 165 |
| 166 // Resolve the urls by combining the base urls with the package names. | 166 // Resolve the urls by combining the base urls with the package names. |
| 167 for (size_t i = 0; i != it->crx_urls.size(); ++i) { | 167 for (size_t i = 0; i != it->crx_urls.size(); ++i) { |
| 168 const GURL url(it->crx_urls[i].Resolve(package.name)); | 168 const GURL url(it->crx_urls[i].Resolve(package.name)); |
| 169 if (url.is_valid()) | 169 if (url.is_valid()) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 VLOG(1) << "Update check failed." << error; | 205 VLOG(1) << "Update check failed." << error; |
| 206 | 206 |
| 207 ChangeAllItemsState(CrxUpdateItem::State::kChecking, | 207 ChangeAllItemsState(CrxUpdateItem::State::kChecking, |
| 208 CrxUpdateItem::State::kNoUpdate); | 208 CrxUpdateItem::State::kNoUpdate); |
| 209 | 209 |
| 210 UpdateComplete(error); | 210 UpdateComplete(error); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace update_client | 213 } // namespace update_client |
| OLD | NEW |