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

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: Rebase 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
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 if (sender_id.empty())
653 unregister_callback); 653 unregister_callback.Run(GCMClient::INVALID_PARAMETER);
mlamouri (slow - plz ping) 2015/03/13 16:25:49 Is there any chance you could handle that case whe
johnme 2015/03/13 17:21:12 I want to re-use the logic for getting the PMAI, c
mlamouri (slow - plz ping) 2015/03/13 17:32:13 It's clearer but I would suggest to not do that. I
654 else
655 GetGCMDriver()->UnregisterWithSenderId(app_id_guid, sender_id,
656 unregister_callback);
654 #else 657 #else
655 GetGCMDriver()->Unregister(app_id_guid, unregister_callback); 658 GetGCMDriver()->Unregister(app_id_guid, unregister_callback);
656 #endif 659 #endif
657 } 660 }
658 661
659 void PushMessagingServiceImpl::DidUnregister( 662 void PushMessagingServiceImpl::DidUnregister(
660 bool was_registered, 663 bool was_registered,
661 const content::PushMessagingService::UnregisterCallback& callback, 664 const content::PushMessagingService::UnregisterCallback& callback,
662 gcm::GCMClient::Result result) { 665 gcm::GCMClient::Result result) {
663 if (was_registered) 666 if (was_registered)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 weak_factory_.GetWeakPtr(), id, barrier_closure)); 737 weak_factory_.GetWeakPtr(), id, barrier_closure));
735 } 738 }
736 } 739 }
737 740
738 void PushMessagingServiceImpl::UnregisterBecausePermissionRevoked( 741 void PushMessagingServiceImpl::UnregisterBecausePermissionRevoked(
739 const PushMessagingApplicationId& id, const base::Closure& closure, 742 const PushMessagingApplicationId& id, const base::Closure& closure,
740 const std::string& sender_id, bool success, bool not_found) { 743 const std::string& sender_id, bool success, bool not_found) {
741 base::Closure barrier_closure = base::BarrierClosure(2, closure); 744 base::Closure barrier_closure = base::BarrierClosure(2, closure);
742 745
743 // Unregister the PushMessagingApplicationId with the push service. 746 // Unregister the PushMessagingApplicationId with the push service.
747 // It's possible for GetSenderId to have failed and sender_id to be empty, if
748 // cookies (and the SW database) for an origin got cleared before permissions
749 // are cleared for the origin (crbug.com/464328). In that case Unregister will
mlamouri (slow - plz ping) 2015/03/13 16:25:49 This CL is fixing the bug you list. If someone car
johnme 2015/03/13 17:21:12 Done.
750 // just delete the application ID to block future messages.
751 // TODO(johnme): Auto-unregister before SW DB is cleared (crbug.com/402458).
mlamouri (slow - plz ping) 2015/03/13 16:25:49 https://crbug.com/....
johnme 2015/03/13 17:21:12 Done (does your editor linkify links, but only if
mlamouri (slow - plz ping) 2015/03/13 17:32:13 I have no idea what my editors would do but "crbug
744 Unregister(id.app_id_guid(), sender_id, 752 Unregister(id.app_id_guid(), sender_id,
745 base::Bind(&UnregisterCallbackToClosure, barrier_closure)); 753 base::Bind(&UnregisterCallbackToClosure, barrier_closure));
746 754
747 // Clear the associated service worker push registration id. 755 // Clear the associated service worker push registration id.
748 ClearPushRegistrationID(profile_, id.origin(), 756 ClearPushRegistrationID(profile_, id.origin(),
749 id.service_worker_registration_id(), barrier_closure); 757 id.service_worker_registration_id(), barrier_closure);
750 } 758 }
751 759
752 void PushMessagingServiceImpl::SetContentSettingChangedCallbackForTesting( 760 void PushMessagingServiceImpl::SetContentSettingChangedCallbackForTesting(
753 const base::Closure& callback) { 761 const base::Closure& callback) {
(...skipping 17 matching lines...) Expand all
771 CONTENT_SETTING_ALLOW; 779 CONTENT_SETTING_ALLOW;
772 } 780 }
773 781
774 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { 782 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const {
775 gcm::GCMProfileService* gcm_profile_service = 783 gcm::GCMProfileService* gcm_profile_service =
776 gcm::GCMProfileServiceFactory::GetForProfile(profile_); 784 gcm::GCMProfileServiceFactory::GetForProfile(profile_);
777 CHECK(gcm_profile_service); 785 CHECK(gcm_profile_service);
778 CHECK(gcm_profile_service->driver()); 786 CHECK(gcm_profile_service->driver());
779 return gcm_profile_service->driver(); 787 return gcm_profile_service->driver();
780 } 788 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698