| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 GCMClientImpl::~GCMClientImpl() { | 171 GCMClientImpl::~GCMClientImpl() { |
| 172 } | 172 } |
| 173 | 173 |
| 174 void GCMClientImpl::Initialize( | 174 void GCMClientImpl::Initialize( |
| 175 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 175 const checkin_proto::ChromeBuildProto& chrome_build_proto, |
| 176 const base::FilePath& path, | 176 const base::FilePath& path, |
| 177 const std::vector<std::string>& account_ids, | 177 const std::vector<std::string>& account_ids, |
| 178 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 178 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
| 179 const scoped_refptr<net::URLRequestContextGetter>& | 179 const scoped_refptr<net::URLRequestContextGetter>& |
| 180 url_request_context_getter, | 180 url_request_context_getter, |
| 181 Delegate* delegate) { | 181 GCMClient::Delegate* delegate) { |
| 182 DCHECK_EQ(UNINITIALIZED, state_); | 182 DCHECK_EQ(UNINITIALIZED, state_); |
| 183 DCHECK(url_request_context_getter); | 183 DCHECK(url_request_context_getter); |
| 184 DCHECK(delegate); | 184 DCHECK(delegate); |
| 185 | 185 |
| 186 url_request_context_getter_ = url_request_context_getter; | 186 url_request_context_getter_ = url_request_context_getter; |
| 187 const net::HttpNetworkSession::Params* network_session_params = | 187 const net::HttpNetworkSession::Params* network_session_params = |
| 188 url_request_context_getter_->GetURLRequestContext()-> | 188 url_request_context_getter_->GetURLRequestContext()-> |
| 189 GetNetworkSessionParams(); | 189 GetNetworkSessionParams(); |
| 190 DCHECK(network_session_params); | 190 DCHECK(network_session_params); |
| 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 |