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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 GCMClientImpl::~GCMClientImpl() { | 169 GCMClientImpl::~GCMClientImpl() { |
170 } | 170 } |
171 | 171 |
172 void GCMClientImpl::Initialize( | 172 void GCMClientImpl::Initialize( |
173 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 173 const checkin_proto::ChromeBuildProto& chrome_build_proto, |
174 const base::FilePath& path, | 174 const base::FilePath& path, |
175 const std::vector<std::string>& account_ids, | 175 const std::vector<std::string>& account_ids, |
176 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 176 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
177 const scoped_refptr<net::URLRequestContextGetter>& | 177 const scoped_refptr<net::URLRequestContextGetter>& |
178 url_request_context_getter, | 178 url_request_context_getter, |
179 GCMClient::Delegate* delegate) { | 179 Delegate* delegate) { |
180 DCHECK_EQ(UNINITIALIZED, state_); | 180 DCHECK_EQ(UNINITIALIZED, state_); |
181 DCHECK(url_request_context_getter); | 181 DCHECK(url_request_context_getter); |
182 DCHECK(delegate); | 182 DCHECK(delegate); |
183 | 183 |
184 url_request_context_getter_ = url_request_context_getter; | 184 url_request_context_getter_ = url_request_context_getter; |
185 const net::HttpNetworkSession::Params* network_session_params = | 185 const net::HttpNetworkSession::Params* network_session_params = |
186 url_request_context_getter_->GetURLRequestContext()-> | 186 url_request_context_getter_->GetURLRequestContext()-> |
187 GetNetworkSessionParams(); | 187 GetNetworkSessionParams(); |
188 DCHECK(network_session_params); | 188 DCHECK(network_session_params); |
189 network_session_ = new net::HttpNetworkSession(*network_session_params); | 189 network_session_ = new net::HttpNetworkSession(*network_session_params); |
190 | 190 |
191 chrome_build_proto_.CopyFrom(chrome_build_proto); | 191 chrome_build_proto_.CopyFrom(chrome_build_proto); |
192 account_ids_ = account_ids; | 192 account_ids_ = account_ids; |
193 | 193 |
194 gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner)); | 194 gcm_store_.reset(new GCMStoreImpl(path, blocking_task_runner)); |
195 | 195 |
196 delegate_ = delegate; | 196 delegate_ = delegate; |
197 | 197 |
198 recorder_.SetDelegate(this); | |
199 | |
200 state_ = INITIALIZED; | 198 state_ = INITIALIZED; |
201 } | 199 } |
202 | 200 |
203 void GCMClientImpl::Load() { | 201 void GCMClientImpl::Load() { |
204 DCHECK_EQ(INITIALIZED, state_); | 202 DCHECK_EQ(INITIALIZED, state_); |
205 | 203 |
206 // Once the loading is completed, the check-in will be initiated. | 204 // Once the loading is completed, the check-in will be initiated. |
207 gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted, | 205 gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted, |
208 weak_ptr_factory_.GetWeakPtr())); | 206 weak_ptr_factory_.GetWeakPtr())); |
209 state_ = LOADING; | 207 state_ = LOADING; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 stats.android_id = device_checkin_info_.android_id; | 620 stats.android_id = device_checkin_info_.android_id; |
623 recorder_.CollectActivities(&stats.recorded_activities); | 621 recorder_.CollectActivities(&stats.recorded_activities); |
624 | 622 |
625 for (RegistrationInfoMap::const_iterator it = registrations_.begin(); | 623 for (RegistrationInfoMap::const_iterator it = registrations_.begin(); |
626 it != registrations_.end(); ++it) { | 624 it != registrations_.end(); ++it) { |
627 stats.registered_app_ids.push_back(it->first); | 625 stats.registered_app_ids.push_back(it->first); |
628 } | 626 } |
629 return stats; | 627 return stats; |
630 } | 628 } |
631 | 629 |
632 void GCMClientImpl::OnActivityRecorded() { | |
633 delegate_->OnActivityRecorded(); | |
634 } | |
635 | |
636 void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) { | 630 void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) { |
637 switch (message.tag()) { | 631 switch (message.tag()) { |
638 case kLoginResponseTag: | 632 case kLoginResponseTag: |
639 DVLOG(1) << "Login response received by GCM Client. Ignoring."; | 633 DVLOG(1) << "Login response received by GCM Client. Ignoring."; |
640 return; | 634 return; |
641 case kDataMessageStanzaTag: | 635 case kDataMessageStanzaTag: |
642 DVLOG(1) << "A downstream message received. Processing..."; | 636 DVLOG(1) << "A downstream message received. Processing..."; |
643 HandleIncomingMessage(message); | 637 HandleIncomingMessage(message); |
644 return; | 638 return; |
645 default: | 639 default: |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 | 764 |
771 recorder_.RecordIncomingSendError( | 765 recorder_.RecordIncomingSendError( |
772 data_message_stanza.category(), | 766 data_message_stanza.category(), |
773 data_message_stanza.to(), | 767 data_message_stanza.to(), |
774 data_message_stanza.id()); | 768 data_message_stanza.id()); |
775 delegate_->OnMessageSendError(data_message_stanza.category(), | 769 delegate_->OnMessageSendError(data_message_stanza.category(), |
776 send_error_details); | 770 send_error_details); |
777 } | 771 } |
778 | 772 |
779 } // namespace gcm | 773 } // namespace gcm |
OLD | NEW |