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

Side by Side Diff: content/browser/notifications/notification_id_generator.h

Issue 1133813002: Introduce the NotificationIdGenerator in //content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 6 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
« no previous file with comments | « no previous file | content/browser/notifications/notification_id_generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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.
4
5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_
6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_
7
8 #include <stdint.h>
9 #include <string>
10
11 #include "content/common/content_export.h"
12
13 class GURL;
14
15 namespace content {
16
17 class BrowserContext;
18
19 // Generates deterministic notification ids for Web Notifications.
20 //
21 // The notification id must be deterministic for a given browser context, origin
22 // and tag, when the tag is non-empty, or unique for the given notification when
23 // the tag is empty. For non-persistent notifications, the uniqueness will be
24 // based on the render process id. For persistent notifications, the generated
25 // id will be globally unique for the lifetime of the notification database.
26 //
27 // Notifications coming from the same origin and having the same tag will result
28 // in the same notification id being generated. This id may then be used to
29 // update the notification in the platform notification service.
30 //
31 // The notification id will be used by the notification service for determining
32 // when to replace notifications, and as the unique identifier when a
33 // notification has to be closed programmatically.
34 //
35 // It is important to note that, for persistent notifications, the generated
36 // notification id can outlive the browser process responsible for creating it.
37 class CONTENT_EXPORT NotificationIdGenerator {
38 public:
39 NotificationIdGenerator(BrowserContext* browser_context,
40 int render_process_id);
41 ~NotificationIdGenerator();
42
43 // Generates an id for a persistent notification given the notification's
44 // origin, tag and persistent notification id. The persistent notification id
45 // will have been created by the persistent notification database.
46 std::string GenerateForPersistentNotification(
47 const GURL& origin,
48 const std::string& tag,
49 int64_t persistent_notification_id) const;
50
51 // Generates an id for a non-persistent notification given the notification's
52 // origin, tag and non-persistent notification id. The non-persistent
53 // notification id will have created by the renderer with |render_process_id|.
54 std::string GenerateForNonPersistentNotification(
55 const GURL& origin,
56 const std::string& tag,
57 int non_persistent_notification_id) const;
58
59 private:
60 // The NotificationMessageFilter that owns |this| will outlive the context.
61 BrowserContext* browser_context_;
62
63 int render_process_id_;
64 };
65
66 } // namespace context
67
68 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/notifications/notification_id_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698