Chromium Code Reviews| 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 | |
|
johnme
2015/05/27 18:18:35
Please clearly explain that calling new Notificati
Peter Beverloo
2015/05/28 12:51:44
Done.
| |
| 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 // 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 { | |
| 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. The persistent notification id | |
| 41 // will have been created by the persistent notification database. | |
| 42 std::string GenerateForPersistentNotification( | |
| 43 const GURL& origin, | |
| 44 const std::string& tag, | |
| 45 int64_t persistent_notification_id) const; | |
| 46 | |
| 47 // Generates an id for a non-persistent notification given the notification's | |
| 48 // origin, tag and non-persistent notification id. The non-persistent | |
| 49 // notification id will have created by the renderer with |render_process_id|. | |
| 50 std::string GenerateForNonPersistentNotification( | |
| 51 const GURL& origin, | |
| 52 const std::string& tag, | |
| 53 int non_persistent_notification_id) const; | |
| 54 | |
| 55 private: | |
| 56 // The NotificationMessageFilter that owns |this| will outlive the context. | |
| 57 BrowserContext* browser_context_; | |
| 58 | |
| 59 int render_process_id_; | |
| 60 }; | |
| 61 | |
| 62 } // namespace context | |
| 63 | |
| 64 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ | |
| OLD | NEW |