| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 network_session_ = new net::HttpNetworkSession(*network_session_params); | 191 network_session_ = new net::HttpNetworkSession(*network_session_params); |
| 192 | 192 |
| 193 chrome_build_proto_.CopyFrom(chrome_build_proto); | 193 chrome_build_proto_.CopyFrom(chrome_build_proto); |
| 194 account_ids_ = account_ids; | 194 account_ids_ = account_ids; |
| 195 | 195 |
| 196 gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner)); | 196 gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner)); |
| 197 gservices_settings_.reset(new GServicesSettings(gcm_store_.get())); | 197 gservices_settings_.reset(new GServicesSettings(gcm_store_.get())); |
| 198 | 198 |
| 199 delegate_ = delegate; | 199 delegate_ = delegate; |
| 200 | 200 |
| 201 recorder_.SetDelegate(this); |
| 202 |
| 201 state_ = INITIALIZED; | 203 state_ = INITIALIZED; |
| 202 } | 204 } |
| 203 | 205 |
| 204 void GCMClientImpl::Load() { | 206 void GCMClientImpl::Load() { |
| 205 DCHECK_EQ(INITIALIZED, state_); | 207 DCHECK_EQ(INITIALIZED, state_); |
| 206 | 208 |
| 207 // Once the loading is completed, the check-in will be initiated. | 209 // Once the loading is completed, the check-in will be initiated. |
| 208 gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted, | 210 gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted, |
| 209 weak_ptr_factory_.GetWeakPtr())); | 211 weak_ptr_factory_.GetWeakPtr())); |
| 210 state_ = LOADING; | 212 state_ = LOADING; |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 stats.android_id = device_checkin_info_.android_id; | 614 stats.android_id = device_checkin_info_.android_id; |
| 613 recorder_.CollectActivities(&stats.recorded_activities); | 615 recorder_.CollectActivities(&stats.recorded_activities); |
| 614 | 616 |
| 615 for (RegistrationInfoMap::const_iterator it = registrations_.begin(); | 617 for (RegistrationInfoMap::const_iterator it = registrations_.begin(); |
| 616 it != registrations_.end(); ++it) { | 618 it != registrations_.end(); ++it) { |
| 617 stats.registered_app_ids.push_back(it->first); | 619 stats.registered_app_ids.push_back(it->first); |
| 618 } | 620 } |
| 619 return stats; | 621 return stats; |
| 620 } | 622 } |
| 621 | 623 |
| 624 void GCMClientImpl::OnActivityRecorded() { |
| 625 delegate_->OnActivityRecorded(); |
| 626 } |
| 627 |
| 622 void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) { | 628 void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) { |
| 623 switch (message.tag()) { | 629 switch (message.tag()) { |
| 624 case kLoginResponseTag: | 630 case kLoginResponseTag: |
| 625 DVLOG(1) << "Login response received by GCM Client. Ignoring."; | 631 DVLOG(1) << "Login response received by GCM Client. Ignoring."; |
| 626 return; | 632 return; |
| 627 case kDataMessageStanzaTag: | 633 case kDataMessageStanzaTag: |
| 628 DVLOG(1) << "A downstream message received. Processing..."; | 634 DVLOG(1) << "A downstream message received. Processing..."; |
| 629 HandleIncomingMessage(message); | 635 HandleIncomingMessage(message); |
| 630 return; | 636 return; |
| 631 default: | 637 default: |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 | 762 |
| 757 recorder_.RecordIncomingSendError( | 763 recorder_.RecordIncomingSendError( |
| 758 data_message_stanza.category(), | 764 data_message_stanza.category(), |
| 759 data_message_stanza.to(), | 765 data_message_stanza.to(), |
| 760 data_message_stanza.id()); | 766 data_message_stanza.id()); |
| 761 delegate_->OnMessageSendError(data_message_stanza.category(), | 767 delegate_->OnMessageSendError(data_message_stanza.category(), |
| 762 send_error_details); | 768 send_error_details); |
| 763 } | 769 } |
| 764 | 770 |
| 765 } // namespace gcm | 771 } // namespace gcm |
| OLD | NEW |