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

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

Issue 1024463006: Destroy the notification database when corruption occurs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-db-SWContextObserver
Patch Set: another test 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 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 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 void WriteNotificationData(const GURL& origin, 51 void WriteNotificationData(const GURL& origin,
52 const NotificationDatabaseData& database_data, 52 const NotificationDatabaseData& database_data,
53 const WriteResultCallback& callback) override; 53 const WriteResultCallback& callback) override;
54 void DeleteNotificationData(int64_t notification_id, 54 void DeleteNotificationData(int64_t notification_id,
55 const GURL& origin, 55 const GURL& origin,
56 const DeleteResultCallback& callback) override; 56 const DeleteResultCallback& callback) override;
57 57
58 // ServiceWorkerContextObserver implementation. 58 // ServiceWorkerContextObserver implementation.
59 void OnRegistrationDeleted(int64_t registration_id, 59 void OnRegistrationDeleted(int64_t registration_id,
60 const GURL& pattern) override; 60 const GURL& pattern) override;
61 void OnStorageWiped() override;
61 62
62 private: 63 private:
63 friend class PlatformNotificationContextTest; 64 friend class PlatformNotificationContextTest;
64 65
66 enum class CorruptionBehavior;
67
65 ~PlatformNotificationContextImpl() override; 68 ~PlatformNotificationContextImpl() override;
66 69
67 void InitializeOnIO(); 70 void InitializeOnIO();
68 void ShutdownOnIO(); 71 void ShutdownOnIO();
69 72
70 // Initializes the database if neccesary. Must be called on the IO thread. 73 // Initializes the database if neccesary. Must be called on the IO thread.
71 // |success_closure| will be invoked on a the |task_runner_| thread when 74 // |success_closure| will be invoked on a the |task_runner_| thread when
72 // everything is available, or |failure_closure_| will be invoked on the 75 // everything is available, or |failure_closure_| will be invoked on the
73 // IO thread when initialization fails. 76 // IO thread when initialization fails.
74 void LazyInitialize(const base::Closure& success_closure, 77 void LazyInitialize(const base::Closure& success_closure,
75 const base::Closure& failure_closure); 78 const base::Closure& failure_closure);
76 79
77 // Opens the database. Must be called on the |task_runner_| thread. When the 80 // Opens the database. Must be called on the |task_runner_| thread. When the
78 // database has been opened, |success_closure| will be invoked on the task 81 // database has been opened, |success_closure| will be invoked on the task
79 // thread, otherwise |failure_closure_| will be invoked on the IO thread. 82 // thread, otherwise |failure_closure_| will be invoked on the IO thread.
80 void OpenDatabase(const base::Closure& success_closure, 83 void OpenDatabase(const base::Closure& success_closure,
81 const base::Closure& failure_closure); 84 const base::Closure& failure_closure,
85 CorruptionBehavior corruption_behavior);
82 86
83 // Deletes all notifications associated with |service_worker_registration_id| 87 // Deletes all notifications associated with |service_worker_registration_id|
84 // belonging to |origin|. Must be called on the |task_runner_| thread. 88 // belonging to |origin|. Must be called on the |task_runner_| thread.
85 void DoDeleteNotificationsForServiceWorkerRegistration( 89 void DoDeleteNotificationsForServiceWorkerRegistration(
86 const GURL& origin, 90 const GURL& origin,
87 int64_t service_worker_registration_id); 91 int64_t service_worker_registration_id);
88 92
89 // Actually reads the notification data from the database. Must only be 93 // Actually reads the notification data from the database. Must only be
90 // called on the |task_runner_| thread. |callback| will be invoked on the 94 // called on the |task_runner_| thread. |callback| will be invoked on the
91 // IO thread when the operation has completed. 95 // IO thread when the operation has completed.
92 void DoReadNotificationData(int64_t notification_id, 96 void DoReadNotificationData(int64_t notification_id,
93 const GURL& origin, 97 const GURL& origin,
94 const ReadResultCallback& callback); 98 const ReadResultCallback& callback);
95 99
96 // Actually writes the notification database to the database. Must only be 100 // Actually writes the notification database to the database. Must only be
97 // called on the |task_runner_| thread. |callback| will be invoked on the 101 // called on the |task_runner_| thread. |callback| will be invoked on the
98 // IO thread when the operation has completed. 102 // IO thread when the operation has completed.
99 void DoWriteNotificationData(const GURL& origin, 103 void DoWriteNotificationData(const GURL& origin,
100 const NotificationDatabaseData& database_data, 104 const NotificationDatabaseData& database_data,
101 const WriteResultCallback& callback); 105 const WriteResultCallback& callback);
102 106
103 // Actually deletes the notification information from the database. Must only 107 // Actually deletes the notification information from the database. Must only
104 // be called on the |task_runner_| thread. |callback| will be invoked on the 108 // be called on the |task_runner_| thread. |callback| will be invoked on the
105 // IO thread when the operation has completed. 109 // IO thread when the operation has completed.
106 void DoDeleteNotificationData(int64_t notification_id, 110 void DoDeleteNotificationData(int64_t notification_id,
107 const GURL& origin, 111 const GURL& origin,
108 const DeleteResultCallback& callback); 112 const DeleteResultCallback& callback);
109 113
114 // Destroys the database regardless of its initialization status. This method
115 // must only be called on the |task_runner_| thread.
116 void DestroyDatabase();
117
110 // Returns the path in which the database should be initialized. May be empty. 118 // Returns the path in which the database should be initialized. May be empty.
111 base::FilePath GetDatabasePath() const; 119 base::FilePath GetDatabasePath() const;
112 120
113 // Sets the task runner to use for testing purposes. 121 // Sets the task runner to use for testing purposes.
114 void SetTaskRunnerForTesting( 122 void SetTaskRunnerForTesting(
115 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 123 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
116 124
117 base::FilePath path_; 125 base::FilePath path_;
118 126
119 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; 127 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
120 128
121 scoped_refptr<base::SequencedTaskRunner> task_runner_; 129 scoped_refptr<base::SequencedTaskRunner> task_runner_;
122 scoped_ptr<NotificationDatabase> database_; 130 scoped_ptr<NotificationDatabase> database_;
123 131
124 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); 132 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl);
125 }; 133 };
126 134
127 } // namespace content 135 } // namespace content
128 136
129 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ 137 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698