OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // OnSuccess(Connection) doesn't create an extra one. | 120 // OnSuccess(Connection) doesn't create an extra one. |
121 bool connection_created_ = false; | 121 bool connection_created_ = false; |
122 | 122 |
123 // Used to assert that OnSuccess is only called if there was no data loss. | 123 // Used to assert that OnSuccess is only called if there was no data loss. |
124 blink::WebIDBDataLoss data_loss_; | 124 blink::WebIDBDataLoss data_loss_; |
125 | 125 |
126 // The "blocked" event should be sent at most once per request. | 126 // The "blocked" event should be sent at most once per request. |
127 bool sent_blocked_ = false; | 127 bool sent_blocked_ = false; |
128 base::TimeTicks connection_open_start_time_; | 128 base::TimeTicks connection_open_start_time_; |
129 | 129 |
130 std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_; | 130 // Required for unittests so that are scheduled on a taskrunner. |
| 131 struct DeleteOnIOThreadTaskRunner { |
| 132 template <typename T> |
| 133 static void Destruct(const T* x) { |
| 134 if (!BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, x)) { |
| 135 #if defined(UNIT_TEST) |
| 136 // Only logged under unit testing because leaks at shutdown |
| 137 // are acceptable under normal circumstances. |
| 138 LOG(ERROR) << "DeleteSoon failed on IO thread"; |
| 139 #endif // UNIT_TEST |
| 140 } |
| 141 } |
| 142 template <typename T> |
| 143 inline void operator()(T* ptr) const { |
| 144 enum { type_must_be_complete = sizeof(T) }; |
| 145 Destruct(ptr); |
| 146 } |
| 147 }; |
| 148 |
| 149 std::unique_ptr<IOThreadHelper, DeleteOnIOThreadTaskRunner> io_helper_; |
131 base::ThreadChecker thread_checker_; | 150 base::ThreadChecker thread_checker_; |
132 | 151 |
133 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); | 152 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); |
134 }; | 153 }; |
135 | 154 |
136 } // namespace content | 155 } // namespace content |
137 | 156 |
138 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ | 157 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ |
OLD | NEW |