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

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

Issue 996813002: Deflake PushMessagingBrowserTest.DenyPushPermissionUnregisters & friends (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use scoped_refptr 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 #ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ 5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_
6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ 6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_
7 7
8 #include "base/callback.h"
8 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
10 #include "components/content_settings/core/browser/content_settings_observer.h" 11 #include "components/content_settings/core/browser/content_settings_observer.h"
11 #include "components/content_settings/core/common/content_settings.h" 12 #include "components/content_settings/core/common/content_settings.h"
12 #include "components/gcm_driver/gcm_app_handler.h" 13 #include "components/gcm_driver/gcm_app_handler.h"
13 #include "components/gcm_driver/gcm_client.h" 14 #include "components/gcm_driver/gcm_client.h"
14 #include "components/keyed_service/core/keyed_service.h" 15 #include "components/keyed_service/core/keyed_service.h"
15 #include "content/public/browser/push_messaging_service.h" 16 #include "content/public/browser/push_messaging_service.h"
16 #include "content/public/common/push_messaging_status.h" 17 #include "content/public/common/push_messaging_status.h"
17 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi ssionStatus.h" 18 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi ssionStatus.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 // content_settings::Observer implementation. 82 // content_settings::Observer implementation.
82 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, 83 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern,
83 const ContentSettingsPattern& secondary_pattern, 84 const ContentSettingsPattern& secondary_pattern,
84 ContentSettingsType content_type, 85 ContentSettingsType content_type,
85 std::string resource_identifier) override; 86 std::string resource_identifier) override;
86 87
87 // KeyedService implementation. 88 // KeyedService implementation.
88 void Shutdown() override; 89 void Shutdown() override;
89 90
91 void SetContentSettingChangedCallbackForTesting(
92 const base::Closure& callback);
93
90 private: 94 private:
91 // A registration is pending until it has succeeded or failed. 95 // A registration is pending until it has succeeded or failed.
92 void IncreasePushRegistrationCount(int add, bool is_pending); 96 void IncreasePushRegistrationCount(int add, bool is_pending);
93 void DecreasePushRegistrationCount(int subtract, bool was_pending); 97 void DecreasePushRegistrationCount(int subtract, bool was_pending);
94 98
95 // OnMessage methods --------------------------------------------------------- 99 // OnMessage methods ---------------------------------------------------------
96 100
97 void DeliverMessageCallback(const std::string& app_id_guid, 101 void DeliverMessageCallback(const std::string& app_id_guid,
98 const GURL& requesting_origin, 102 const GURL& requesting_origin,
99 int64 service_worker_registration_id, 103 int64 service_worker_registration_id,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 const std::string& sender_id, 144 const std::string& sender_id,
141 const content::PushMessagingService::UnregisterCallback&); 145 const content::PushMessagingService::UnregisterCallback&);
142 146
143 void DidUnregister(bool was_registered, 147 void DidUnregister(bool was_registered,
144 const content::PushMessagingService::UnregisterCallback&, 148 const content::PushMessagingService::UnregisterCallback&,
145 gcm::GCMClient::Result result); 149 gcm::GCMClient::Result result);
146 150
147 // OnContentSettingChanged methods ------------------------------------------- 151 // OnContentSettingChanged methods -------------------------------------------
148 152
149 void UnregisterBecausePermissionRevoked(const PushMessagingApplicationId& id, 153 void UnregisterBecausePermissionRevoked(const PushMessagingApplicationId& id,
154 const base::Closure& closure,
150 const std::string& sender_id, 155 const std::string& sender_id,
151 bool success, bool not_found); 156 bool success, bool not_found);
152 157
153 // Helper methods ------------------------------------------------------------ 158 // Helper methods ------------------------------------------------------------
154 159
155 // Checks if a given origin is allowed to use Push. 160 // Checks if a given origin is allowed to use Push.
156 bool HasPermission(const GURL& origin); 161 bool HasPermission(const GURL& origin);
157 162
158 gcm::GCMDriver* GetGCMDriver() const; 163 gcm::GCMDriver* GetGCMDriver() const;
159 164
160 Profile* profile_; 165 Profile* profile_;
161 166
162 int push_registration_count_; 167 int push_registration_count_;
163 int pending_push_registration_count_; 168 int pending_push_registration_count_;
164 169
170 base::Closure content_setting_changed_callback_for_testing_;
171
165 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; 172 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_;
166 173
167 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); 174 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl);
168 }; 175 };
169 176
170 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ 177 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698