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

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

Issue 1904163002: Move Web Notifications to use Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@skbitmap-blink
Patch Set: it works \o/ Created 4 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/child/notifications/notification_dispatcher.h"
6
7 #include <limits>
8
9 #include "content/child/notifications/notification_manager.h"
10
11 namespace content {
12
13 NotificationDispatcher::NotificationDispatcher(
14 ThreadSafeSender* thread_safe_sender)
15 : WorkerThreadMessageFilter(thread_safe_sender) {}
16
17 NotificationDispatcher::~NotificationDispatcher() {}
18
19 int NotificationDispatcher::GenerateNotificationId(int thread_id) {
20 base::AutoLock lock(notification_id_map_lock_);
21 CHECK_LT(next_notification_id_, std::numeric_limits<int>::max());
22
23 notification_id_map_[next_notification_id_] = thread_id;
24 return next_notification_id_++;
25 }
26
27 bool NotificationDispatcher::ShouldHandleMessage(
28 const IPC::Message& msg) const {
29 return IPC_MESSAGE_CLASS(msg) == PlatformNotificationMsgStart;
30 }
31
32 void NotificationDispatcher::OnFilteredMessageReceived(
33 const IPC::Message& msg) {
34 NotificationManager::ThreadSpecificInstance(thread_safe_sender(), this)
35 ->OnMessageReceived(msg);
36 }
37
38 bool NotificationDispatcher::GetWorkerThreadIdForMessage(
39 const IPC::Message& msg,
40 int* ipc_thread_id) {
41 int notification_id = -1;
42 const bool success = base::PickleIterator(msg).ReadInt(&notification_id);
43 DCHECK(success);
44
45 base::AutoLock lock(notification_id_map_lock_);
46 auto iterator = notification_id_map_.find(notification_id);
47 if (iterator != notification_id_map_.end()) {
48 *ipc_thread_id = iterator->second;
49 return true;
50 }
51 return false;
52 }
53
54 } // namespace content
OLDNEW
« no previous file with comments | « content/child/notifications/notification_dispatcher.h ('k') | content/child/notifications/notification_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698