| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "base/version.h" | 14 #include "base/version.h" |
| 15 #include "components/update_client/action_update.h" | 15 #include "components/update_client/action_update.h" |
| 16 #include "components/update_client/configurator.h" | 16 #include "components/update_client/configurator.h" |
| 17 #include "components/update_client/update_checker.h" | 17 #include "components/update_client/update_checker.h" |
| 18 #include "components/update_client/update_client.h" | 18 #include "components/update_client/update_client.h" |
| 19 #include "components/update_client/utils.h" | 19 #include "components/update_client/utils.h" |
| 20 | 20 |
| 21 using std::string; | 21 using std::string; |
| 22 using std::vector; | 22 using std::vector; |
| 23 | 23 |
| 24 namespace update_client { | 24 namespace update_client { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Returns true if the |proposed| version is newer than |current| version. | 28 // Returns true if the |proposed| version is newer than |current| version. |
| 29 bool IsVersionNewer(const base::Version& current, const std::string& proposed) { | 29 bool IsVersionNewer(const Version& current, const std::string& proposed) { |
| 30 base::Version proposed_ver(proposed); | 30 Version proposed_ver(proposed); |
| 31 return proposed_ver.IsValid() && current.CompareTo(proposed_ver) < 0; | 31 return proposed_ver.IsValid() && current.CompareTo(proposed_ver) < 0; |
| 32 } | 32 } |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 ActionUpdateCheck::ActionUpdateCheck( | 36 ActionUpdateCheck::ActionUpdateCheck( |
| 37 scoped_ptr<UpdateChecker> update_checker, | 37 scoped_ptr<UpdateChecker> update_checker, |
| 38 const base::Version& browser_version, | 38 const base::Version& browser_version, |
| 39 const std::string& extra_request_parameters) | 39 const std::string& extra_request_parameters) |
| 40 : update_checker_(update_checker.Pass()), | 40 : update_checker_(update_checker.Pass()), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 61 for (size_t i = 0; i != crx_components.size(); ++i) { | 61 for (size_t i = 0; i != crx_components.size(); ++i) { |
| 62 scoped_ptr<CrxUpdateItem> item(new CrxUpdateItem); | 62 scoped_ptr<CrxUpdateItem> item(new CrxUpdateItem); |
| 63 const CrxComponent& crx_component = crx_components[i]; | 63 const CrxComponent& crx_component = crx_components[i]; |
| 64 | 64 |
| 65 item->id = GetCrxComponentID(crx_component); | 65 item->id = GetCrxComponentID(crx_component); |
| 66 item->component = crx_component; | 66 item->component = crx_component; |
| 67 item->last_check = base::Time::Now(); | 67 item->last_check = base::Time::Now(); |
| 68 item->crx_urls.clear(); | 68 item->crx_urls.clear(); |
| 69 item->crx_diffurls.clear(); | 69 item->crx_diffurls.clear(); |
| 70 item->previous_version = crx_component.version; | 70 item->previous_version = crx_component.version; |
| 71 item->next_version = base::Version(); | 71 item->next_version = Version(); |
| 72 item->previous_fp = crx_component.fingerprint; | 72 item->previous_fp = crx_component.fingerprint; |
| 73 item->next_fp.clear(); | 73 item->next_fp.clear(); |
| 74 item->on_demand = update_context->is_foreground; | 74 item->on_demand = update_context->is_foreground; |
| 75 item->diff_update_failed = false; | 75 item->diff_update_failed = false; |
| 76 item->error_category = 0; | 76 item->error_category = 0; |
| 77 item->error_code = 0; | 77 item->error_code = 0; |
| 78 item->extra_code1 = 0; | 78 item->extra_code1 = 0; |
| 79 item->diff_error_category = 0; | 79 item->diff_error_category = 0; |
| 80 item->diff_error_code = 0; | 80 item->diff_error_code = 0; |
| 81 item->diff_extra_code1 = 0; | 81 item->diff_extra_code1 = 0; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 147 } |
| 148 | 148 |
| 149 if (it->manifest.packages.size() != 1) { | 149 if (it->manifest.packages.size() != 1) { |
| 150 // Assume one and only one package per CRX. | 150 // Assume one and only one package per CRX. |
| 151 VLOG(1) << "Ignoring multiple packages for CRX: " << crx->id; | 151 VLOG(1) << "Ignoring multiple packages for CRX: " << crx->id; |
| 152 ChangeItemState(crx, CrxUpdateItem::State::kNoUpdate); | 152 ChangeItemState(crx, CrxUpdateItem::State::kNoUpdate); |
| 153 continue; | 153 continue; |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Parse the members of the result and queue an upgrade for this CRX. | 156 // Parse the members of the result and queue an upgrade for this CRX. |
| 157 crx->next_version = base::Version(it->manifest.version); | 157 crx->next_version = Version(it->manifest.version); |
| 158 | 158 |
| 159 VLOG(1) << "Update found for CRX: " << crx->id; | 159 VLOG(1) << "Update found for CRX: " << crx->id; |
| 160 | 160 |
| 161 const auto& package(it->manifest.packages[0]); | 161 const auto& package(it->manifest.packages[0]); |
| 162 crx->next_fp = package.fingerprint; | 162 crx->next_fp = package.fingerprint; |
| 163 | 163 |
| 164 // Resolve the urls by combining the base urls with the package names. | 164 // Resolve the urls by combining the base urls with the package names. |
| 165 for (size_t i = 0; i != it->crx_urls.size(); ++i) { | 165 for (size_t i = 0; i != it->crx_urls.size(); ++i) { |
| 166 const GURL url(it->crx_urls[i].Resolve(package.name)); | 166 const GURL url(it->crx_urls[i].Resolve(package.name)); |
| 167 if (url.is_valid()) | 167 if (url.is_valid()) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 197 const std::string& error_message) { | 197 const std::string& error_message) { |
| 198 DCHECK(thread_checker_.CalledOnValidThread()); | 198 DCHECK(thread_checker_.CalledOnValidThread()); |
| 199 DCHECK(error); | 199 DCHECK(error); |
| 200 | 200 |
| 201 VLOG(1) << "Update check failed." << error; | 201 VLOG(1) << "Update check failed." << error; |
| 202 | 202 |
| 203 UpdateComplete(error); | 203 UpdateComplete(error); |
| 204 } | 204 } |
| 205 | 205 |
| 206 } // namespace update_client | 206 } // namespace update_client |
| OLD | NEW |