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 ClearPushSubscriptionId(profile_, |
| 259 identifier.origin(), |
| 260 identifier.service_worker_registration_id(), |
| 261 base::Bind(&base::DoNothing)); |
| 262 // TODO(johnme): Fire pushsubscriptionchange/pushsubscriptionlost SW event. |
| 263 } |
| 264 PushMessagingAppIdentifier::DeleteAllFromPrefs(profile_); |
| 265 } |
| 266 |
255 // OnMessage methods ----------------------------------------------------------- | 267 // OnMessage methods ----------------------------------------------------------- |
256 | 268 |
257 void PushMessagingServiceImpl::OnMessage(const std::string& app_id, | 269 void PushMessagingServiceImpl::OnMessage(const std::string& app_id, |
258 const gcm::IncomingMessage& message) { | 270 const gcm::IncomingMessage& message) { |
259 // We won't have time to process and act on the message. | 271 // 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 | 272 // 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 | 273 // the message is not consumed. See https://crbug.com/612815 |
262 if (g_browser_process->IsShuttingDown()) | 274 if (g_browser_process->IsShuttingDown()) |
263 return; | 275 return; |
264 | 276 |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 } | 971 } |
960 | 972 |
961 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() | 973 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() |
962 const { | 974 const { |
963 instance_id::InstanceIDProfileService* instance_id_profile_service = | 975 instance_id::InstanceIDProfileService* instance_id_profile_service = |
964 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); | 976 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); |
965 CHECK(instance_id_profile_service); | 977 CHECK(instance_id_profile_service); |
966 CHECK(instance_id_profile_service->driver()); | 978 CHECK(instance_id_profile_service->driver()); |
967 return instance_id_profile_service->driver(); | 979 return instance_id_profile_service->driver(); |
968 } | 980 } |
OLD | NEW |