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 Delegate* delegate) { | 179 GCMClient::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 |
198 state_ = INITIALIZED; | 200 state_ = INITIALIZED; |
199 } | 201 } |
200 | 202 |
201 void GCMClientImpl::Load() { | 203 void GCMClientImpl::Load() { |
202 DCHECK_EQ(INITIALIZED, state_); | 204 DCHECK_EQ(INITIALIZED, state_); |
203 | 205 |
204 // Once the loading is completed, the check-in will be initiated. | 206 // Once the loading is completed, the check-in will be initiated. |
205 gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted, | 207 gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted, |
206 weak_ptr_factory_.GetWeakPtr())); | 208 weak_ptr_factory_.GetWeakPtr())); |
207 state_ = LOADING; | 209 state_ = LOADING; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 stats.android_id = device_checkin_info_.android_id; | 622 stats.android_id = device_checkin_info_.android_id; |
621 recorder_.CollectActivities(&stats.recorded_activities); | 623 recorder_.CollectActivities(&stats.recorded_activities); |
622 | 624 |
623 for (RegistrationInfoMap::const_iterator it = registrations_.begin(); | 625 for (RegistrationInfoMap::const_iterator it = registrations_.begin(); |
624 it != registrations_.end(); ++it) { | 626 it != registrations_.end(); ++it) { |
625 stats.registered_app_ids.push_back(it->first); | 627 stats.registered_app_ids.push_back(it->first); |
626 } | 628 } |
627 return stats; | 629 return stats; |
628 } | 630 } |
629 | 631 |
| 632 void GCMClientImpl::OnActivityRecorded() { |
| 633 delegate_->OnActivityRecorded(); |
| 634 } |
| 635 |
630 void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) { | 636 void GCMClientImpl::OnMessageReceivedFromMCS(const gcm::MCSMessage& message) { |
631 switch (message.tag()) { | 637 switch (message.tag()) { |
632 case kLoginResponseTag: | 638 case kLoginResponseTag: |
633 DVLOG(1) << "Login response received by GCM Client. Ignoring."; | 639 DVLOG(1) << "Login response received by GCM Client. Ignoring."; |
634 return; | 640 return; |
635 case kDataMessageStanzaTag: | 641 case kDataMessageStanzaTag: |
636 DVLOG(1) << "A downstream message received. Processing..."; | 642 DVLOG(1) << "A downstream message received. Processing..."; |
637 HandleIncomingMessage(message); | 643 HandleIncomingMessage(message); |
638 return; | 644 return; |
639 default: | 645 default: |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 | 770 |
765 recorder_.RecordIncomingSendError( | 771 recorder_.RecordIncomingSendError( |
766 data_message_stanza.category(), | 772 data_message_stanza.category(), |
767 data_message_stanza.to(), | 773 data_message_stanza.to(), |
768 data_message_stanza.id()); | 774 data_message_stanza.id()); |
769 delegate_->OnMessageSendError(data_message_stanza.category(), | 775 delegate_->OnMessageSendError(data_message_stanza.category(), |
770 send_error_details); | 776 send_error_details); |
771 } | 777 } |
772 | 778 |
773 } // namespace gcm | 779 } // namespace gcm |
OLD | NEW |