OLD | NEW |
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_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ |
6 #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ | 6 #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/browser/notification_database_data.h" | 14 #include "content/public/browser/notification_database_data.h" |
13 | 15 |
14 class GURL; | 16 class GURL; |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 | 19 |
18 // Represents the storage context for persistent Web Notifications, specific to | 20 // Represents the storage context for persistent Web Notifications, specific to |
19 // the storage partition owning the instance. All methods defined in this | 21 // the storage partition owning the instance. All methods defined in this |
20 // interface may only be used on the IO thread. | 22 // interface may only be used on the IO thread. |
21 class PlatformNotificationContext { | 23 class PlatformNotificationContext |
| 24 : public base::RefCountedThreadSafe<PlatformNotificationContext, |
| 25 BrowserThread::DeleteOnUIThread> { |
22 public: | 26 public: |
23 using ReadResultCallback = | 27 using ReadResultCallback = |
24 base::Callback<void(bool /* success */, | 28 base::Callback<void(bool /* success */, |
25 const NotificationDatabaseData&)>; | 29 const NotificationDatabaseData&)>; |
26 | 30 |
27 using ReadAllResultCallback = | 31 using ReadAllResultCallback = |
28 base::Callback<void(bool /* success */, | 32 base::Callback<void(bool /* success */, |
29 const std::vector<NotificationDatabaseData>&)>; | 33 const std::vector<NotificationDatabaseData>&)>; |
30 | 34 |
31 using WriteResultCallback = | 35 using WriteResultCallback = |
(...skipping 26 matching lines...) Expand all Loading... |
58 const WriteResultCallback& callback) = 0; | 62 const WriteResultCallback& callback) = 0; |
59 | 63 |
60 // Deletes all data associated with |notification_id| belonging to |origin| | 64 // Deletes all data associated with |notification_id| belonging to |origin| |
61 // from the database. |callback| will be invoked with the success status | 65 // from the database. |callback| will be invoked with the success status |
62 // when the operation has completed. | 66 // when the operation has completed. |
63 virtual void DeleteNotificationData(int64_t notification_id, | 67 virtual void DeleteNotificationData(int64_t notification_id, |
64 const GURL& origin, | 68 const GURL& origin, |
65 const DeleteResultCallback& callback) = 0; | 69 const DeleteResultCallback& callback) = 0; |
66 | 70 |
67 protected: | 71 protected: |
| 72 friend class base::DeleteHelper<PlatformNotificationContext>; |
| 73 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 74 |
68 virtual ~PlatformNotificationContext() {} | 75 virtual ~PlatformNotificationContext() {} |
69 }; | 76 }; |
70 | 77 |
71 } // namespace content | 78 } // namespace content |
72 | 79 |
73 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ | 80 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ |
OLD | NEW |