Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/child/notifications/notification_manager.h" | 7 #include "content/child/notifications/notification_manager.h" |
| 8 #include "content/common/platform_notification_messages.h" | |
| 9 | 8 |
| 10 namespace content { | 9 namespace content { |
| 11 | 10 |
| 12 NotificationDispatcher::NotificationDispatcher( | 11 NotificationDispatcher::NotificationDispatcher( |
| 13 ThreadSafeSender* thread_safe_sender) | 12 ThreadSafeSender* thread_safe_sender) |
| 14 : WorkerThreadMessageFilter(thread_safe_sender), next_notification_id_(0) { | 13 : WorkerThreadMessageFilter(thread_safe_sender) { |
| 15 } | 14 } |
| 16 | 15 |
| 17 NotificationDispatcher::~NotificationDispatcher() {} | 16 NotificationDispatcher::~NotificationDispatcher() {} |
| 18 | 17 |
| 19 int NotificationDispatcher::GenerateNotificationId(int thread_id) { | 18 int NotificationDispatcher::GenerateNotificationId(int thread_id) { |
| 20 base::AutoLock lock(notification_id_map_lock_); | 19 base::AutoLock lock(notification_id_map_lock_); |
| 20 CHECK_GE(next_notification_id_, 0); | |
|
johnme
2015/03/19 16:26:59
If a legit website polls at 60 FPS for just over 1
Tom Sepez
2015/03/19 18:10:18
Just wondering why this is a signed type in the fi
Peter Beverloo
2015/03/19 18:17:00
I initially introduced it as such for consistency
| |
| 21 | |
| 21 notification_id_map_[next_notification_id_] = thread_id; | 22 notification_id_map_[next_notification_id_] = thread_id; |
| 22 return next_notification_id_++; | 23 return next_notification_id_++; |
| 23 } | 24 } |
| 24 | 25 |
| 25 bool NotificationDispatcher::ShouldHandleMessage( | 26 bool NotificationDispatcher::ShouldHandleMessage( |
| 26 const IPC::Message& msg) const { | 27 const IPC::Message& msg) const { |
| 27 return IPC_MESSAGE_CLASS(msg) == PlatformNotificationMsgStart; | 28 return IPC_MESSAGE_CLASS(msg) == PlatformNotificationMsgStart; |
| 28 } | 29 } |
| 29 | 30 |
| 30 void NotificationDispatcher::OnFilteredMessageReceived( | 31 void NotificationDispatcher::OnFilteredMessageReceived( |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 44 base::AutoLock lock(notification_id_map_lock_); | 45 base::AutoLock lock(notification_id_map_lock_); |
| 45 auto iterator = notification_id_map_.find(notification_id); | 46 auto iterator = notification_id_map_.find(notification_id); |
| 46 if (iterator != notification_id_map_.end()) { | 47 if (iterator != notification_id_map_.end()) { |
| 47 *ipc_thread_id = iterator->second; | 48 *ipc_thread_id = iterator->second; |
| 48 return true; | 49 return true; |
| 49 } | 50 } |
| 50 return false; | 51 return false; |
| 51 } | 52 } |
| 52 | 53 |
| 53 } // namespace content | 54 } // namespace content |
| OLD | NEW |