Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/browser/push_messaging/push_messaging_service_impl.cc

Issue 990283002: Push API: Prevent DCHECK when clear permissions after clear SW DB (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@retrycallback
Patch Set: Fix typo Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <bitset> 7 #include <bitset>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/barrier_closure.h" 10 #include "base/barrier_closure.h"
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 bool was_registered = application_id.IsValid(); 642 bool was_registered = application_id.IsValid();
643 if (was_registered) 643 if (was_registered)
644 application_id.DeleteFromDisk(profile_); 644 application_id.DeleteFromDisk(profile_);
645 645
646 const auto& unregister_callback = 646 const auto& unregister_callback =
647 base::Bind(&PushMessagingServiceImpl::DidUnregister, 647 base::Bind(&PushMessagingServiceImpl::DidUnregister,
648 weak_factory_.GetWeakPtr(), 648 weak_factory_.GetWeakPtr(),
649 was_registered, callback); 649 was_registered, callback);
650 #if defined(OS_ANDROID) 650 #if defined(OS_ANDROID)
651 // On Android the backend is different, and requires the original sender_id. 651 // On Android the backend is different, and requires the original sender_id.
652 GetGCMDriver()->UnregisterWithSenderId(app_id_guid, sender_id, 652 // UnregisterBecausePermissionRevoked sometimes calls us with an empty one.
653 unregister_callback); 653 if (sender_id.empty())
654 unregister_callback.Run(gcm::GCMClient::INVALID_PARAMETER);
655 else
656 GetGCMDriver()->UnregisterWithSenderId(app_id_guid, sender_id,
657 unregister_callback);
654 #else 658 #else
655 GetGCMDriver()->Unregister(app_id_guid, unregister_callback); 659 GetGCMDriver()->Unregister(app_id_guid, unregister_callback);
656 #endif 660 #endif
657 } 661 }
658 662
659 void PushMessagingServiceImpl::DidUnregister( 663 void PushMessagingServiceImpl::DidUnregister(
660 bool was_registered, 664 bool was_registered,
661 const content::PushMessagingService::UnregisterCallback& callback, 665 const content::PushMessagingService::UnregisterCallback& callback,
662 gcm::GCMClient::Result result) { 666 gcm::GCMClient::Result result) {
663 if (was_registered) 667 if (was_registered)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 weak_factory_.GetWeakPtr(), id, barrier_closure)); 738 weak_factory_.GetWeakPtr(), id, barrier_closure));
735 } 739 }
736 } 740 }
737 741
738 void PushMessagingServiceImpl::UnregisterBecausePermissionRevoked( 742 void PushMessagingServiceImpl::UnregisterBecausePermissionRevoked(
739 const PushMessagingApplicationId& id, const base::Closure& closure, 743 const PushMessagingApplicationId& id, const base::Closure& closure,
740 const std::string& sender_id, bool success, bool not_found) { 744 const std::string& sender_id, bool success, bool not_found) {
741 base::Closure barrier_closure = base::BarrierClosure(2, closure); 745 base::Closure barrier_closure = base::BarrierClosure(2, closure);
742 746
743 // Unregister the PushMessagingApplicationId with the push service. 747 // Unregister the PushMessagingApplicationId with the push service.
748 // It's possible for GetSenderId to have failed and sender_id to be empty, if
749 // cookies (and the SW database) for an origin got cleared before permissions
750 // are cleared for the origin. In that case Unregister will just delete the
751 // application ID to block future messages.
752 // TODO(johnme): Auto-unregister before SW DB is cleared
753 // (https://crbug.com/402458).
744 Unregister(id.app_id_guid(), sender_id, 754 Unregister(id.app_id_guid(), sender_id,
745 base::Bind(&UnregisterCallbackToClosure, barrier_closure)); 755 base::Bind(&UnregisterCallbackToClosure, barrier_closure));
746 756
747 // Clear the associated service worker push registration id. 757 // Clear the associated service worker push registration id.
748 ClearPushRegistrationID(profile_, id.origin(), 758 ClearPushRegistrationID(profile_, id.origin(),
749 id.service_worker_registration_id(), barrier_closure); 759 id.service_worker_registration_id(), barrier_closure);
750 } 760 }
751 761
752 void PushMessagingServiceImpl::SetContentSettingChangedCallbackForTesting( 762 void PushMessagingServiceImpl::SetContentSettingChangedCallbackForTesting(
753 const base::Closure& callback) { 763 const base::Closure& callback) {
(...skipping 17 matching lines...) Expand all
771 CONTENT_SETTING_ALLOW; 781 CONTENT_SETTING_ALLOW;
772 } 782 }
773 783
774 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { 784 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const {
775 gcm::GCMProfileService* gcm_profile_service = 785 gcm::GCMProfileService* gcm_profile_service =
776 gcm::GCMProfileServiceFactory::GetForProfile(profile_); 786 gcm::GCMProfileServiceFactory::GetForProfile(profile_);
777 CHECK(gcm_profile_service); 787 CHECK(gcm_profile_service);
778 CHECK(gcm_profile_service->driver()); 788 CHECK(gcm_profile_service->driver());
779 return gcm_profile_service->driver(); 789 return gcm_profile_service->driver();
780 } 790 }
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698