Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: google_apis/gcm/tools/mcs_probe.cc

Issue 144383005: [GCM] Fix mcs_probe credential handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Persist checkin credentials Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gcm/engine/mcs_client.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gcm/tools/mcs_probe.cc
diff --git a/google_apis/gcm/tools/mcs_probe.cc b/google_apis/gcm/tools/mcs_probe.cc
index 7dce59346cc9d5bbd036ed9a0b21a28f022e890d..cf9085d6c37402791c1bbe37f5006a03df417986 100644
--- a/google_apis/gcm/tools/mcs_probe.cc
+++ b/google_apis/gcm/tools/mcs_probe.cc
@@ -182,6 +182,7 @@ class MCSProbe {
void BuildNetworkSession();
void LoadCallback(scoped_ptr<GCMStore::LoadResult> load_result);
+ void UpdateCallback(bool success);
void ErrorCallback();
void OnCheckInCompleted(uint64 android_id, uint64 secret);
@@ -282,8 +283,19 @@ void MCSProbe::Start() {
void MCSProbe::LoadCallback(scoped_ptr<GCMStore::LoadResult> load_result) {
DCHECK(load_result->success);
- android_id_ = load_result->device_android_id;
- secret_ = load_result->device_security_token;
+ if (android_id_ != 0 && secret_ != 0) {
+ DVLOG(1) << "Presetting MCS id " << android_id_;
+ load_result->device_android_id = android_id_;
+ load_result->device_security_token = secret_;
+ gcm_store_->SetDeviceCredentials(android_id_,
+ secret_,
+ base::Bind(&MCSProbe::UpdateCallback,
+ base::Unretained(this)));
+ } else {
+ android_id_ = load_result->device_android_id;
+ secret_ = load_result->device_security_token;
+ DVLOG(1) << "Loaded MCS id " << android_id_;
+ }
mcs_client_->Initialize(
base::Bind(&MCSProbe::ErrorCallback, base::Unretained(this)),
base::Bind(&MessageReceivedCallback),
@@ -291,6 +303,7 @@ void MCSProbe::LoadCallback(scoped_ptr<GCMStore::LoadResult> load_result) {
load_result.Pass());
if (!android_id_ || !secret_) {
+ DVLOG(1) << "Checkin to generate new MCS credentials.";
CheckIn();
return;
}
@@ -298,6 +311,9 @@ void MCSProbe::LoadCallback(scoped_ptr<GCMStore::LoadResult> load_result) {
mcs_client_->Login(android_id_, secret_);
}
+void MCSProbe::UpdateCallback(bool success) {
+}
+
void MCSProbe::InitializeNetworkState() {
FILE* log_file = NULL;
if (command_line_.HasSwitch(kLogFileSwitch)) {
@@ -394,6 +410,11 @@ void MCSProbe::OnCheckInCompleted(uint64 android_id, uint64 secret) {
android_id_ = android_id;
secret_ = secret;
+ gcm_store_->SetDeviceCredentials(android_id_,
+ secret_,
+ base::Bind(&MCSProbe::UpdateCallback,
+ base::Unretained(this)));
+
LOG(INFO) << "MCS login initiated.";
mcs_client_->Login(android_id_, secret_);
}
« no previous file with comments | « google_apis/gcm/engine/mcs_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698