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

Side by Side Diff: content/child/notifications/notification_dispatcher.cc

Issue 758603002: Use Mojo Permission Service when requesting Notifications permission. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission_geolocation_follow_up
Patch Set: Created 6 years 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 #include "content/child/notifications/notification_dispatcher.h" 5 #include "content/child/notifications/notification_dispatcher.h"
6 6
7 #include "base/message_loop/message_loop_proxy.h" 7 #include "base/message_loop/message_loop_proxy.h"
8 #include "content/child/notifications/notification_manager.h" 8 #include "content/child/notifications/notification_manager.h"
9 #include "content/child/thread_safe_sender.h" 9 #include "content/child/thread_safe_sender.h"
10 #include "content/child/worker_thread_task_runner.h" 10 #include "content/child/worker_thread_task_runner.h"
(...skipping 11 matching lines...) Expand all
22 NotificationDispatcher::~NotificationDispatcher() {} 22 NotificationDispatcher::~NotificationDispatcher() {}
23 23
24 int NotificationDispatcher::GenerateNotificationId(int thread_id) { 24 int NotificationDispatcher::GenerateNotificationId(int thread_id) {
25 base::AutoLock lock(notification_id_map_lock_); 25 base::AutoLock lock(notification_id_map_lock_);
26 notification_id_map_[next_notification_id_] = thread_id; 26 notification_id_map_[next_notification_id_] = thread_id;
27 return next_notification_id_++; 27 return next_notification_id_++;
28 } 28 }
29 29
30 base::TaskRunner* NotificationDispatcher::OverrideTaskRunnerForMessage( 30 base::TaskRunner* NotificationDispatcher::OverrideTaskRunnerForMessage(
31 const IPC::Message& msg) { 31 const IPC::Message& msg) {
32 if (!ShouldHandleMessage(msg))
33 return NULL;
34
35 int notification_id = -1, 32 int notification_id = -1,
36 thread_id = 0; 33 thread_id = 0;
37 34
38 const bool success = PickleIterator(msg).ReadInt(&notification_id); 35 const bool success = PickleIterator(msg).ReadInt(&notification_id);
39 DCHECK(success); 36 DCHECK(success);
40 37
41 { 38 {
42 base::AutoLock lock(notification_id_map_lock_); 39 base::AutoLock lock(notification_id_map_lock_);
43 auto iterator = notification_id_map_.find(notification_id); 40 auto iterator = notification_id_map_.find(notification_id);
44 if (iterator != notification_id_map_.end()) 41 if (iterator != notification_id_map_.end())
45 thread_id = iterator->second; 42 thread_id = iterator->second;
46 } 43 }
47 44
48 if (!thread_id) 45 if (!thread_id)
49 return main_thread_loop_proxy_.get(); 46 return main_thread_loop_proxy_.get();
50 47
51 return new WorkerThreadTaskRunner(thread_id); 48 return new WorkerThreadTaskRunner(thread_id);
52 } 49 }
53 50
54 bool NotificationDispatcher::OnMessageReceived(const IPC::Message& msg) { 51 bool NotificationDispatcher::OnMessageReceived(const IPC::Message& msg) {
55 if (!ShouldHandleMessage(msg))
56 return false;
57
58 NotificationManager::ThreadSpecificInstance( 52 NotificationManager::ThreadSpecificInstance(
59 thread_safe_sender_.get(), 53 thread_safe_sender_.get(),
60 main_thread_loop_proxy_.get(), 54 main_thread_loop_proxy_.get(),
61 this)->OnMessageReceived(msg); 55 this)->OnMessageReceived(msg);
62 return true; 56 return true;
63 } 57 }
64 58
65 bool NotificationDispatcher::ShouldHandleMessage(const IPC::Message& msg) {
66 // The thread-safe message filter is responsible for handling all the messages
67 // except for the routed permission-request-completed message, which will be
68 // picked up by the RenderFrameImpl instead.
69 return IPC_MESSAGE_CLASS(msg) == PlatformNotificationMsgStart &&
70 msg.type() != PlatformNotificationMsg_PermissionRequestComplete::ID;
71 }
72
73 } // namespace content 59 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698