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

Side by Side Diff: content/child/notifications/notification_manager.h

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

Powered by Google App Engine
This is Rietveld 408576698