| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // If a message gets here, IndexedDBMessageFilter already determined that it | 161 // If a message gets here, IndexedDBMessageFilter already determined that it |
| 162 // is an IndexedDB message. | 162 // is an IndexedDB message. |
| 163 DCHECK(handled) << "Didn't handle a message defined at line " | 163 DCHECK(handled) << "Didn't handle a message defined at line " |
| 164 << IPC_MESSAGE_ID_LINE(msg.type()); | 164 << IPC_MESSAGE_ID_LINE(msg.type()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 bool IndexedDBDispatcher::Send(IPC::Message* msg) { | 167 bool IndexedDBDispatcher::Send(IPC::Message* msg) { |
| 168 return thread_safe_sender_->Send(msg); | 168 return thread_safe_sender_->Send(msg); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void IndexedDBDispatcher::AddIDBObserver(int32_t ipc_database_id, | 171 int32_t IndexedDBDispatcher::AddIDBObserver(int32_t ipc_database_id, |
| 172 int64_t transaction_id, | 172 int64_t transaction_id, |
| 173 blink::IDBObserver* observer) { | 173 blink::IDBObserver* observer) { |
| 174 int64_t observer_id = maxObserverId++; | 174 // TODO(palakj): generate id through IDMap here. |
| 175 observers_[observer_id] = observer; | 175 int32_t observer_id = 0; |
| 176 // params.ipc_thread_id = CurrentWorkerId(); | |
| 177 // params.ipc_database_id = ipc_database_id; | |
| 178 // params.transaction_id = transaction_id; | |
| 179 // params.observer_id = observer_id; | |
| 180 Send(new IndexedDBHostMsg_DatabaseObserve( | 176 Send(new IndexedDBHostMsg_DatabaseObserve( |
| 181 CurrentWorkerId(), | 177 CurrentWorkerId(), |
| 182 ipc_database_id, | 178 ipc_database_id, |
| 183 transaction_id, | 179 transaction_id, |
| 184 observer_id)); | 180 observer_id)); |
| 181 return observer_id; |
| 182 } |
| 183 |
| 184 std::vector<int32_t> IndexedDBDispatcher::RemoveIDBObserver( |
| 185 int32_t ipc_database_id, |
| 186 blink::IDBObserver* observer) { |
| 187 std::vector<int32_t> remove_observers; |
| 188 // TODO(palakj): iterate over map to find observer and collect id's in |
| 189 // remove_observers |
| 190 |
| 191 Send(new IndexedDBHostMsg_DatabaseUnobserve( |
| 192 CurrentWorkerId(), ipc_database_id, remove_observers)); |
| 193 return remove_observers; |
| 185 } | 194 } |
| 186 | 195 |
| 187 void IndexedDBDispatcher::RequestIDBCursorAdvance( | 196 void IndexedDBDispatcher::RequestIDBCursorAdvance( |
| 188 unsigned long count, | 197 unsigned long count, |
| 189 WebIDBCallbacks* callbacks_ptr, | 198 WebIDBCallbacks* callbacks_ptr, |
| 190 int32_t ipc_cursor_id, | 199 int32_t ipc_cursor_id, |
| 191 int64_t transaction_id) { | 200 int64_t transaction_id) { |
| 192 // Reset all cursor prefetch caches except for this cursor. | 201 // Reset all cursor prefetch caches except for this cursor. |
| 193 ResetCursorPrefetchCaches(transaction_id, ipc_cursor_id); | 202 ResetCursorPrefetchCaches(transaction_id, ipc_cursor_id); |
| 194 | 203 |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; | 826 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; |
| 818 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 827 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 819 if (i->first == ipc_exception_cursor_id || | 828 if (i->first == ipc_exception_cursor_id || |
| 820 i->second->transaction_id() != transaction_id) | 829 i->second->transaction_id() != transaction_id) |
| 821 continue; | 830 continue; |
| 822 i->second->ResetPrefetchCache(); | 831 i->second->ResetPrefetchCache(); |
| 823 } | 832 } |
| 824 } | 833 } |
| 825 | 834 |
| 826 } // namespace content | 835 } // namespace content |
| OLD | NEW |