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_checker.h" | 5 #include "components/update_client/update_checker.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 23 matching lines...) Expand all Loading... |
34 return IsValidBrand(brand) ? brand : std::string(""); | 34 return IsValidBrand(brand) ? brand : std::string(""); |
35 } | 35 } |
36 | 36 |
37 // Returns a sanitized version of the |ap| or an empty string otherwise. | 37 // Returns a sanitized version of the |ap| or an empty string otherwise. |
38 std::string SanitizeAp(const std::string& ap) { | 38 std::string SanitizeAp(const std::string& ap) { |
39 return IsValidAp(ap) ? ap : std::string(); | 39 return IsValidAp(ap) ? ap : std::string(); |
40 } | 40 } |
41 | 41 |
42 // Returns true if at least one item requires network encryption. | 42 // Returns true if at least one item requires network encryption. |
43 bool IsEncryptionRequired(const std::vector<CrxUpdateItem*>& items) { | 43 bool IsEncryptionRequired(const std::vector<CrxUpdateItem*>& items) { |
44 for (const auto& item : items) { | 44 for (auto* item : items) { |
45 if (item->component.requires_network_encryption) | 45 if (item->component.requires_network_encryption) |
46 return true; | 46 return true; |
47 } | 47 } |
48 return false; | 48 return false; |
49 } | 49 } |
50 | 50 |
51 // Builds an update check request for |components|. |additional_attributes| is | 51 // Builds an update check request for |components|. |additional_attributes| is |
52 // serialized as part of the <request> element of the request to customize it | 52 // serialized as part of the <request> element of the request to customize it |
53 // with data that is not platform or component specific. For each |item|, a | 53 // with data that is not platform or component specific. For each |item|, a |
54 // corresponding <app> element is created and inserted as a child node of | 54 // corresponding <app> element is created and inserted as a child node of |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 | 152 |
153 update_check_callback_ = update_check_callback; | 153 update_check_callback_ = update_check_callback; |
154 | 154 |
155 auto urls(config_->UpdateUrl()); | 155 auto urls(config_->UpdateUrl()); |
156 if (IsEncryptionRequired(items_to_check)) | 156 if (IsEncryptionRequired(items_to_check)) |
157 RemoveUnsecureUrls(&urls); | 157 RemoveUnsecureUrls(&urls); |
158 | 158 |
159 std::unique_ptr<std::vector<std::string>> ids_checked( | 159 std::unique_ptr<std::vector<std::string>> ids_checked( |
160 new std::vector<std::string>()); | 160 new std::vector<std::string>()); |
161 for (auto crx : items_to_check) | 161 for (auto* crx : items_to_check) |
162 ids_checked->push_back(crx->id); | 162 ids_checked->push_back(crx->id); |
163 request_sender_.reset(new RequestSender(config_)); | 163 request_sender_.reset(new RequestSender(config_)); |
164 request_sender_->Send( | 164 request_sender_->Send( |
165 config_->UseCupSigning(), | 165 config_->UseCupSigning(), |
166 BuildUpdateCheckRequest(*config_, items_to_check, metadata_, | 166 BuildUpdateCheckRequest(*config_, items_to_check, metadata_, |
167 additional_attributes), | 167 additional_attributes), |
168 urls, base::Bind(&UpdateCheckerImpl::OnRequestSenderComplete, | 168 urls, base::Bind(&UpdateCheckerImpl::OnRequestSenderComplete, |
169 base::Unretained(this), base::Passed(&ids_checked))); | 169 base::Unretained(this), base::Passed(&ids_checked))); |
170 return true; | 170 return true; |
171 } | 171 } |
(...skipping 29 matching lines...) Expand all Loading... |
201 } // namespace | 201 } // namespace |
202 | 202 |
203 std::unique_ptr<UpdateChecker> UpdateChecker::Create( | 203 std::unique_ptr<UpdateChecker> UpdateChecker::Create( |
204 const scoped_refptr<Configurator>& config, | 204 const scoped_refptr<Configurator>& config, |
205 PersistedData* persistent) { | 205 PersistedData* persistent) { |
206 return std::unique_ptr<UpdateChecker>( | 206 return std::unique_ptr<UpdateChecker>( |
207 new UpdateCheckerImpl(config, persistent)); | 207 new UpdateCheckerImpl(config, persistent)); |
208 } | 208 } |
209 | 209 |
210 } // namespace update_client | 210 } // namespace update_client |
OLD | NEW |