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

Side by Side Diff: google_apis/gcm/gcm_client_impl.cc

Issue 176823009: Show device information in chrome://gcm-internals page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make string format portable. Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « google_apis/gcm/gcm_client_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "google_apis/gcm/gcm_client_impl.h" 5 #include "google_apis/gcm/gcm_client_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 mcs_proto::AppData* app_data = stanza.add_app_data(); 406 mcs_proto::AppData* app_data = stanza.add_app_data();
407 app_data->set_key(iter->first); 407 app_data->set_key(iter->first);
408 app_data->set_value(iter->second); 408 app_data->set_value(iter->second);
409 } 409 }
410 410
411 MCSMessage mcs_message(stanza); 411 MCSMessage mcs_message(stanza);
412 DVLOG(1) << "MCS message size: " << mcs_message.size(); 412 DVLOG(1) << "MCS message size: " << mcs_message.size();
413 mcs_client_->SendMessage(mcs_message); 413 mcs_client_->SendMessage(mcs_message);
414 } 414 }
415 415
416 std::string GCMClientImpl::GetStateString() const {
417 switch(state_) {
418 case GCMClientImpl::INITIALIZED:
419 return "INITIALIZED";
420 case GCMClientImpl::UNINITIALIZED:
421 return "UNINITIALIZED";
422 case GCMClientImpl::LOADING:
423 return "LOADING";
424 case GCMClientImpl::INITIAL_DEVICE_CHECKIN:
425 return "INITIAL_DEVICE_CHECKIN";
426 case GCMClientImpl::READY:
427 return "READY";
428 default:
429 NOTREACHED();
430 return std::string();
431 }
432 }
433
434 GCMClient::GCMStatistics GCMClientImpl::GetStatistics() const {
435 GCMClient::GCMStatistics stats;
436 stats.gcm_client_state = GCMClientImpl::GetStateString();
437 stats.connection_client_created = mcs_client_.get() != NULL;
438 if (mcs_client_.get()) {
439 stats.connection_state = mcs_client_->GetStateString();
440 // TODO(juyik): add more statistics such as message metadata list, etc.
441 }
442 if (device_checkin_info_.android_id > 0)
443 stats.android_id = device_checkin_info_.android_id;
444 return stats;
445 }
446
416 void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) { 447 void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) {
417 switch (message.tag()) { 448 switch (message.tag()) {
418 case kLoginResponseTag: 449 case kLoginResponseTag:
419 DVLOG(1) << "Login response received by GCM Client. Ignoring."; 450 DVLOG(1) << "Login response received by GCM Client. Ignoring.";
420 return; 451 return;
421 case kDataMessageStanzaTag: 452 case kDataMessageStanzaTag:
422 DVLOG(1) << "A downstream message received. Processing..."; 453 DVLOG(1) << "A downstream message received. Processing...";
423 HandleIncomingMessage(message); 454 HandleIncomingMessage(message);
424 return; 455 return;
425 default: 456 default:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 if (iter != incoming_message.data.end()) 533 if (iter != incoming_message.data.end())
503 message_id = iter->second; 534 message_id = iter->second;
504 delegate->OnMessageSendError(app_id, message_id, SERVER_ERROR); 535 delegate->OnMessageSendError(app_id, message_id, SERVER_ERROR);
505 } 536 }
506 537
507 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { 538 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) {
508 mcs_client_ = mcs_client.Pass(); 539 mcs_client_ = mcs_client.Pass();
509 } 540 }
510 541
511 } // namespace gcm 542 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/gcm_client_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698