OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 5 #ifndef CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ |
6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
12 #include <string> | 13 #include <string> |
| 14 #include <utility> |
13 #include <vector> | 15 #include <vector> |
14 | 16 |
15 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
16 #include "base/id_map.h" | 18 #include "base/id_map.h" |
17 #include "base/macros.h" | 19 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
19 #include "base/strings/nullable_string16.h" | 21 #include "base/strings/nullable_string16.h" |
20 #include "content/child/indexed_db/indexed_db_callbacks_impl.h" | 22 #include "content/child/indexed_db/indexed_db_callbacks_impl.h" |
21 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" | 23 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" |
22 #include "content/common/content_export.h" | 24 #include "content/common/content_export.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 77 |
76 // This method is virtual so it can be overridden in unit tests. | 78 // This method is virtual so it can be overridden in unit tests. |
77 virtual bool Send(IPC::Message* msg); | 79 virtual bool Send(IPC::Message* msg); |
78 | 80 |
79 int32_t RegisterObserver(std::unique_ptr<blink::WebIDBObserver> observer); | 81 int32_t RegisterObserver(std::unique_ptr<blink::WebIDBObserver> observer); |
80 | 82 |
81 // Removes observers from our local map observers_. | 83 // Removes observers from our local map observers_. |
82 void RemoveObservers(const std::vector<int32_t>& observer_ids_to_remove); | 84 void RemoveObservers(const std::vector<int32_t>& observer_ids_to_remove); |
83 | 85 |
84 // This method is virtual so it can be overridden in unit tests. | 86 // This method is virtual so it can be overridden in unit tests. |
85 virtual void RequestIDBCursorAdvance(unsigned long count, | 87 virtual void RequestIDBCursorAdvance( |
86 blink::WebIDBCallbacks* callbacks_ptr, | 88 unsigned long count, |
87 int32_t ipc_cursor_id, | 89 std::unique_ptr<blink::WebIDBCallbacks> callbacks_ptr, |
88 int64_t transaction_id); | 90 int32_t ipc_cursor_id, |
| 91 int64_t transaction_id); |
89 | 92 |
90 // This method is virtual so it can be overridden in unit tests. | 93 // This method is virtual so it can be overridden in unit tests. |
91 virtual void RequestIDBCursorContinue(const IndexedDBKey& key, | 94 virtual void RequestIDBCursorContinue( |
92 const IndexedDBKey& primary_key, | 95 const IndexedDBKey& key, |
93 blink::WebIDBCallbacks* callbacks_ptr, | 96 const IndexedDBKey& primary_key, |
94 int32_t ipc_cursor_id, | 97 std::unique_ptr<blink::WebIDBCallbacks> callbacks_ptr, |
95 int64_t transaction_id); | 98 int32_t ipc_cursor_id, |
| 99 int64_t transaction_id); |
96 | 100 |
97 // This method is virtual so it can be overridden in unit tests. | 101 // This method is virtual so it can be overridden in unit tests. |
98 virtual void RequestIDBCursorPrefetch(int n, | 102 virtual void RequestIDBCursorPrefetch( |
99 blink::WebIDBCallbacks* callbacks_ptr, | 103 int n, |
100 int32_t ipc_cursor_id); | 104 std::unique_ptr<blink::WebIDBCallbacks> callbacks_ptr, |
| 105 int32_t ipc_cursor_id); |
101 | 106 |
102 // This method is virtual so it can be overridden in unit tests. | 107 // This method is virtual so it can be overridden in unit tests. |
103 virtual void RequestIDBCursorPrefetchReset(int used_prefetches, | 108 virtual void RequestIDBCursorPrefetchReset(int used_prefetches, |
104 int unused_prefetches, | 109 int unused_prefetches, |
105 int32_t ipc_cursor_id); | 110 int32_t ipc_cursor_id); |
106 | 111 |
107 void RegisterCursor(int32_t ipc_cursor_id, WebIDBCursorImpl* cursor); | 112 void RegisterCursor(int32_t ipc_cursor_id, WebIDBCursorImpl* cursor); |
108 | 113 |
109 virtual void CursorDestroyed(int32_t ipc_cursor_id); | 114 virtual void CursorDestroyed(int32_t ipc_cursor_id); |
110 | 115 |
(...skipping 12 matching lines...) Expand all Loading... |
123 void UnregisterMojoOwnedDatabaseCallbacks( | 128 void UnregisterMojoOwnedDatabaseCallbacks( |
124 blink::WebIDBDatabaseCallbacks* callback_state); | 129 blink::WebIDBDatabaseCallbacks* callback_state); |
125 | 130 |
126 private: | 131 private: |
127 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorReset); | 132 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorReset); |
128 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorTransactionId); | 133 FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorTransactionId); |
129 | 134 |
130 static int32_t CurrentWorkerId() { return WorkerThread::GetCurrentId(); } | 135 static int32_t CurrentWorkerId() { return WorkerThread::GetCurrentId(); } |
131 | 136 |
132 template <typename T> | 137 template <typename T> |
133 void init_params(T* params, blink::WebIDBCallbacks* callbacks_ptr) { | 138 void init_params(T* params, |
134 std::unique_ptr<blink::WebIDBCallbacks> callbacks(callbacks_ptr); | 139 std::unique_ptr<blink::WebIDBCallbacks> callbacks_ptr) { |
135 params->ipc_thread_id = CurrentWorkerId(); | 140 params->ipc_thread_id = CurrentWorkerId(); |
136 params->ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | 141 params->ipc_callbacks_id = pending_callbacks_.Add(std::move(callbacks_ptr)); |
137 } | 142 } |
138 | 143 |
139 // IDBCallback message handlers. | 144 // IDBCallback message handlers. |
140 void OnSuccessCursorContinue( | 145 void OnSuccessCursorContinue( |
141 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p); | 146 const IndexedDBMsg_CallbacksSuccessCursorContinue_Params& p); |
142 void OnSuccessCursorPrefetch( | 147 void OnSuccessCursorPrefetch( |
143 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p); | 148 const IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params& p); |
144 void OnSuccessValue(const IndexedDBMsg_CallbacksSuccessValue_Params& p); | 149 void OnSuccessValue(const IndexedDBMsg_CallbacksSuccessValue_Params& p); |
145 void OnSuccessInteger(int32_t ipc_thread_id, | 150 void OnSuccessInteger(int32_t ipc_thread_id, |
146 int32_t ipc_callbacks_id, | 151 int32_t ipc_callbacks_id, |
(...skipping 29 matching lines...) Expand all Loading... |
176 | 181 |
177 // Map from cursor id to WebIDBCursorImpl. | 182 // Map from cursor id to WebIDBCursorImpl. |
178 std::map<int32_t, WebIDBCursorImpl*> cursors_; | 183 std::map<int32_t, WebIDBCursorImpl*> cursors_; |
179 | 184 |
180 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); | 185 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); |
181 }; | 186 }; |
182 | 187 |
183 } // namespace content | 188 } // namespace content |
184 | 189 |
185 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ | 190 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_DISPATCHER_H_ |
OLD | NEW |