buffet: ticket_id is local to RegisterDevice
This is just minor refactoring. Previously ticket_id_ was a field in the
DeviceRegistrationInfo class, but it was only used in one method
(RegisterDevice) and there was no need to maintain state between calls
to this method.
TEST=FEATURES=test emerge-${BOARD} buffet
BUG=none
Change-Id: I766ffc30cc4ddb4620dff071abd0e52b1f3ae0c7
Reviewed-on: https://chromium-review.googlesource.com/251046
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Nathan Bullock <nathanbullock@google.com>
Tested-by: Nathan Bullock <nathanbullock@google.com>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
diff --git a/buffet/device_registration_info.cc b/buffet/device_registration_info.cc
index b44498d..a4e30e1 100644
--- a/buffet/device_registration_info.cc
+++ b/buffet/device_registration_info.cc
@@ -402,7 +402,8 @@
std::string DeviceRegistrationInfo::RegisterDevice(
const std::map<std::string, std::string>& params,
chromeos::ErrorPtr* error) {
- if (!GetParamValue(params, "ticket_id", &ticket_id_, error) ||
+ std::string ticket_id;
+ if (!GetParamValue(params, "ticket_id", &ticket_id, error) ||
!GetParamValue(params, storage_keys::kClientId, &client_id_, error) ||
!GetParamValue(params, storage_keys::kClientSecret, &client_secret_,
error) ||
@@ -425,11 +426,11 @@
return std::string();
base::DictionaryValue req_json;
- req_json.SetString("id", ticket_id_);
+ req_json.SetString("id", ticket_id);
req_json.SetString("oauthClientId", client_id_);
req_json.Set("deviceDraft", device_draft.release());
- auto url = GetServiceURL("registrationTickets/" + ticket_id_,
+ auto url = GetServiceURL("registrationTickets/" + ticket_id,
{{"key", api_key_}});
std::unique_ptr<chromeos::http::Response> response =
chromeos::http::PatchJsonAndBlock(url, &req_json, {}, transport_, error);
@@ -442,7 +443,7 @@
return std::string();
}
- url = GetServiceURL("registrationTickets/" + ticket_id_ +
+ url = GetServiceURL("registrationTickets/" + ticket_id +
"/finalize?key=" + api_key_);
response = chromeos::http::SendRequestWithNoDataAndBlock(
chromeos::http::request_type::kPost, url, {}, transport_, error);