OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/location.h" | 6 #include "base/location.h" |
7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "components/gcm_driver/gcm_driver.h" | 9 #include "components/gcm_driver/gcm_driver.h" |
10 #include "components/invalidation/gcm_invalidation_bridge.h" | 10 #include "components/invalidation/gcm_invalidation_bridge.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 DCHECK(CalledOnValidThread()); | 273 DCHECK(CalledOnValidThread()); |
274 core_thread_task_runner_->PostTask( | 274 core_thread_task_runner_->PostTask( |
275 FROM_HERE, | 275 FROM_HERE, |
276 base::Bind(&GCMInvalidationBridge::Core::RegisterFinished, | 276 base::Bind(&GCMInvalidationBridge::Core::RegisterFinished, |
277 core_, | 277 core_, |
278 callback, | 278 callback, |
279 registration_id, | 279 registration_id, |
280 result)); | 280 result)); |
281 } | 281 } |
282 | 282 |
| 283 void GCMInvalidationBridge::Unregister() { |
| 284 DCHECK(CalledOnValidThread()); |
| 285 // No-op if GCMClient is disabled. |
| 286 if (gcm_driver_ == NULL) |
| 287 return; |
| 288 |
| 289 gcm_driver_->Unregister( |
| 290 kInvalidationsAppId, |
| 291 base::Bind(&GCMInvalidationBridge::UnregisterFinishedNoOp)); |
| 292 } |
| 293 |
| 294 // static |
| 295 void GCMInvalidationBridge::UnregisterFinishedNoOp( |
| 296 gcm::GCMClient::Result result) { |
| 297 // No-op. |
| 298 } |
| 299 |
283 void GCMInvalidationBridge::SubscribeForIncomingMessages() { | 300 void GCMInvalidationBridge::SubscribeForIncomingMessages() { |
284 // No-op if GCMClient is disabled. | 301 // No-op if GCMClient is disabled. |
285 if (gcm_driver_ == NULL) | 302 if (gcm_driver_ == NULL) |
286 return; | 303 return; |
287 | 304 |
288 DCHECK(!subscribed_for_incoming_messages_); | 305 DCHECK(!subscribed_for_incoming_messages_); |
289 gcm_driver_->AddAppHandler(kInvalidationsAppId, this); | 306 gcm_driver_->AddAppHandler(kInvalidationsAppId, this); |
290 gcm_driver_->AddConnectionObserver(this); | 307 gcm_driver_->AddConnectionObserver(this); |
291 core_thread_task_runner_->PostTask( | 308 core_thread_task_runner_->PostTask( |
292 FROM_HERE, | 309 FROM_HERE, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 } | 367 } |
351 | 368 |
352 void GCMInvalidationBridge::OnDisconnected() { | 369 void GCMInvalidationBridge::OnDisconnected() { |
353 core_thread_task_runner_->PostTask( | 370 core_thread_task_runner_->PostTask( |
354 FROM_HERE, | 371 FROM_HERE, |
355 base::Bind(&GCMInvalidationBridge::Core::OnConnectionStateChanged, | 372 base::Bind(&GCMInvalidationBridge::Core::OnConnectionStateChanged, |
356 core_, | 373 core_, |
357 false)); | 374 false)); |
358 } | 375 } |
359 | 376 |
360 | |
361 } // namespace invalidation | 377 } // namespace invalidation |
OLD | NEW |