Chromium Code Reviews| Index: content/browser/notifications/platform_notification_context_impl.h |
| diff --git a/content/browser/notifications/platform_notification_context_impl.h b/content/browser/notifications/platform_notification_context_impl.h |
| index f2eb599f4db5d489aec943122325727978c56f49..018fcfc95da16d42fac529d3c764a953a5297625 100644 |
| --- a/content/browser/notifications/platform_notification_context_impl.h |
| +++ b/content/browser/notifications/platform_notification_context_impl.h |
| @@ -8,16 +8,19 @@ |
| #include <stdint.h> |
| #include <set> |
| #include <string> |
| +#include <unordered_set> |
| #include "base/callback.h" |
| #include "base/compiler_specific.h" |
| #include "base/files/file_path.h" |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "content/browser/service_worker/service_worker_context_observer.h" |
| #include "content/common/content_export.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/platform_notification_context.h" |
| +#include "third_party/WebKit/public/platform/modules/notifications/notification_service.mojom.h" |
| class GURL; |
| @@ -27,9 +30,11 @@ class SequencedTaskRunner; |
| namespace content { |
| +class BlinkNotificationServiceImpl; |
| class BrowserContext; |
| class NotificationDatabase; |
| struct NotificationDatabaseData; |
| +class ResourceContext; |
| class ServiceWorkerContextWrapper; |
| // Implementation of the Web Notification storage context. The public methods |
| @@ -54,6 +59,17 @@ class CONTENT_EXPORT PlatformNotificationContextImpl |
| // To be called on the UI thread when the context is being shut down. |
| void Shutdown(); |
| + // Creates a BlinkNotificationServiceImpl that is owned by this context. Must |
| + // be called on the UI thread, although the service will be created on and |
| + // bound to the IO thread. |
| + void CreateService( |
| + int render_process_id, |
| + mojo::InterfaceRequest<blink::mojom::NotificationService> request); |
| + |
| + // Removes |service| from the list of owned services, for example because the |
| + // Mojo pipe disconnected. Must be called on the IO thread. |
| + void RemoveService(BlinkNotificationServiceImpl* service); |
| + |
| // PlatformNotificationContext implementation. |
| void ReadNotificationData(int64_t notification_id, |
| const GURL& origin, |
| @@ -81,6 +97,10 @@ class CONTENT_EXPORT PlatformNotificationContextImpl |
| void InitializeOnIO(); |
| void ShutdownOnIO(); |
| + void CreateServiceOnIO( |
| + int render_process_id, |
| + ResourceContext* resource_context, |
| + mojo::InterfaceRequest<blink::mojom::NotificationService> request); |
| // Initializes the database if neccesary. Must be called on the IO thread. |
| // |success_closure| will be invoked on a the |task_runner_| thread when |
| @@ -153,6 +173,12 @@ class CONTENT_EXPORT PlatformNotificationContextImpl |
| // Indicates whether the database should be pruned when it's opened. |
| bool prune_database_on_open_ = false; |
| + // The notification services are owned by the platform context, and will be |
| + // removed when either this class is destroyed or the Mojo pipe disconnects. |
| + std::unordered_set<BlinkNotificationServiceImpl*> services_; |
|
dcheng
2016/05/10 06:54:46
Can we store std::unique_ptr's in the set?
Peter Beverloo
2016/05/10 13:32:55
Yes, but we lose the properties of a set. Since th
dcheng
2016/05/11 21:26:40
It seems strictly better than having to manually d
|
| + |
| + base::WeakPtrFactory<PlatformNotificationContextImpl> weak_factory_to_io_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); |
| }; |