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

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

Issue 1127013008: Beginnings of synchronizing notifications in the notification database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ 5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ 6 #define CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <set>
10 #include <string>
9 11
10 #include "base/callback.h" 12 #include "base/callback.h"
11 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
12 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
13 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
14 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
15 #include "content/browser/service_worker/service_worker_context_observer.h" 17 #include "content/browser/service_worker/service_worker_context_observer.h"
16 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
17 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/platform_notification_context.h" 20 #include "content/public/browser/platform_notification_context.h"
19 21
20 class GURL; 22 class GURL;
21 23
22 namespace base { 24 namespace base {
23 class SequencedTaskRunner; 25 class SequencedTaskRunner;
24 } 26 }
25 27
26 namespace content { 28 namespace content {
27 29
30 class BrowserContext;
28 class NotificationDatabase; 31 class NotificationDatabase;
29 struct NotificationDatabaseData; 32 struct NotificationDatabaseData;
30 class ServiceWorkerContextWrapper; 33 class ServiceWorkerContextWrapper;
31 34
32 // Implementation of the Web Notification storage context. The public methods 35 // Implementation of the Web Notification storage context. The public methods
33 // defined in this interface must only be called on the IO thread unless 36 // defined in this interface must only be called on the IO thread unless
34 // otherwise specified. 37 // otherwise specified.
35 class CONTENT_EXPORT PlatformNotificationContextImpl 38 class CONTENT_EXPORT PlatformNotificationContextImpl
36 : NON_EXPORTED_BASE(public PlatformNotificationContext), 39 : NON_EXPORTED_BASE(public PlatformNotificationContext),
37 NON_EXPORTED_BASE(public ServiceWorkerContextObserver) { 40 NON_EXPORTED_BASE(public ServiceWorkerContextObserver) {
38 public: 41 public:
39 // Constructs a new platform notification context. If |path| is non-empty, the 42 // Constructs a new platform notification context. If |path| is non-empty, the
40 // database will be initialized in the "Platform Notifications" subdirectory 43 // database will be initialized in the "Platform Notifications" subdirectory
41 // of |path|. Otherwise, the database will be initialized in memory. The 44 // of |path|. Otherwise, the database will be initialized in memory. The
42 // constructor must only be called on the IO thread. 45 // constructor must only be called on the IO thread.
43 PlatformNotificationContextImpl( 46 PlatformNotificationContextImpl(
44 const base::FilePath& path, 47 const base::FilePath& path,
48 BrowserContext* browser_context,
45 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); 49 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context);
46 50
47 // To be called on the UI thread to initialize the instance. 51 // To be called on the UI thread to initialize the instance.
48 void Initialize(); 52 void Initialize();
49 53
50 // To be called on the UI thread when the context is being shut down. 54 // To be called on the UI thread when the context is being shut down.
51 void Shutdown(); 55 void Shutdown();
52 56
53 // PlatformNotificationContext implementation. 57 // PlatformNotificationContext implementation.
54 void ReadNotificationData(int64_t notification_id, 58 void ReadNotificationData(int64_t notification_id,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 bool DestroyDatabase(); 136 bool DestroyDatabase();
133 137
134 // Returns the path in which the database should be initialized. May be empty. 138 // Returns the path in which the database should be initialized. May be empty.
135 base::FilePath GetDatabasePath() const; 139 base::FilePath GetDatabasePath() const;
136 140
137 // Sets the task runner to use for testing purposes. 141 // Sets the task runner to use for testing purposes.
138 void SetTaskRunnerForTesting( 142 void SetTaskRunnerForTesting(
139 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 143 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
140 144
141 base::FilePath path_; 145 base::FilePath path_;
146 BrowserContext* browser_context_;
142 147
143 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; 148 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
144 149
145 scoped_refptr<base::SequencedTaskRunner> task_runner_; 150 scoped_refptr<base::SequencedTaskRunner> task_runner_;
146 scoped_ptr<NotificationDatabase> database_; 151 scoped_ptr<NotificationDatabase> database_;
147 152
153 // Indicates whether the database should be pruned when it's opened.
154 bool prune_database_on_open_ = false;
155
148 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); 156 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl);
149 }; 157 };
150 158
151 } // namespace content 159 } // namespace content
152 160
153 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ 161 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698