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/base64.h" | 5 #include "base/base64.h" |
6 #include "base/i18n/time_formatting.h" | 6 #include "base/i18n/time_formatting.h" |
| 7 #include "base/location.h" |
7 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
8 #include "base/sha1.h" | 9 #include "base/sha1.h" |
| 10 #include "base/single_thread_task_runner.h" |
9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/thread_task_runner_handle.h" |
11 #if !defined(OS_ANDROID) | 14 #if !defined(OS_ANDROID) |
12 // channel_common.proto defines ANDROID constant that conflicts with Android | 15 // channel_common.proto defines ANDROID constant that conflicts with Android |
13 // build. At the same time TiclInvalidationService is not used on Android so it | 16 // build. At the same time TiclInvalidationService is not used on Android so it |
14 // is safe to exclude these protos from Android build. | 17 // is safe to exclude these protos from Android build. |
15 #include "google/cacheinvalidation/android_channel.pb.h" | 18 #include "google/cacheinvalidation/android_channel.pb.h" |
16 #include "google/cacheinvalidation/channel_common.pb.h" | 19 #include "google/cacheinvalidation/channel_common.pb.h" |
17 #include "google/cacheinvalidation/types.pb.h" | 20 #include "google/cacheinvalidation/types.pb.h" |
18 #endif | 21 #endif |
19 #include "components/invalidation/gcm_network_channel.h" | 22 #include "components/invalidation/gcm_network_channel.h" |
20 #include "components/invalidation/gcm_network_channel_delegate.h" | 23 #include "components/invalidation/gcm_network_channel_delegate.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 RequestAccessToken(); | 142 RequestAccessToken(); |
140 } else { | 143 } else { |
141 DVLOG(2) << "Register failed: " << result; | 144 DVLOG(2) << "Register failed: " << result; |
142 // Retry in case of transient error. | 145 // Retry in case of transient error. |
143 switch (result) { | 146 switch (result) { |
144 case gcm::GCMClient::NETWORK_ERROR: | 147 case gcm::GCMClient::NETWORK_ERROR: |
145 case gcm::GCMClient::SERVER_ERROR: | 148 case gcm::GCMClient::SERVER_ERROR: |
146 case gcm::GCMClient::TTL_EXCEEDED: | 149 case gcm::GCMClient::TTL_EXCEEDED: |
147 case gcm::GCMClient::UNKNOWN_ERROR: { | 150 case gcm::GCMClient::UNKNOWN_ERROR: { |
148 register_backoff_entry_->InformOfRequest(false); | 151 register_backoff_entry_->InformOfRequest(false); |
149 base::MessageLoop::current()->PostDelayedTask( | 152 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
150 FROM_HERE, | 153 FROM_HERE, base::Bind(&GCMNetworkChannel::Register, |
151 base::Bind(&GCMNetworkChannel::Register, | 154 weak_factory_.GetWeakPtr()), |
152 weak_factory_.GetWeakPtr()), | |
153 register_backoff_entry_->GetTimeUntilRelease()); | 155 register_backoff_entry_->GetTimeUntilRelease()); |
154 break; | 156 break; |
155 } | 157 } |
156 default: | 158 default: |
157 break; | 159 break; |
158 } | 160 } |
159 } | 161 } |
160 diagnostic_info_.registration_id_ = registration_id_; | 162 diagnostic_info_.registration_id_ = registration_id_; |
161 diagnostic_info_.registration_result_ = result; | 163 diagnostic_info_.registration_result_ = result; |
162 } | 164 } |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 ENUM_CASE(gcm::GCMClient::UNKNOWN_ERROR); | 450 ENUM_CASE(gcm::GCMClient::UNKNOWN_ERROR); |
449 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER); | 451 ENUM_CASE(gcm::GCMClient::INVALID_PARAMETER); |
450 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING); | 452 ENUM_CASE(gcm::GCMClient::ASYNC_OPERATION_PENDING); |
451 ENUM_CASE(gcm::GCMClient::GCM_DISABLED); | 453 ENUM_CASE(gcm::GCMClient::GCM_DISABLED); |
452 } | 454 } |
453 NOTREACHED(); | 455 NOTREACHED(); |
454 return ""; | 456 return ""; |
455 } | 457 } |
456 | 458 |
457 } // namespace syncer | 459 } // namespace syncer |
OLD | NEW |