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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 pending_unregistrations_deleter_(&pending_unregistrations_), | 119 pending_unregistrations_deleter_(&pending_unregistrations_), |
120 weak_ptr_factory_(this) { | 120 weak_ptr_factory_(this) { |
121 } | 121 } |
122 | 122 |
123 GCMClientImpl::~GCMClientImpl() { | 123 GCMClientImpl::~GCMClientImpl() { |
124 } | 124 } |
125 | 125 |
126 void GCMClientImpl::Initialize( | 126 void GCMClientImpl::Initialize( |
127 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 127 const checkin_proto::ChromeBuildProto& chrome_build_proto, |
128 const base::FilePath& path, | 128 const base::FilePath& path, |
| 129 const std::vector<std::string>& account_ids, |
129 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 130 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
130 const scoped_refptr<net::URLRequestContextGetter>& | 131 const scoped_refptr<net::URLRequestContextGetter>& |
131 url_request_context_getter, | 132 url_request_context_getter, |
132 Delegate* delegate) { | 133 Delegate* delegate) { |
133 DCHECK_EQ(UNINITIALIZED, state_); | 134 DCHECK_EQ(UNINITIALIZED, state_); |
134 DCHECK(url_request_context_getter); | 135 DCHECK(url_request_context_getter); |
135 DCHECK(delegate); | 136 DCHECK(delegate); |
136 | 137 |
137 chrome_build_proto_.CopyFrom(chrome_build_proto); | 138 chrome_build_proto_.CopyFrom(chrome_build_proto); |
138 url_request_context_getter_ = url_request_context_getter; | 139 url_request_context_getter_ = url_request_context_getter; |
| 140 account_ids_ = account_ids; |
139 | 141 |
140 gcm_store_.reset(new GCMStoreImpl(false, path, blocking_task_runner)); | 142 gcm_store_.reset(new GCMStoreImpl(false, path, blocking_task_runner)); |
141 gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted, | 143 gcm_store_->Load(base::Bind(&GCMClientImpl::OnLoadCompleted, |
142 weak_ptr_factory_.GetWeakPtr())); | 144 weak_ptr_factory_.GetWeakPtr())); |
143 | 145 |
144 delegate_ = delegate; | 146 delegate_ = delegate; |
145 | 147 |
146 // |mcs_client_| might already be set for testing at this point. No need to | 148 // |mcs_client_| might already be set for testing at this point. No need to |
147 // create a |connection_factory_|. | 149 // create a |connection_factory_|. |
148 if (!mcs_client_.get()) { | 150 if (!mcs_client_.get()) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 device_checkin_info_.secret); | 226 device_checkin_info_.secret); |
225 } | 227 } |
226 | 228 |
227 void GCMClientImpl::ResetState() { | 229 void GCMClientImpl::ResetState() { |
228 state_ = UNINITIALIZED; | 230 state_ = UNINITIALIZED; |
229 // TODO(fgorski): reset all of the necessart objects and start over. | 231 // TODO(fgorski): reset all of the necessart objects and start over. |
230 } | 232 } |
231 | 233 |
232 void GCMClientImpl::StartCheckin(const CheckinInfo& checkin_info) { | 234 void GCMClientImpl::StartCheckin(const CheckinInfo& checkin_info) { |
233 checkin_request_.reset( | 235 checkin_request_.reset( |
234 new CheckinRequest( | 236 new CheckinRequest(base::Bind(&GCMClientImpl::OnCheckinCompleted, |
235 base::Bind(&GCMClientImpl::OnCheckinCompleted, | 237 weak_ptr_factory_.GetWeakPtr()), |
236 weak_ptr_factory_.GetWeakPtr()), | 238 kDefaultBackoffPolicy, |
237 kDefaultBackoffPolicy, | 239 chrome_build_proto_, |
238 chrome_build_proto_, | 240 checkin_info.android_id, |
239 checkin_info.android_id, | 241 checkin_info.secret, |
240 checkin_info.secret, | 242 account_ids_, |
241 url_request_context_getter_)); | 243 url_request_context_getter_)); |
242 checkin_request_->Start(); | 244 checkin_request_->Start(); |
243 } | 245 } |
244 | 246 |
245 void GCMClientImpl::OnCheckinCompleted(uint64 android_id, | 247 void GCMClientImpl::OnCheckinCompleted(uint64 android_id, |
246 uint64 security_token) { | 248 uint64 security_token) { |
247 checkin_request_.reset(); | 249 checkin_request_.reset(); |
248 | 250 |
249 CheckinInfo checkin_info; | 251 CheckinInfo checkin_info; |
250 checkin_info.android_id = android_id; | 252 checkin_info.android_id = android_id; |
251 checkin_info.secret = security_token; | 253 checkin_info.secret = security_token; |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 if (iter != incoming_message.data.end()) | 489 if (iter != incoming_message.data.end()) |
488 message_id = iter->second; | 490 message_id = iter->second; |
489 delegate->OnMessageSendError(app_id, message_id, SERVER_ERROR); | 491 delegate->OnMessageSendError(app_id, message_id, SERVER_ERROR); |
490 } | 492 } |
491 | 493 |
492 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { | 494 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { |
493 mcs_client_ = mcs_client.Pass(); | 495 mcs_client_ = mcs_client.Pass(); |
494 } | 496 } |
495 | 497 |
496 } // namespace gcm | 498 } // namespace gcm |
OLD | NEW |