OLD | NEW |
---|---|
(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 | |
johnme
2015/05/08 15:35:25
Can render process ids ever get reused (without th
Peter Beverloo
2015/05/20 18:43:33
No. See ChildProcessHostImpl::GenerateChildProcess
| |
25 // id will be globally unique for on the lifetime of the notification database. | |
johnme
2015/05/08 15:35:25
s/for on/for/
Peter Beverloo
2015/05/20 18:43:33
Done.
| |
26 // | |
27 // The notification id will be used by the notification service for determining | |
28 // when to replace notifications, and as the unique identifier when a | |
29 // notification has to be closed programmatically. | |
30 // | |
31 // It is important to note that, for persistent notifications, the generated | |
32 // notification id can outlive the browser process responsible for creating it. | |
33 class CONTENT_EXPORT NotificationIdGenerator { | |
johnme
2015/05/08 15:35:25
Since multiple distinct notifications may share a
Peter Beverloo
2015/05/20 18:43:33
The technical term for this form of ID would be a
| |
34 public: | |
35 NotificationIdGenerator(BrowserContext* browser_context, | |
36 int render_process_id); | |
37 ~NotificationIdGenerator(); | |
38 | |
39 // Generates an id for a persistent notification given the notification's | |
40 // origin, tag and persistent notification id. | |
41 std::string GenerateForPersistentNotification( | |
42 const GURL& origin, | |
43 const std::string& tag, | |
44 int64_t persistent_notification_id) const; | |
45 | |
46 // Generates an id for a non-persistent notification given the notification's | |
47 // origin, tag and non-persistent notification id. | |
johnme
2015/05/08 15:35:26
Where do these non_persistent_notification_ids com
Peter Beverloo
2015/05/20 18:43:34
Done.
| |
48 std::string GenerateForNonPersistentNotification( | |
49 const GURL& origin, | |
50 const std::string& tag, | |
51 int non_persistent_notification_id) const; | |
52 | |
53 private: | |
54 BrowserContext* browser_context_; | |
johnme
2015/05/08 15:35:25
Perhaps add a comment like "Required to outlive th
Peter Beverloo
2015/05/20 18:43:34
Done.
| |
55 int render_process_id_; | |
56 }; | |
57 | |
58 } // namespace context | |
59 | |
60 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ | |
OLD | NEW |