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

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

Issue 2719813005: CrOS: Add print statements to help debug BrowserProcessImpl::Unpin crash. (Closed)
Patch Set: Use DVLOG instead. 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 #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 <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "chrome/browser/background/background_trigger.h" 18 #include "chrome/browser/background/background_trigger.h"
19 #include "chrome/browser/push_messaging/push_messaging_notification_manager.h" 19 #include "chrome/browser/push_messaging/push_messaging_notification_manager.h"
20 #include "chrome/common/features.h" 20 #include "chrome/common/features.h"
21 #include "components/content_settings/core/browser/content_settings_observer.h" 21 #include "components/content_settings/core/browser/content_settings_observer.h"
22 #include "components/content_settings/core/common/content_settings.h" 22 #include "components/content_settings/core/common/content_settings.h"
23 #include "components/content_settings/core/common/content_settings_types.h" 23 #include "components/content_settings/core/common/content_settings_types.h"
24 #include "components/gcm_driver/common/gcm_messages.h" 24 #include "components/gcm_driver/common/gcm_messages.h"
25 #include "components/gcm_driver/gcm_app_handler.h" 25 #include "components/gcm_driver/gcm_app_handler.h"
26 #include "components/gcm_driver/gcm_client.h" 26 #include "components/gcm_driver/gcm_client.h"
27 #include "components/gcm_driver/instance_id/instance_id.h" 27 #include "components/gcm_driver/instance_id/instance_id.h"
28 #include "components/keyed_service/core/keyed_service.h" 28 #include "components/keyed_service/core/keyed_service.h"
29 #include "content/public/browser/notification_observer.h"
30 #include "content/public/browser/notification_registrar.h"
29 #include "content/public/browser/push_messaging_service.h" 31 #include "content/public/browser/push_messaging_service.h"
30 #include "content/public/common/push_event_payload.h" 32 #include "content/public/common/push_event_payload.h"
31 #include "content/public/common/push_messaging_status.h" 33 #include "content/public/common/push_messaging_status.h"
32 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h" 34 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h"
33 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi ssionStatus.h" 35 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi ssionStatus.h"
34 36
35 class Profile; 37 class Profile;
36 class PushMessagingAppIdentifier; 38 class PushMessagingAppIdentifier;
37 class PushMessagingServiceObserver; 39 class PushMessagingServiceObserver;
38 class PushMessagingServiceTest; 40 class PushMessagingServiceTest;
39 class ScopedKeepAlive; 41 class ScopedKeepAlive;
40 struct PushSubscriptionOptions; 42 struct PushSubscriptionOptions;
41 43
42 namespace gcm { 44 namespace gcm {
43 class GCMDriver; 45 class GCMDriver;
44 } 46 }
45 namespace instance_id { 47 namespace instance_id {
46 class InstanceIDDriver; 48 class InstanceIDDriver;
47 } 49 }
48 50
49 class PushMessagingServiceImpl : public content::PushMessagingService, 51 class PushMessagingServiceImpl : public content::PushMessagingService,
52 public content::NotificationObserver,
50 public gcm::GCMAppHandler, 53 public gcm::GCMAppHandler,
51 public content_settings::Observer, 54 public content_settings::Observer,
52 public KeyedService, 55 public KeyedService,
53 public BackgroundTrigger { 56 public BackgroundTrigger {
54 public: 57 public:
55 // If any Service Workers are using push, starts GCM and adds an app handler. 58 // If any Service Workers are using push, starts GCM and adds an app handler.
56 static void InitializeForProfile(Profile* profile); 59 static void InitializeForProfile(Profile* profile);
57 60
58 explicit PushMessagingServiceImpl(Profile* profile); 61 explicit PushMessagingServiceImpl(Profile* profile);
59 ~PushMessagingServiceImpl() override; 62 ~PushMessagingServiceImpl() override;
60 63
61 // gcm::GCMAppHandler implementation. 64 // gcm::GCMAppHandler implementation.
62 void ShutdownHandler() override; 65 void ShutdownHandler() override;
63 void OnStoreReset() override; 66 void OnStoreReset() override;
64 void OnMessage(const std::string& app_id, 67 void OnMessage(const std::string& app_id,
65 const gcm::IncomingMessage& message) override; 68 const gcm::IncomingMessage& message) override;
66 void OnMessagesDeleted(const std::string& app_id) override; 69 void OnMessagesDeleted(const std::string& app_id) override;
67 void OnSendError( 70 void OnSendError(
68 const std::string& app_id, 71 const std::string& app_id,
69 const gcm::GCMClient::SendErrorDetails& send_error_details) override; 72 const gcm::GCMClient::SendErrorDetails& send_error_details) override;
70 void OnSendAcknowledged(const std::string& app_id, 73 void OnSendAcknowledged(const std::string& app_id,
71 const std::string& message_id) override; 74 const std::string& message_id) override;
72 bool CanHandle(const std::string& app_id) const override; 75 bool CanHandle(const std::string& app_id) const override;
73 76
77 // content::NotificationObserver:
78 // TODO(sammiequon): This is used to help debug the crash in crbug.com/660962.
79 // Remove this when the crash is fixed or if verified to not be related to
80 // this.
81 void Observe(int type,
82 const content::NotificationSource& source,
83 const content::NotificationDetails& details) override;
84
74 // content::PushMessagingService implementation: 85 // content::PushMessagingService implementation:
75 GURL GetEndpoint(bool standard_protocol) const override; 86 GURL GetEndpoint(bool standard_protocol) const override;
76 void SubscribeFromDocument(const GURL& requesting_origin, 87 void SubscribeFromDocument(const GURL& requesting_origin,
77 int64_t service_worker_registration_id, 88 int64_t service_worker_registration_id,
78 int renderer_id, 89 int renderer_id,
79 int render_frame_id, 90 int render_frame_id,
80 const content::PushSubscriptionOptions& options, 91 const content::PushSubscriptionOptions& options,
81 const RegisterCallback& callback) override; 92 const RegisterCallback& callback) override;
82 void SubscribeFromWorker(const GURL& requesting_origin, 93 void SubscribeFromWorker(const GURL& requesting_origin,
83 int64_t service_worker_registration_id, 94 int64_t service_worker_registration_id,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 270
260 // A multiset containing one entry for each in-flight push message delivery, 271 // A multiset containing one entry for each in-flight push message delivery,
261 // keyed by the receiver's app id. 272 // keyed by the receiver's app id.
262 std::multiset<std::string> in_flight_message_deliveries_; 273 std::multiset<std::string> in_flight_message_deliveries_;
263 274
264 MessageDispatchedCallback message_dispatched_callback_for_testing_; 275 MessageDispatchedCallback message_dispatched_callback_for_testing_;
265 276
266 std::unique_ptr<PushMessagingServiceObserver> 277 std::unique_ptr<PushMessagingServiceObserver>
267 push_messaging_service_observer_; 278 push_messaging_service_observer_;
268 279
280 content::NotificationRegistrar registrar_;
281
269 #if BUILDFLAG(ENABLE_BACKGROUND) 282 #if BUILDFLAG(ENABLE_BACKGROUND)
270 // KeepAlive registered while we have in-flight push messages, to make sure 283 // KeepAlive registered while we have in-flight push messages, to make sure
271 // we can finish processing them without being interrupted. 284 // we can finish processing them without being interrupted.
272 std::unique_ptr<ScopedKeepAlive> in_flight_keep_alive_; 285 std::unique_ptr<ScopedKeepAlive> in_flight_keep_alive_;
273 #endif 286 #endif
274 287
275 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; 288 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_;
276 289
277 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); 290 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl);
278 }; 291 };
279 292
280 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ 293 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698