Chromium Code Reviews| 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 #ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ | 5 #ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ |
| 6 #define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ | 6 #define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | |
| 12 #include <memory> | 11 #include <memory> |
| 13 #include <set> | 12 #include <set> |
| 13 #include <tuple> | |
|
johnme
2016/09/02 15:07:44
Unnecessary?
Peter Beverloo
2016/09/05 15:11:01
Done.
| |
| 14 #include <unordered_map> | |
| 14 #include <vector> | 15 #include <vector> |
| 15 | 16 |
| 16 #include "base/id_map.h" | 17 #include "base/id_map.h" |
| 17 #include "base/macros.h" | 18 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 19 #include "content/child/notifications/notification_dispatcher.h" | 20 #include "content/child/notifications/notification_dispatcher.h" |
| 20 #include "content/common/platform_notification_messages.h" | 21 #include "content/common/platform_notification_messages.h" |
| 21 #include "content/public/child/worker_thread.h" | 22 #include "content/public/child/worker_thread.h" |
| 22 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onManager.h" | 23 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onManager.h" |
| 23 | 24 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 51 const blink::WebNotificationData& notification_data, | 52 const blink::WebNotificationData& notification_data, |
| 52 std::unique_ptr<blink::WebNotificationResources> notification_resources, | 53 std::unique_ptr<blink::WebNotificationResources> notification_resources, |
| 53 blink::WebServiceWorkerRegistration* service_worker_registration, | 54 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 54 blink::WebNotificationShowCallbacks* callbacks) override; | 55 blink::WebNotificationShowCallbacks* callbacks) override; |
| 55 void getNotifications( | 56 void getNotifications( |
| 56 const blink::WebString& filter_tag, | 57 const blink::WebString& filter_tag, |
| 57 blink::WebServiceWorkerRegistration* service_worker_registration, | 58 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 58 blink::WebNotificationGetCallbacks* callbacks) override; | 59 blink::WebNotificationGetCallbacks* callbacks) override; |
| 59 void close(blink::WebNotificationDelegate* delegate) override; | 60 void close(blink::WebNotificationDelegate* delegate) override; |
| 60 void closePersistent(const blink::WebSecurityOrigin& origin, | 61 void closePersistent(const blink::WebSecurityOrigin& origin, |
| 62 const blink::WebString& tag, | |
| 61 int64_t persistent_notification_id) override; | 63 int64_t persistent_notification_id) override; |
| 62 void notifyDelegateDestroyed( | 64 void notifyDelegateDestroyed( |
| 63 blink::WebNotificationDelegate* delegate) override; | 65 blink::WebNotificationDelegate* delegate) override; |
| 64 | 66 |
| 65 // Called by the NotificationDispatcher. | 67 // Called by the NotificationDispatcher. |
| 66 bool OnMessageReceived(const IPC::Message& message); | 68 bool OnMessageReceived(const IPC::Message& message); |
| 67 | 69 |
| 68 private: | 70 private: |
| 69 NotificationManager(ThreadSafeSender* thread_safe_sender, | 71 NotificationManager(ThreadSafeSender* thread_safe_sender, |
| 70 NotificationDispatcher* notification_dispatcher); | 72 NotificationDispatcher* notification_dispatcher); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 82 scoped_refptr<NotificationDispatcher> notification_dispatcher_; | 84 scoped_refptr<NotificationDispatcher> notification_dispatcher_; |
| 83 | 85 |
| 84 // Tracks pending requests for getting a list of notifications. | 86 // Tracks pending requests for getting a list of notifications. |
| 85 IDMap<blink::WebNotificationGetCallbacks, IDMapOwnPointer> | 87 IDMap<blink::WebNotificationGetCallbacks, IDMapOwnPointer> |
| 86 pending_get_notification_requests_; | 88 pending_get_notification_requests_; |
| 87 | 89 |
| 88 // Tracks pending requests for displaying persistent notifications. | 90 // Tracks pending requests for displaying persistent notifications. |
| 89 IDMap<blink::WebNotificationShowCallbacks, IDMapOwnPointer> | 91 IDMap<blink::WebNotificationShowCallbacks, IDMapOwnPointer> |
| 90 pending_show_notification_requests_; | 92 pending_show_notification_requests_; |
| 91 | 93 |
| 94 // Structure holding the information for active non-persistent notifications. | |
| 95 struct ActiveNotificationData { | |
| 96 ActiveNotificationData() = default; | |
| 97 ActiveNotificationData(blink::WebNotificationDelegate* delegate, | |
| 98 const GURL& origin, | |
| 99 const std::string& tag); | |
| 100 ~ActiveNotificationData(); | |
| 101 | |
| 102 blink::WebNotificationDelegate* delegate = nullptr; | |
| 103 GURL origin; | |
| 104 std::string tag; | |
| 105 }; | |
| 106 | |
| 92 // Map to store the delegate associated with a notification request Id. | 107 // Map to store the delegate associated with a notification request Id. |
| 93 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_; | 108 std::unordered_map<int, ActiveNotificationData> active_page_notifications_; |
| 94 | 109 |
| 95 DISALLOW_COPY_AND_ASSIGN(NotificationManager); | 110 DISALLOW_COPY_AND_ASSIGN(NotificationManager); |
| 96 }; | 111 }; |
| 97 | 112 |
| 98 } // namespace content | 113 } // namespace content |
| 99 | 114 |
| 100 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ | 115 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ |
| OLD | NEW |