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 "chrome/browser/push_messaging/push_messaging_service_impl.h" | 5 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/barrier_closure.h" | 9 #include "base/barrier_closure.h" |
10 #include "base/base64url.h" | 10 #include "base/base64url.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return base::StartsWith(app_id, kPushMessagingAppIdentifierPrefix, | 245 return base::StartsWith(app_id, kPushMessagingAppIdentifierPrefix, |
246 base::CompareCase::INSENSITIVE_ASCII); | 246 base::CompareCase::INSENSITIVE_ASCII); |
247 } | 247 } |
248 | 248 |
249 void PushMessagingServiceImpl::ShutdownHandler() { | 249 void PushMessagingServiceImpl::ShutdownHandler() { |
250 // Shutdown() should come before and it removes us from the list of app | 250 // Shutdown() should come before and it removes us from the list of app |
251 // handlers of gcm::GCMDriver so this shouldn't ever been called. | 251 // handlers of gcm::GCMDriver so this shouldn't ever been called. |
252 NOTREACHED(); | 252 NOTREACHED(); |
253 } | 253 } |
254 | 254 |
| 255 void PushMessagingServiceImpl::OnStoreReset() { |
| 256 // Delete all cached subscriptions, since they are now invalid. |
| 257 for (const auto& identifier : PushMessagingAppIdentifier::GetAll(profile_)) { |
| 258 // Clear all the subscriptions in parallel, to reduce risk that shutdown |
| 259 // occurs before we finish clearing them. |
| 260 ClearPushSubscriptionId(profile_, identifier.origin(), |
| 261 identifier.service_worker_registration_id(), |
| 262 base::Bind(&base::DoNothing)); |
| 263 // TODO(johnme): Fire pushsubscriptionchange/pushsubscriptionlost SW event. |
| 264 } |
| 265 PushMessagingAppIdentifier::DeleteAllFromPrefs(profile_); |
| 266 } |
| 267 |
255 // OnMessage methods ----------------------------------------------------------- | 268 // OnMessage methods ----------------------------------------------------------- |
256 | 269 |
257 void PushMessagingServiceImpl::OnMessage(const std::string& app_id, | 270 void PushMessagingServiceImpl::OnMessage(const std::string& app_id, |
258 const gcm::IncomingMessage& message) { | 271 const gcm::IncomingMessage& message) { |
259 // We won't have time to process and act on the message. | 272 // We won't have time to process and act on the message. |
260 // TODO(peter) This should be checked at the level of the GCMDriver, so that | 273 // TODO(peter) This should be checked at the level of the GCMDriver, so that |
261 // the message is not consumed. See https://crbug.com/612815 | 274 // the message is not consumed. See https://crbug.com/612815 |
262 if (g_browser_process->IsShuttingDown()) | 275 if (g_browser_process->IsShuttingDown()) |
263 return; | 276 return; |
264 | 277 |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 } | 972 } |
960 | 973 |
961 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() | 974 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() |
962 const { | 975 const { |
963 instance_id::InstanceIDProfileService* instance_id_profile_service = | 976 instance_id::InstanceIDProfileService* instance_id_profile_service = |
964 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); | 977 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); |
965 CHECK(instance_id_profile_service); | 978 CHECK(instance_id_profile_service); |
966 CHECK(instance_id_profile_service->driver()); | 979 CHECK(instance_id_profile_service->driver()); |
967 return instance_id_profile_service->driver(); | 980 return instance_id_profile_service->driver(); |
968 } | 981 } |
OLD | NEW |