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 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 void PushMessagingServiceImpl::DidDeleteID(const std::string& app_id, | 807 void PushMessagingServiceImpl::DidDeleteID(const std::string& app_id, |
808 bool was_subscribed, | 808 bool was_subscribed, |
809 InstanceID::Result result) { | 809 InstanceID::Result result) { |
810 RecordUnsubscribeIIDResult(result); | 810 RecordUnsubscribeIIDResult(result); |
811 // DidUnsubscribe must be run asynchronously when passing a non-empty | 811 // DidUnsubscribe must be run asynchronously when passing a non-empty |
812 // |app_id_when_instance_id|, since it calls | 812 // |app_id_when_instance_id|, since it calls |
813 // InstanceIDDriver::RemoveInstanceID which deletes the InstanceID itself. | 813 // InstanceIDDriver::RemoveInstanceID which deletes the InstanceID itself. |
814 // Calling that immediately would cause a use-after-free in our caller. | 814 // Calling that immediately would cause a use-after-free in our caller. |
815 base::ThreadTaskRunnerHandle::Get()->PostTask( | 815 base::ThreadTaskRunnerHandle::Get()->PostTask( |
816 FROM_HERE, | 816 FROM_HERE, |
817 base::Bind(&PushMessagingServiceImpl::DidUnsubscribe, | 817 base::BindOnce(&PushMessagingServiceImpl::DidUnsubscribe, |
818 weak_factory_.GetWeakPtr(), app_id, was_subscribed)); | 818 weak_factory_.GetWeakPtr(), app_id, was_subscribed)); |
819 } | 819 } |
820 | 820 |
821 void PushMessagingServiceImpl::DidUnsubscribe( | 821 void PushMessagingServiceImpl::DidUnsubscribe( |
822 const std::string& app_id_when_instance_id, | 822 const std::string& app_id_when_instance_id, |
823 bool was_subscribed) { | 823 bool was_subscribed) { |
824 if (!app_id_when_instance_id.empty()) | 824 if (!app_id_when_instance_id.empty()) |
825 GetInstanceIDDriver()->RemoveInstanceID(app_id_when_instance_id); | 825 GetInstanceIDDriver()->RemoveInstanceID(app_id_when_instance_id); |
826 | 826 |
827 if (was_subscribed) | 827 if (was_subscribed) |
828 DecreasePushSubscriptionCount(1, false /* was_pending */); | 828 DecreasePushSubscriptionCount(1, false /* was_pending */); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 } | 1019 } |
1020 | 1020 |
1021 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() | 1021 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() |
1022 const { | 1022 const { |
1023 instance_id::InstanceIDProfileService* instance_id_profile_service = | 1023 instance_id::InstanceIDProfileService* instance_id_profile_service = |
1024 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); | 1024 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); |
1025 CHECK(instance_id_profile_service); | 1025 CHECK(instance_id_profile_service); |
1026 CHECK(instance_id_profile_service->driver()); | 1026 CHECK(instance_id_profile_service->driver()); |
1027 return instance_id_profile_service->driver(); | 1027 return instance_id_profile_service->driver(); |
1028 } | 1028 } |
OLD | NEW |