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

Unified Diff: content/browser/notifications/platform_notification_context_impl.h

Issue 1014703007: The platform notification context should observe the Service Worker Context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-db-ReadAllData
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
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 812bda64e3cde7fc77c1e9414735efca7bb8c9f6..ddbf2a7169130cf33f940a7f44a87733def37b5d 100644
--- a/content/browser/notifications/platform_notification_context_impl.h
+++ b/content/browser/notifications/platform_notification_context_impl.h
@@ -10,7 +10,9 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
+#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
+#include "content/browser/service_worker/service_worker_context_observer.h"
#include "content/common/content_export.h"
#include "content/public/browser/platform_notification_context.h"
@@ -24,16 +26,23 @@ namespace content {
class NotificationDatabase;
struct NotificationDatabaseData;
+class ServiceWorkerContextWrapper;
// Implementation of the Web Notification storage context. The public methods
// defined in this interface must only be called on the IO thread.
johnme 2015/03/20 14:56:35 Please add "unless otherwise specified".
Peter Beverloo 2015/03/20 18:39:06 Done.
class CONTENT_EXPORT PlatformNotificationContextImpl
- : public NON_EXPORTED_BASE(PlatformNotificationContext) {
+ : NON_EXPORTED_BASE(public PlatformNotificationContext),
+ NON_EXPORTED_BASE(public ServiceWorkerContextObserver) {
public:
// Constructs a new platform notification context. If |path| is non-empty, the
johnme 2015/03/20 14:56:35 Please add "on the UI thread"
Peter Beverloo 2015/03/20 18:39:06 Done.
// database will be initialized in the "Platform Notifications" subdirectory
// of |path|. Otherwise, the database will be initialized in memory.
- explicit PlatformNotificationContextImpl(const base::FilePath& path);
+ PlatformNotificationContextImpl(
+ const base::FilePath& path,
+ const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context);
johnme 2015/03/20 14:56:35 Why not pass the scoped_refptr by value?
Peter Beverloo 2015/03/20 18:39:06 Per bauerb@'s suggestion in https://codereview.chr
+
+ // To be called on the UI thread when the context is being shut down.
+ void Shutdown();
// PlatformNotificationContext implementation.
void ReadNotificationData(int64_t notification_id,
@@ -46,11 +55,18 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
const GURL& origin,
const DeleteResultCallback& callback) override;
+ // ServiceWorkerContextObserver implementation.
+ void OnRegistrationDeleted(int64_t registration_id,
+ const GURL& pattern) override;
+
private:
friend class PlatformNotificationContextTest;
~PlatformNotificationContextImpl() override;
+ void InitializeOnIO();
+ void ShutdownOnIO();
+
// Initializes the database if neccesary. Must be called on the IO thread.
// |success_closure| will be invoked on a the |task_runner_| thread when
// everything is available, or |failure_closure_| will be invoked on the
@@ -64,6 +80,12 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
void OpenDatabase(const base::Closure& success_closure,
const base::Closure& failure_closure);
+ // Deletes all notifications associated with |service_worker_registration_id|
+ // belonging to |origin|. Must be called on the |task_runner_| thread.
+ void DoDeleteNotificationsForServiceWorkerRegistration(
johnme 2015/03/20 14:56:35 Micro-nit: move this after DoDeleteNotificationDat
Peter Beverloo 2015/03/20 18:39:06 Done.
+ const GURL& origin,
+ int64_t service_worker_registration_id);
+
// Actually reads the notification data from the database. Must only be
// called on the |task_runner_| thread. |callback| will be invoked on the
// IO thread when the operation has completed.
@@ -94,6 +116,8 @@ class CONTENT_EXPORT PlatformNotificationContextImpl
base::FilePath path_;
+ scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
+
scoped_refptr<base::SequencedTaskRunner> task_runner_;
scoped_ptr<NotificationDatabase> database_;

Powered by Google App Engine
This is Rietveld 408576698