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

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

Issue 1014073002: Implement getting notifications up to the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 #include "content/child/notifications/notification_dispatcher.h" 5 #include "content/child/notifications/notification_dispatcher.h"
6 6
7 #include <limits>
8
7 #include "content/child/notifications/notification_manager.h" 9 #include "content/child/notifications/notification_manager.h"
8 #include "content/common/platform_notification_messages.h"
9 10
10 namespace content { 11 namespace content {
11 12
12 NotificationDispatcher::NotificationDispatcher( 13 NotificationDispatcher::NotificationDispatcher(
13 ThreadSafeSender* thread_safe_sender) 14 ThreadSafeSender* thread_safe_sender)
14 : WorkerThreadMessageFilter(thread_safe_sender), next_notification_id_(0) { 15 : WorkerThreadMessageFilter(thread_safe_sender) {
15 } 16 }
16 17
17 NotificationDispatcher::~NotificationDispatcher() {} 18 NotificationDispatcher::~NotificationDispatcher() {}
18 19
19 int NotificationDispatcher::GenerateNotificationId(int thread_id) { 20 int NotificationDispatcher::GenerateNotificationId(int thread_id) {
20 base::AutoLock lock(notification_id_map_lock_); 21 base::AutoLock lock(notification_id_map_lock_);
22 CHECK_LT(next_notification_id_, std::numeric_limits<int>::max());
23
21 notification_id_map_[next_notification_id_] = thread_id; 24 notification_id_map_[next_notification_id_] = thread_id;
22 return next_notification_id_++; 25 return next_notification_id_++;
23 } 26 }
24 27
25 bool NotificationDispatcher::ShouldHandleMessage( 28 bool NotificationDispatcher::ShouldHandleMessage(
26 const IPC::Message& msg) const { 29 const IPC::Message& msg) const {
27 return IPC_MESSAGE_CLASS(msg) == PlatformNotificationMsgStart; 30 return IPC_MESSAGE_CLASS(msg) == PlatformNotificationMsgStart;
28 } 31 }
29 32
30 void NotificationDispatcher::OnFilteredMessageReceived( 33 void NotificationDispatcher::OnFilteredMessageReceived(
(...skipping 13 matching lines...) Expand all
44 base::AutoLock lock(notification_id_map_lock_); 47 base::AutoLock lock(notification_id_map_lock_);
45 auto iterator = notification_id_map_.find(notification_id); 48 auto iterator = notification_id_map_.find(notification_id);
46 if (iterator != notification_id_map_.end()) { 49 if (iterator != notification_id_map_.end()) {
47 *ipc_thread_id = iterator->second; 50 *ipc_thread_id = iterator->second;
48 return true; 51 return true;
49 } 52 }
50 return false; 53 return false;
51 } 54 }
52 55
53 } // namespace content 56 } // 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