Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 | 394 |
| 395 MCSMessage mcs_message(stanza); | 395 MCSMessage mcs_message(stanza); |
| 396 DVLOG(1) << "MCS message size: " << mcs_message.size(); | 396 DVLOG(1) << "MCS message size: " << mcs_message.size(); |
| 397 mcs_client_->SendMessage(mcs_message); | 397 mcs_client_->SendMessage(mcs_message); |
| 398 } | 398 } |
| 399 | 399 |
| 400 bool GCMClientImpl::IsReady() const { | 400 bool GCMClientImpl::IsReady() const { |
| 401 return state_ == READY; | 401 return state_ == READY; |
| 402 } | 402 } |
| 403 | 403 |
| 404 std::string GCMClientImpl::GetStateString(gcm::GCMClientImpl::State state) | |
| 405 const { | |
| 406 switch(state) { | |
| 407 case gcm::GCMClientImpl::UNINITIALIZED: | |
| 408 return "UNINITIALIZED"; | |
| 409 case gcm::GCMClientImpl::LOADING: | |
| 410 return "LOADING"; | |
| 411 case gcm::GCMClientImpl::INITIAL_DEVICE_CHECKIN: | |
| 412 return "INITIAL_DEVICE_CHECKIN"; | |
| 413 case gcm::GCMClientImpl::READY: | |
| 414 return "READY"; | |
| 415 } | |
| 416 return std::string(); | |
| 417 } | |
| 418 | |
| 419 void GCMClientImpl::GetStatistics(GCMStatistics* stats) const { | |
| 420 if (!stats) | |
| 421 return; | |
| 422 // stats->gcm_client_state = GetStateString(state_); | |
|
fgorski
2014/02/28 19:52:47
??
juyik
2014/03/01 00:21:57
This has been fixed in my newer patch.
| |
| 423 stats->connection_client_created = (mcs_client_.get() != NULL); | |
| 424 stats->connection_state = MCSClient::GetStateString(mcs_client_->state()); | |
|
fgorski
2014/02/28 19:52:47
can MCSClient be NULL here?
juyik
2014/03/01 00:21:57
Fixed in my newer patch.
| |
| 425 // TODO(juyik): add more statistics such as message metadata list, etc. | |
| 426 } | |
| 427 | |
| 404 void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) { | 428 void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) { |
| 405 switch (message.tag()) { | 429 switch (message.tag()) { |
| 406 case kLoginResponseTag: | 430 case kLoginResponseTag: |
| 407 DVLOG(1) << "Login response received by GCM Client. Ignoring."; | 431 DVLOG(1) << "Login response received by GCM Client. Ignoring."; |
| 408 return; | 432 return; |
| 409 case kDataMessageStanzaTag: | 433 case kDataMessageStanzaTag: |
| 410 DVLOG(1) << "A downstream message received. Processing..."; | 434 DVLOG(1) << "A downstream message received. Processing..."; |
| 411 HandleIncomingMessage(message); | 435 HandleIncomingMessage(message); |
| 412 return; | 436 return; |
| 413 default: | 437 default: |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 if (iter != incoming_message.data.end()) | 514 if (iter != incoming_message.data.end()) |
| 491 message_id = iter->second; | 515 message_id = iter->second; |
| 492 delegate->OnMessageSendError(app_id, message_id, SERVER_ERROR); | 516 delegate->OnMessageSendError(app_id, message_id, SERVER_ERROR); |
| 493 } | 517 } |
| 494 | 518 |
| 495 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { | 519 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { |
| 496 mcs_client_ = mcs_client.Pass(); | 520 mcs_client_ = mcs_client.Pass(); |
| 497 } | 521 } |
| 498 | 522 |
| 499 } // namespace gcm | 523 } // namespace gcm |
| OLD | NEW |