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

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

Issue 2300093002: Make //content responsible for generating notification Ids (Closed)
Patch Set: Make //content responsible for generating notification Ids Created 4 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ 5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_
6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ 6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 10
(...skipping 19 matching lines...) Expand all
30 // update the notification in the platform notification service. 30 // update the notification in the platform notification service.
31 // 31 //
32 // The notification id will be used by the notification service for determining 32 // The notification id will be used by the notification service for determining
33 // when to replace notifications, and as the unique identifier when a 33 // when to replace notifications, and as the unique identifier when a
34 // notification has to be closed programmatically. 34 // notification has to be closed programmatically.
35 // 35 //
36 // It is important to note that, for persistent notifications, the generated 36 // It is important to note that, for persistent notifications, the generated
37 // notification id can outlive the browser process responsible for creating it. 37 // notification id can outlive the browser process responsible for creating it.
38 class CONTENT_EXPORT NotificationIdGenerator { 38 class CONTENT_EXPORT NotificationIdGenerator {
39 public: 39 public:
40 NotificationIdGenerator(BrowserContext* browser_context, 40 explicit NotificationIdGenerator(BrowserContext* browser_context);
41 int render_process_id);
42 ~NotificationIdGenerator(); 41 ~NotificationIdGenerator();
43 42
44 // Returns whether |notification_id| belongs to a persistent notification. 43 // Returns whether |notification_id| belongs to a persistent notification.
45 static bool IsPersistentNotification( 44 static bool IsPersistentNotification(
46 const base::StringPiece& notification_id); 45 const base::StringPiece& notification_id);
47 46
48 // Returns whether |notification_id| belongs to a non-persistent notification. 47 // Returns whether |notification_id| belongs to a non-persistent notification.
49 static bool IsNonPersistentNotification( 48 static bool IsNonPersistentNotification(
50 const base::StringPiece& notification_id); 49 const base::StringPiece& notification_id);
51 50
52 // Generates an id for a persistent notification given the notification's 51 // Generates an id for a persistent notification given the notification's
53 // origin, tag and persistent notification id. The persistent notification id 52 // origin, tag and persistent notification id. The persistent notification id
54 // will have been created by the persistent notification database. 53 // will have been created by the persistent notification database.
55 std::string GenerateForPersistentNotification( 54 std::string GenerateForPersistentNotification(
56 const GURL& origin, 55 const GURL& origin,
57 const std::string& tag, 56 const std::string& tag,
58 int64_t persistent_notification_id) const; 57 int64_t persistent_notification_id) const;
59 58
60 // Generates an id for a non-persistent notification given the notification's 59 // Generates an id for a non-persistent notification given the notification's
61 // origin, tag and non-persistent notification id. The non-persistent 60 // origin, tag and non-persistent notification id. The non-persistent
62 // notification id will have created by the renderer with |render_process_id|. 61 // notification id must've been created by the |render_process_id|.
63 std::string GenerateForNonPersistentNotification( 62 std::string GenerateForNonPersistentNotification(
64 const GURL& origin, 63 const GURL& origin,
65 const std::string& tag, 64 const std::string& tag,
66 int non_persistent_notification_id) const; 65 int non_persistent_notification_id,
66 int render_process_id) const;
67 67
68 private: 68 private:
69 // The NotificationMessageFilter that owns |this| will outlive the context. 69 // The NotificationMessageFilter that owns |this| will outlive the context.
70 BrowserContext* browser_context_; 70 BrowserContext* browser_context_;
71
72 int render_process_id_;
73 }; 71 };
74 72
75 } // namespace context 73 } // namespace context
76 74
77 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ 75 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698