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

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

Issue 2749823002: Restore KeyedServiceFactory diagnostics for context use-after-destroy. (Closed)
Patch Set: Add test fixes, more service shutdown fixes. Created 3 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 <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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 : profile_(profile), 156 : profile_(profile),
157 push_subscription_count_(0), 157 push_subscription_count_(0),
158 pending_push_subscription_count_(0), 158 pending_push_subscription_count_(0),
159 notification_manager_(profile), 159 notification_manager_(profile),
160 push_messaging_service_observer_(PushMessagingServiceObserver::Create()), 160 push_messaging_service_observer_(PushMessagingServiceObserver::Create()),
161 weak_factory_(this) { 161 weak_factory_(this) {
162 DCHECK(profile); 162 DCHECK(profile);
163 HostContentSettingsMapFactory::GetForProfile(profile_)->AddObserver(this); 163 HostContentSettingsMapFactory::GetForProfile(profile_)->AddObserver(this);
164 } 164 }
165 165
166 PushMessagingServiceImpl::~PushMessagingServiceImpl() { 166 PushMessagingServiceImpl::~PushMessagingServiceImpl() = default;
167 HostContentSettingsMapFactory::GetForProfile(profile_)->RemoveObserver(this);
168 }
169 167
170 void PushMessagingServiceImpl::IncreasePushSubscriptionCount(int add, 168 void PushMessagingServiceImpl::IncreasePushSubscriptionCount(int add,
171 bool is_pending) { 169 bool is_pending) {
172 DCHECK(add > 0); 170 DCHECK(add > 0);
173 if (push_subscription_count_ + pending_push_subscription_count_ == 0) { 171 if (push_subscription_count_ + pending_push_subscription_count_ == 0) {
174 GetGCMDriver()->AddAppHandler(kPushMessagingAppIdentifierPrefix, this); 172 GetGCMDriver()->AddAppHandler(kPushMessagingAppIdentifierPrefix, this);
175 } 173 }
176 if (is_pending) { 174 if (is_pending) {
177 pending_push_subscription_count_ += add; 175 pending_push_subscription_count_ += add;
178 } else { 176 } else {
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 917
920 void PushMessagingServiceImpl::SetContentSettingChangedCallbackForTesting( 918 void PushMessagingServiceImpl::SetContentSettingChangedCallbackForTesting(
921 const base::Closure& callback) { 919 const base::Closure& callback) {
922 content_setting_changed_callback_for_testing_ = callback; 920 content_setting_changed_callback_for_testing_ = callback;
923 } 921 }
924 922
925 // KeyedService methods ------------------------------------------------------- 923 // KeyedService methods -------------------------------------------------------
926 924
927 void PushMessagingServiceImpl::Shutdown() { 925 void PushMessagingServiceImpl::Shutdown() {
928 GetGCMDriver()->RemoveAppHandler(kPushMessagingAppIdentifierPrefix); 926 GetGCMDriver()->RemoveAppHandler(kPushMessagingAppIdentifierPrefix);
927 HostContentSettingsMapFactory::GetForProfile(profile_)->RemoveObserver(this);
929 } 928 }
930 929
931 // BackgroundTrigger methods --------------------------------------------------- 930 // BackgroundTrigger methods ---------------------------------------------------
932 base::string16 PushMessagingServiceImpl::GetName() { 931 base::string16 PushMessagingServiceImpl::GetName() {
933 return l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_BACKGROUND_SERVICE_NAME); 932 return l10n_util::GetStringUTF16(IDS_NOTIFICATIONS_BACKGROUND_SERVICE_NAME);
934 } 933 }
935 934
936 gfx::ImageSkia* PushMessagingServiceImpl::GetIcon() { 935 gfx::ImageSkia* PushMessagingServiceImpl::GetIcon() {
937 return nullptr; 936 return nullptr;
938 } 937 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 } 988 }
990 989
991 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() 990 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver()
992 const { 991 const {
993 instance_id::InstanceIDProfileService* instance_id_profile_service = 992 instance_id::InstanceIDProfileService* instance_id_profile_service =
994 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); 993 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_);
995 CHECK(instance_id_profile_service); 994 CHECK(instance_id_profile_service);
996 CHECK(instance_id_profile_service->driver()); 995 CHECK(instance_id_profile_service->driver());
997 return instance_id_profile_service->driver(); 996 return instance_id_profile_service->driver();
998 } 997 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698