blob: b6305a567549d27edc29e6b667b051ee2423b418 [file] [log] [blame]
[email protected]f7867172012-07-11 07:04:071// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]90e908552009-10-05 01:40:122// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]797c3552011-03-17 00:26:185#ifndef CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_
6#define CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_
[email protected]90e908552009-10-05 01:40:127
8#include <map>
9
10#include "base/basictypes.h"
[email protected]14c1c232013-06-11 17:52:4411#include "base/containers/hash_tables.h"
[email protected]90e908552009-10-05 01:40:1212#include "base/id_map.h"
[email protected]03ff5e52011-09-30 00:28:1413#include "content/common/content_export.h"
[email protected]2255a9332013-06-17 05:12:3114#include "third_party/WebKit/public/web/WebNotification.h"
[email protected]90e908552009-10-05 01:40:1215
[email protected]180ef242013-11-07 06:50:4616namespace blink {
[email protected]90e908552009-10-05 01:40:1217class WebNotificationPermissionCallback;
18}
19
[email protected]3827e9702012-10-23 06:19:2820namespace content {
21
[email protected]90e908552009-10-05 01:40:1222// This class manages the set of active Notification objects in either
23// a render or worker process. This class should be accessed only on
24// the main thread.
[email protected]03ff5e52011-09-30 00:28:1425class CONTENT_EXPORT ActiveNotificationTracker {
[email protected]90e908552009-10-05 01:40:1226 public:
[email protected]2858bbf2010-10-05 23:46:0227 ActiveNotificationTracker();
28 ~ActiveNotificationTracker();
[email protected]90e908552009-10-05 01:40:1229
30 // Methods for tracking active notification objects.
[email protected]180ef242013-11-07 06:50:4631 int RegisterNotification(const blink::WebNotification& notification);
[email protected]90e908552009-10-05 01:40:1232 void UnregisterNotification(int id);
[email protected]180ef242013-11-07 06:50:4633 bool GetId(const blink::WebNotification& notification, int& id);
34 bool GetNotification(int id, blink::WebNotification* notification);
[email protected]90e908552009-10-05 01:40:1235
36 // Methods for tracking active permission requests.
37 int RegisterPermissionRequest(
[email protected]180ef242013-11-07 06:50:4638 blink::WebNotificationPermissionCallback* callback);
[email protected]90e908552009-10-05 01:40:1239 void OnPermissionRequestComplete(int id);
[email protected]180ef242013-11-07 06:50:4640 blink::WebNotificationPermissionCallback* GetCallback(int id);
[email protected]90e908552009-10-05 01:40:1241
[email protected]422197532010-01-25 17:38:2342 // Clears out all active notifications. Useful on page navigation.
43 void Clear();
44
[email protected]90e908552009-10-05 01:40:1245 private:
[email protected]180ef242013-11-07 06:50:4646 typedef std::map<blink::WebNotification, int> ReverseTable;
[email protected]90e908552009-10-05 01:40:1247
48 // Tracking maps for active notifications and permission requests.
[email protected]180ef242013-11-07 06:50:4649 IDMap<blink::WebNotification> notification_table_;
[email protected]90e908552009-10-05 01:40:1250 ReverseTable reverse_notification_table_;
[email protected]180ef242013-11-07 06:50:4651 IDMap<blink::WebNotificationPermissionCallback> callback_table_;
[email protected]90e908552009-10-05 01:40:1252
53 DISALLOW_COPY_AND_ASSIGN(ActiveNotificationTracker);
54};
55
[email protected]3827e9702012-10-23 06:19:2856} // namespace content
57
[email protected]797c3552011-03-17 00:26:1858#endif // CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_