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_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 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 class NotificationDatabase; | 28 class NotificationDatabase; |
29 struct NotificationDatabaseData; | 29 struct NotificationDatabaseData; |
30 class ServiceWorkerContextWrapper; | 30 class ServiceWorkerContextWrapper; |
31 | 31 |
32 // Implementation of the Web Notification storage context. The public methods | 32 // Implementation of the Web Notification storage context. The public methods |
33 // defined in this interface must only be called on the IO thread unless | 33 // defined in this interface must only be called on the IO thread unless |
34 // otherwise specified. | 34 // otherwise specified. |
35 class CONTENT_EXPORT PlatformNotificationContextImpl | 35 class CONTENT_EXPORT PlatformNotificationContextImpl |
36 : NON_EXPORTED_BASE(public PlatformNotificationContext), | 36 : NON_EXPORTED_BASE(public PlatformNotificationContext), |
37 NON_EXPORTED_BASE(public ServiceWorkerContextObserver), | 37 NON_EXPORTED_BASE(public ServiceWorkerContextObserver) { |
38 public base::RefCountedThreadSafe<PlatformNotificationContextImpl, | |
39 BrowserThread::DeleteOnUIThread> { | |
40 public: | 38 public: |
41 // Constructs a new platform notification context. If |path| is non-empty, the | 39 // Constructs a new platform notification context. If |path| is non-empty, the |
42 // database will be initialized in the "Platform Notifications" subdirectory | 40 // database will be initialized in the "Platform Notifications" subdirectory |
43 // of |path|. Otherwise, the database will be initialized in memory. The | 41 // of |path|. Otherwise, the database will be initialized in memory. The |
44 // constructor must only be called on the IO thread. | 42 // constructor must only be called on the IO thread. |
45 PlatformNotificationContextImpl( | 43 PlatformNotificationContextImpl( |
46 const base::FilePath& path, | 44 const base::FilePath& path, |
47 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); | 45 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); |
48 | 46 |
49 // To be called on the UI thread to initialize the instance. | 47 // To be called on the UI thread to initialize the instance. |
(...skipping 16 matching lines...) Expand all Loading... |
66 const GURL& origin, | 64 const GURL& origin, |
67 int64_t service_worker_registration_id, | 65 int64_t service_worker_registration_id, |
68 const ReadAllResultCallback& callback) override; | 66 const ReadAllResultCallback& callback) override; |
69 | 67 |
70 // ServiceWorkerContextObserver implementation. | 68 // ServiceWorkerContextObserver implementation. |
71 void OnRegistrationDeleted(int64_t registration_id, | 69 void OnRegistrationDeleted(int64_t registration_id, |
72 const GURL& pattern) override; | 70 const GURL& pattern) override; |
73 void OnStorageWiped() override; | 71 void OnStorageWiped() override; |
74 | 72 |
75 private: | 73 private: |
76 friend class base::DeleteHelper<PlatformNotificationContextImpl>; | |
77 friend class base::RefCountedThreadSafe<PlatformNotificationContextImpl, | |
78 BrowserThread::DeleteOnUIThread>; | |
79 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | |
80 friend class PlatformNotificationContextTest; | 74 friend class PlatformNotificationContextTest; |
81 | 75 |
82 ~PlatformNotificationContextImpl() override; | 76 ~PlatformNotificationContextImpl() override; |
83 | 77 |
84 void InitializeOnIO(); | 78 void InitializeOnIO(); |
85 void ShutdownOnIO(); | 79 void ShutdownOnIO(); |
86 | 80 |
87 // Initializes the database if neccesary. Must be called on the IO thread. | 81 // Initializes the database if neccesary. Must be called on the IO thread. |
88 // |success_closure| will be invoked on a the |task_runner_| thread when | 82 // |success_closure| will be invoked on a the |task_runner_| thread when |
89 // everything is available, or |failure_closure_| will be invoked on the | 83 // everything is available, or |failure_closure_| will be invoked on the |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 144 |
151 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 145 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
152 scoped_ptr<NotificationDatabase> database_; | 146 scoped_ptr<NotificationDatabase> database_; |
153 | 147 |
154 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); | 148 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); |
155 }; | 149 }; |
156 | 150 |
157 } // namespace content | 151 } // namespace content |
158 | 152 |
159 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ | 153 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ |
OLD | NEW |