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

Unified Diff: content/child/notifications/notification_dispatcher.cc

Issue 892543002: workers: Introduce a WorkerMessageFilter to ease routing/processing worker messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/child/notifications/notification_dispatcher.cc
diff --git a/content/child/notifications/notification_dispatcher.cc b/content/child/notifications/notification_dispatcher.cc
index a9a5daab224c3c0c887a34a26dd34f90f7f5c38a..5949972019f8e01f46f31136a38b3e7730de56fe 100644
--- a/content/child/notifications/notification_dispatcher.cc
+++ b/content/child/notifications/notification_dispatcher.cc
@@ -4,19 +4,14 @@
#include "content/child/notifications/notification_dispatcher.h"
-#include "base/message_loop/message_loop_proxy.h"
#include "content/child/notifications/notification_manager.h"
-#include "content/child/thread_safe_sender.h"
-#include "content/child/worker_thread_task_runner.h"
#include "content/common/platform_notification_messages.h"
namespace content {
NotificationDispatcher::NotificationDispatcher(
ThreadSafeSender* thread_safe_sender)
- : main_thread_loop_proxy_(base::MessageLoopProxy::current()),
- thread_safe_sender_(thread_safe_sender),
- next_notification_id_(0) {
+ : WorkerThreadMessageFilter(thread_safe_sender), next_notification_id_(0) {
}
NotificationDispatcher::~NotificationDispatcher() {}
@@ -27,43 +22,32 @@ int NotificationDispatcher::GenerateNotificationId(int thread_id) {
return next_notification_id_++;
}
-base::TaskRunner* NotificationDispatcher::OverrideTaskRunnerForMessage(
- const IPC::Message& msg) {
- if (!ShouldHandleMessage(msg))
- return NULL;
+bool NotificationDispatcher::ShouldHandleMessage(
+ const IPC::Message& msg) const {
+ return IPC_MESSAGE_CLASS(msg) == PlatformNotificationMsgStart;
+}
- int notification_id = -1,
- thread_id = 0;
+void NotificationDispatcher::OnFilteredMessageReceived(
+ const IPC::Message& msg) {
+ NotificationManager::ThreadSpecificInstance(thread_safe_sender(),
+ main_thread_task_runner(),
+ this)->OnMessageReceived(msg);
+}
+bool NotificationDispatcher::GetWorkerThreadIdForMessage(
+ const IPC::Message& msg,
+ int* ipc_thread_id) {
+ int notification_id = -1;
const bool success = PickleIterator(msg).ReadInt(&notification_id);
DCHECK(success);
- {
- base::AutoLock lock(notification_id_map_lock_);
- auto iterator = notification_id_map_.find(notification_id);
- if (iterator != notification_id_map_.end())
- thread_id = iterator->second;
+ base::AutoLock lock(notification_id_map_lock_);
+ auto iterator = notification_id_map_.find(notification_id);
+ if (iterator != notification_id_map_.end()) {
+ *ipc_thread_id = iterator->second;
+ return true;
}
-
- if (!thread_id)
- return main_thread_loop_proxy_.get();
-
- return new WorkerThreadTaskRunner(thread_id);
-}
-
-bool NotificationDispatcher::OnMessageReceived(const IPC::Message& msg) {
- if (!ShouldHandleMessage(msg))
- return false;
-
- NotificationManager::ThreadSpecificInstance(
- thread_safe_sender_.get(),
- main_thread_loop_proxy_.get(),
- this)->OnMessageReceived(msg);
- return true;
-}
-
-bool NotificationDispatcher::ShouldHandleMessage(const IPC::Message& msg) {
- return IPC_MESSAGE_CLASS(msg) == PlatformNotificationMsgStart;
+ return false;
}
} // namespace content
« no previous file with comments | « content/child/notifications/notification_dispatcher.h ('k') | content/child/push_messaging/push_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698