Add an UMA stat to be able to see if the User pods are show on start screen,
[chromium-blink-merge.git] / content / child / notifications / notification_dispatcher.h
blob297f38b6b28ed96c095686a40eb7012ae2dd741a
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.
5 #ifndef CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_
6 #define CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_
8 #include <map>
10 #include "base/synchronization/lock.h"
11 #include "content/child/worker_thread_message_filter.h"
13 namespace content {
15 class NotificationDispatcher : public WorkerThreadMessageFilter {
16 public:
17 explicit NotificationDispatcher(ThreadSafeSender* thread_safe_sender);
19 // Generates a, process-unique new notification Id mapped to |thread_id|, and
20 // return the notification Id. This method can be called on any thread.
21 int GenerateNotificationId(int thread_id);
23 protected:
24 ~NotificationDispatcher() override;
26 private:
27 // WorkerThreadMessageFilter:
28 bool ShouldHandleMessage(const IPC::Message& msg) const override;
29 void OnFilteredMessageReceived(const IPC::Message& msg) override;
30 bool GetWorkerThreadIdForMessage(const IPC::Message& msg,
31 int* ipc_thread_id) override;
33 using NotificationIdToThreadId = std::map<int, int>;
35 base::Lock notification_id_map_lock_;
36 NotificationIdToThreadId notification_id_map_;
37 int next_notification_id_ = 0;
39 DISALLOW_COPY_AND_ASSIGN(NotificationDispatcher);
42 } // namespace content
44 #endif // CONTENT_CHILD_NOTIFICATIONS_NOTIFICATION_DISPATCHER_H_