Chromium Code Reviews| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 base::StringAppendF(&app, "appid=\"%s\" version=\"%s\"", item->id.c_str(), | 84 base::StringAppendF(&app, "appid=\"%s\" version=\"%s\"", item->id.c_str(), |
| 85 item->component.version.GetString().c_str()); | 85 item->component.version.GetString().c_str()); |
| 86 if (!brand.empty()) | 86 if (!brand.empty()) |
| 87 base::StringAppendF(&app, " brand=\"%s\"", brand.c_str()); | 87 base::StringAppendF(&app, " brand=\"%s\"", brand.c_str()); |
| 88 if (item->on_demand) | 88 if (item->on_demand) |
| 89 base::StringAppendF(&app, " installsource=\"ondemand\""); | 89 base::StringAppendF(&app, " installsource=\"ondemand\""); |
| 90 for (const auto& attr : installer_attributes) { | 90 for (const auto& attr : installer_attributes) { |
| 91 base::StringAppendF(&app, " %s=\"%s\"", attr.first.c_str(), | 91 base::StringAppendF(&app, " %s=\"%s\"", attr.first.c_str(), |
| 92 attr.second.c_str()); | 92 attr.second.c_str()); |
| 93 } | 93 } |
| 94 const std::string& cohort = metadata->GetCohort(item->id); | |
|
Sorin Jianu
2016/08/18 21:15:15
This is a small deal and mostly a matter of person
waffles
2016/08/18 22:29:23
Done.
| |
| 95 const std::string& cohort_name = metadata->GetCohortName(item->id); | |
| 96 const std::string& cohort_hint = metadata->GetCohortHint(item->id); | |
| 97 if (!cohort.empty()) | |
| 98 base::StringAppendF(&app, " cohort=\"%s\"", cohort.c_str()); | |
| 99 if (!cohort_name.empty()) | |
| 100 base::StringAppendF(&app, " cohortname=\"%s\"", cohort_name.c_str()); | |
| 101 if (!cohort_hint.empty()) | |
| 102 base::StringAppendF(&app, " cohorthint=\"%s\"", cohort_hint.c_str()); | |
| 94 base::StringAppendF(&app, ">"); | 103 base::StringAppendF(&app, ">"); |
| 95 | 104 |
| 96 base::StringAppendF(&app, "<updatecheck"); | 105 base::StringAppendF(&app, "<updatecheck"); |
| 97 if (item->component.supports_group_policy_enable_component_updates && | 106 if (item->component.supports_group_policy_enable_component_updates && |
| 98 !enabled_component_updates) { | 107 !enabled_component_updates) { |
| 99 base::StringAppendF(&app, " updatedisabled=\"true\""); | 108 base::StringAppendF(&app, " updatedisabled=\"true\""); |
| 100 } | 109 } |
| 101 base::StringAppendF(&app, "/>"); | 110 base::StringAppendF(&app, "/>"); |
| 102 | 111 |
| 103 base::StringAppendF(&app, "<ping rd=\"%d\" ping_freshness=\"%s\" />", | 112 base::StringAppendF(&app, "<ping rd=\"%d\" ping_freshness=\"%s\" />", |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 const std::string& response, | 205 const std::string& response, |
| 197 int retry_after_sec) { | 206 int retry_after_sec) { |
| 198 DCHECK(thread_checker_.CalledOnValidThread()); | 207 DCHECK(thread_checker_.CalledOnValidThread()); |
| 199 | 208 |
| 200 if (!error) { | 209 if (!error) { |
| 201 UpdateResponse update_response; | 210 UpdateResponse update_response; |
| 202 if (update_response.Parse(response)) { | 211 if (update_response.Parse(response)) { |
| 203 int daynum = update_response.results().daystart_elapsed_days; | 212 int daynum = update_response.results().daystart_elapsed_days; |
| 204 if (daynum != UpdateResponse::kNoDaystart) | 213 if (daynum != UpdateResponse::kNoDaystart) |
| 205 metadata_->SetDateLastRollCall(*ids_checked, daynum); | 214 metadata_->SetDateLastRollCall(*ids_checked, daynum); |
| 215 for (auto result : update_response.results().list) { | |
| 216 if (result.set_cohort) | |
| 217 metadata_->SetCohort(result.extension_id, result.cohort); | |
| 218 if (result.set_cohort_hint) | |
| 219 metadata_->SetCohortHint(result.extension_id, result.cohort_hint); | |
| 220 if (result.set_cohort_name) | |
| 221 metadata_->SetCohortName(result.extension_id, result.cohort_name); | |
| 222 } | |
| 206 base::ThreadTaskRunnerHandle::Get()->PostTask( | 223 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 207 FROM_HERE, base::Bind(update_check_callback_, error, | 224 FROM_HERE, base::Bind(update_check_callback_, error, |
| 208 update_response.results(), retry_after_sec)); | 225 update_response.results(), retry_after_sec)); |
| 209 return; | 226 return; |
| 210 } | 227 } |
| 211 | 228 |
| 212 error = -1; | 229 error = -1; |
| 213 VLOG(1) << "Parse failed " << update_response.errors(); | 230 VLOG(1) << "Parse failed " << update_response.errors(); |
| 214 } | 231 } |
| 215 | 232 |
| 216 base::ThreadTaskRunnerHandle::Get()->PostTask( | 233 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 217 FROM_HERE, base::Bind(update_check_callback_, error, | 234 FROM_HERE, base::Bind(update_check_callback_, error, |
| 218 UpdateResponse::Results(), retry_after_sec)); | 235 UpdateResponse::Results(), retry_after_sec)); |
| 219 } | 236 } |
| 220 | 237 |
| 221 } // namespace | 238 } // namespace |
| 222 | 239 |
| 223 std::unique_ptr<UpdateChecker> UpdateChecker::Create( | 240 std::unique_ptr<UpdateChecker> UpdateChecker::Create( |
| 224 const scoped_refptr<Configurator>& config, | 241 const scoped_refptr<Configurator>& config, |
| 225 PersistedData* persistent) { | 242 PersistedData* persistent) { |
| 226 return std::unique_ptr<UpdateChecker>( | 243 return std::unique_ptr<UpdateChecker>( |
| 227 new UpdateCheckerImpl(config, persistent)); | 244 new UpdateCheckerImpl(config, persistent)); |
| 228 } | 245 } |
| 229 | 246 |
| 230 } // namespace update_client | 247 } // namespace update_client |
| OLD | NEW |