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 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 5 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 DCHECK(handled) << "Didn't handle a message defined at line " | 119 DCHECK(handled) << "Didn't handle a message defined at line " |
120 << IPC_MESSAGE_ID_LINE(msg.type()); | 120 << IPC_MESSAGE_ID_LINE(msg.type()); |
121 } | 121 } |
122 | 122 |
123 bool IndexedDBDispatcher::Send(IPC::Message* msg) { | 123 bool IndexedDBDispatcher::Send(IPC::Message* msg) { |
124 return thread_safe_sender_->Send(msg); | 124 return thread_safe_sender_->Send(msg); |
125 } | 125 } |
126 | 126 |
127 int32_t IndexedDBDispatcher::RegisterObserver( | 127 int32_t IndexedDBDispatcher::RegisterObserver( |
128 std::unique_ptr<WebIDBObserver> observer) { | 128 std::unique_ptr<WebIDBObserver> observer) { |
129 return observers_.Add(observer.release()); | 129 return observers_.Add(std::move(observer)); |
130 } | 130 } |
131 | 131 |
132 void IndexedDBDispatcher::RemoveObservers( | 132 void IndexedDBDispatcher::RemoveObservers( |
133 const std::vector<int32_t>& observer_ids_to_remove) { | 133 const std::vector<int32_t>& observer_ids_to_remove) { |
134 for (int32_t id : observer_ids_to_remove) | 134 for (int32_t id : observer_ids_to_remove) |
135 observers_.Remove(id); | 135 observers_.Remove(id); |
136 } | 136 } |
137 | 137 |
138 void IndexedDBDispatcher::RequestIDBCursorAdvance( | 138 void IndexedDBDispatcher::RequestIDBCursorAdvance( |
139 unsigned long count, | 139 unsigned long count, |
140 WebIDBCallbacks* callbacks_ptr, | 140 WebIDBCallbacks* callbacks_ptr, |
danakj
2016/11/18 00:15:33
could this be a unique_ptr?
| |
141 int32_t ipc_cursor_id, | 141 int32_t ipc_cursor_id, |
142 int64_t transaction_id) { | 142 int64_t transaction_id) { |
143 // Reset all cursor prefetch caches except for this cursor. | 143 // Reset all cursor prefetch caches except for this cursor. |
144 ResetCursorPrefetchCaches(transaction_id, ipc_cursor_id); | 144 ResetCursorPrefetchCaches(transaction_id, ipc_cursor_id); |
145 | 145 |
146 std::unique_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 146 int32_t ipc_callbacks_id = pending_callbacks_.Add( |
147 | 147 std::unique_ptr<WebIDBCallbacks>(callbacks_ptr)); |
148 int32_t ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | |
149 Send(new IndexedDBHostMsg_CursorAdvance( | 148 Send(new IndexedDBHostMsg_CursorAdvance( |
150 ipc_cursor_id, CurrentWorkerId(), ipc_callbacks_id, count)); | 149 ipc_cursor_id, CurrentWorkerId(), ipc_callbacks_id, count)); |
151 } | 150 } |
152 | 151 |
153 void IndexedDBDispatcher::RequestIDBCursorContinue( | 152 void IndexedDBDispatcher::RequestIDBCursorContinue( |
154 const IndexedDBKey& key, | 153 const IndexedDBKey& key, |
155 const IndexedDBKey& primary_key, | 154 const IndexedDBKey& primary_key, |
156 WebIDBCallbacks* callbacks_ptr, | 155 WebIDBCallbacks* callbacks_ptr, |
danakj
2016/11/18 00:15:33
and this?
| |
157 int32_t ipc_cursor_id, | 156 int32_t ipc_cursor_id, |
158 int64_t transaction_id) { | 157 int64_t transaction_id) { |
159 // Reset all cursor prefetch caches except for this cursor. | 158 // Reset all cursor prefetch caches except for this cursor. |
160 ResetCursorPrefetchCaches(transaction_id, ipc_cursor_id); | 159 ResetCursorPrefetchCaches(transaction_id, ipc_cursor_id); |
161 | 160 |
162 std::unique_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 161 int32_t ipc_callbacks_id = pending_callbacks_.Add( |
163 | 162 std::unique_ptr<WebIDBCallbacks>(callbacks_ptr)); |
164 int32_t ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | |
165 Send(new IndexedDBHostMsg_CursorContinue( | 163 Send(new IndexedDBHostMsg_CursorContinue( |
166 ipc_cursor_id, CurrentWorkerId(), ipc_callbacks_id, key, primary_key)); | 164 ipc_cursor_id, CurrentWorkerId(), ipc_callbacks_id, key, primary_key)); |
167 } | 165 } |
168 | 166 |
169 void IndexedDBDispatcher::RequestIDBCursorPrefetch( | 167 void IndexedDBDispatcher::RequestIDBCursorPrefetch( |
170 int n, | 168 int n, |
171 WebIDBCallbacks* callbacks_ptr, | 169 WebIDBCallbacks* callbacks_ptr, |
danakj
2016/11/18 00:15:33
and this?
| |
172 int32_t ipc_cursor_id) { | 170 int32_t ipc_cursor_id) { |
173 std::unique_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 171 int32_t ipc_callbacks_id = pending_callbacks_.Add( |
174 | 172 std::unique_ptr<WebIDBCallbacks>(callbacks_ptr)); |
175 int32_t ipc_callbacks_id = pending_callbacks_.Add(callbacks.release()); | |
176 Send(new IndexedDBHostMsg_CursorPrefetch( | 173 Send(new IndexedDBHostMsg_CursorPrefetch( |
177 ipc_cursor_id, CurrentWorkerId(), ipc_callbacks_id, n)); | 174 ipc_cursor_id, CurrentWorkerId(), ipc_callbacks_id, n)); |
178 } | 175 } |
179 | 176 |
180 void IndexedDBDispatcher::RequestIDBCursorPrefetchReset(int used_prefetches, | 177 void IndexedDBDispatcher::RequestIDBCursorPrefetchReset(int used_prefetches, |
181 int unused_prefetches, | 178 int unused_prefetches, |
182 int32_t ipc_cursor_id) { | 179 int32_t ipc_cursor_id) { |
183 Send(new IndexedDBHostMsg_CursorPrefetchReset( | 180 Send(new IndexedDBHostMsg_CursorPrefetchReset( |
184 ipc_cursor_id, used_prefetches, unused_prefetches)); | 181 ipc_cursor_id, used_prefetches, unused_prefetches)); |
185 } | 182 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; | 355 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; |
359 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 356 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
360 if (i->first == ipc_exception_cursor_id || | 357 if (i->first == ipc_exception_cursor_id || |
361 i->second->transaction_id() != transaction_id) | 358 i->second->transaction_id() != transaction_id) |
362 continue; | 359 continue; |
363 i->second->ResetPrefetchCache(); | 360 i->second->ResetPrefetchCache(); |
364 } | 361 } |
365 } | 362 } |
366 | 363 |
367 } // namespace content | 364 } // namespace content |
OLD | NEW |