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

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

Issue 1847863002: Move notification resource loading from content/child to blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ImageFrame::getSkBitmap was removed. Created 4 years, 8 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> 11 #include <map>
12 #include <memory>
12 #include <set> 13 #include <set>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/id_map.h" 16 #include "base/id_map.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
18 #include "base/single_thread_task_runner.h"
19 #include "content/child/notifications/notification_dispatcher.h" 19 #include "content/child/notifications/notification_dispatcher.h"
20 #include "content/child/notifications/pending_notifications_tracker.h"
21 #include "content/common/platform_notification_messages.h" 20 #include "content/common/platform_notification_messages.h"
22 #include "content/public/child/worker_thread.h" 21 #include "content/public/child/worker_thread.h"
23 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onManager.h" 22 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onManager.h"
24 23
25 namespace content { 24 namespace content {
26 25
27 struct NotificationResources; 26 struct NotificationResources;
28 struct PlatformNotificationData; 27 struct PlatformNotificationData;
29 class ThreadSafeSender; 28 class ThreadSafeSender;
30 29
31 class NotificationManager : public blink::WebNotificationManager, 30 class NotificationManager : public blink::WebNotificationManager,
32 public WorkerThread::Observer { 31 public WorkerThread::Observer {
33 public: 32 public:
34 ~NotificationManager() override; 33 ~NotificationManager() override;
35 34
36 // |thread_safe_sender| and |notification_dispatcher| are used if 35 // |thread_safe_sender| and |notification_dispatcher| are used if
37 // calling this leads to construction. 36 // calling this leads to construction.
38 static NotificationManager* ThreadSpecificInstance( 37 static NotificationManager* ThreadSpecificInstance(
39 ThreadSafeSender* thread_safe_sender, 38 ThreadSafeSender* thread_safe_sender,
40 base::SingleThreadTaskRunner* main_thread_task_runner,
41 NotificationDispatcher* notification_dispatcher); 39 NotificationDispatcher* notification_dispatcher);
42 40
43 // WorkerThread::Observer implementation. 41 // WorkerThread::Observer implementation.
44 void WillStopCurrentWorkerThread() override; 42 void WillStopCurrentWorkerThread() override;
45 43
46 // blink::WebNotificationManager implementation. 44 // blink::WebNotificationManager implementation.
47 void show(const blink::WebSecurityOrigin& origin, 45 void show(
48 const blink::WebNotificationData& notification_data, 46 const blink::WebSecurityOrigin& origin,
49 blink::WebNotificationDelegate* delegate) override; 47 const blink::WebNotificationData& notification_data,
48 std::unique_ptr<blink::WebNotificationResources> notification_resources,
49 blink::WebNotificationDelegate* delegate) override;
50 void showPersistent( 50 void showPersistent(
51 const blink::WebSecurityOrigin& origin, 51 const blink::WebSecurityOrigin& origin,
52 const blink::WebNotificationData& notification_data, 52 const blink::WebNotificationData& notification_data,
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,
61 int64_t persistent_notification_id) override; 62 int64_t persistent_notification_id) override;
62 void notifyDelegateDestroyed( 63 void notifyDelegateDestroyed(
63 blink::WebNotificationDelegate* delegate) override; 64 blink::WebNotificationDelegate* delegate) override;
64 blink::WebNotificationPermission checkPermission( 65 blink::WebNotificationPermission checkPermission(
65 const blink::WebSecurityOrigin& origin) override; 66 const blink::WebSecurityOrigin& origin) override;
66 size_t maxActions() override; 67 size_t maxActions() override;
67 68
68 // Called by the NotificationDispatcher. 69 // Called by the NotificationDispatcher.
69 bool OnMessageReceived(const IPC::Message& message); 70 bool OnMessageReceived(const IPC::Message& message);
70 71
71 private: 72 private:
72 NotificationManager(ThreadSafeSender* thread_safe_sender, 73 NotificationManager(ThreadSafeSender* thread_safe_sender,
73 base::SingleThreadTaskRunner* main_thread_task_runner,
74 NotificationDispatcher* notification_dispatcher); 74 NotificationDispatcher* notification_dispatcher);
75 75
76 // IPC message handlers. 76 // IPC message handlers.
77 void OnDidShow(int notification_id); 77 void OnDidShow(int notification_id);
78 void OnDidShowPersistent(int request_id, bool success); 78 void OnDidShowPersistent(int request_id, bool success);
79 void OnDidClose(int notification_id); 79 void OnDidClose(int notification_id);
80 void OnDidClick(int notification_id); 80 void OnDidClick(int notification_id);
81 void OnDidGetNotifications( 81 void OnDidGetNotifications(
82 int request_id, 82 int request_id,
83 const std::vector<PersistentNotificationInfo>& notification_infos); 83 const std::vector<PersistentNotificationInfo>& notification_infos);
(...skipping 15 matching lines...) Expand all
99 void DisplayPersistentNotification( 99 void DisplayPersistentNotification(
100 const blink::WebSecurityOrigin& origin, 100 const blink::WebSecurityOrigin& origin,
101 const blink::WebNotificationData& notification_data, 101 const blink::WebNotificationData& notification_data,
102 int64_t service_worker_registration_id, 102 int64_t service_worker_registration_id,
103 std::unique_ptr<blink::WebNotificationShowCallbacks> callbacks, 103 std::unique_ptr<blink::WebNotificationShowCallbacks> callbacks,
104 const NotificationResources& notification_resources); 104 const NotificationResources& notification_resources);
105 105
106 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 106 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
107 scoped_refptr<NotificationDispatcher> notification_dispatcher_; 107 scoped_refptr<NotificationDispatcher> notification_dispatcher_;
108 108
109 // Tracker which stores all pending Notifications, both page and persistent
110 // ones, until all their associated resources have been fetched.
111 PendingNotificationsTracker notifications_tracker_;
112
113 // Tracks pending requests for getting a list of notifications. 109 // Tracks pending requests for getting a list of notifications.
114 IDMap<blink::WebNotificationGetCallbacks, IDMapOwnPointer> 110 IDMap<blink::WebNotificationGetCallbacks, IDMapOwnPointer>
115 pending_get_notification_requests_; 111 pending_get_notification_requests_;
116 112
117 // Tracks pending requests for displaying persistent notifications. 113 // Tracks pending requests for displaying persistent notifications.
118 IDMap<blink::WebNotificationShowCallbacks, IDMapOwnPointer> 114 IDMap<blink::WebNotificationShowCallbacks, IDMapOwnPointer>
119 pending_show_notification_requests_; 115 pending_show_notification_requests_;
120 116
121 // Map to store the delegate associated with a notification request Id. 117 // Map to store the delegate associated with a notification request Id.
122 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_; 118 std::map<int, blink::WebNotificationDelegate*> active_page_notifications_;
123 119
124 DISALLOW_COPY_AND_ASSIGN(NotificationManager); 120 DISALLOW_COPY_AND_ASSIGN(NotificationManager);
125 }; 121 };
126 122
127 } // namespace content 123 } // namespace content
128 124
129 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_ 125 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698