| 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" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/threading/thread_local.h" | 12 #include "base/threading/thread_local.h" |
| 13 #include "content/child/indexed_db/indexed_db_key_builders.h" | 13 #include "content/child/indexed_db/indexed_db_key_builders.h" |
| 14 #include "content/child/indexed_db/webidbcursor_impl.h" | 14 #include "content/child/indexed_db/webidbcursor_impl.h" |
| 15 #include "content/child/indexed_db/webidbdatabase_impl.h" | 15 #include "content/child/indexed_db/webidbdatabase_impl.h" |
| 16 #include "content/child/thread_safe_sender.h" | 16 #include "content/child/thread_safe_sender.h" |
| 17 #include "content/common/indexed_db/indexed_db_messages.h" | 17 #include "content/common/indexed_db/indexed_db_messages.h" |
| 18 #include "ipc/ipc_channel.h" | 18 #include "ipc/ipc_channel.h" |
| 19 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal
lbacks.h" | 19 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal
lbacks.h" |
| 20 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr
or.h" | 20 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr
or.h" |
| 21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc
eption.h" | 21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc
eption.h" |
| 22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBValue.h" | 22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBValue.h" |
| 23 | 23 |
| 24 using blink::IDBObserver; |
| 24 using blink::WebBlobInfo; | 25 using blink::WebBlobInfo; |
| 25 using blink::WebData; | 26 using blink::WebData; |
| 26 using blink::WebIDBCallbacks; | 27 using blink::WebIDBCallbacks; |
| 27 using blink::WebIDBCursor; | 28 using blink::WebIDBCursor; |
| 28 using blink::WebIDBDatabase; | 29 using blink::WebIDBDatabase; |
| 29 using blink::WebIDBDatabaseCallbacks; | 30 using blink::WebIDBDatabaseCallbacks; |
| 30 using blink::WebIDBDatabaseError; | 31 using blink::WebIDBDatabaseError; |
| 31 using blink::WebIDBKey; | 32 using blink::WebIDBKey; |
| 32 using blink::WebIDBMetadata; | 33 using blink::WebIDBMetadata; |
| 33 using blink::WebIDBValue; | 34 using blink::WebIDBValue; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // If a message gets here, IndexedDBMessageFilter already determined that it | 161 // If a message gets here, IndexedDBMessageFilter already determined that it |
| 161 // is an IndexedDB message. | 162 // is an IndexedDB message. |
| 162 DCHECK(handled) << "Didn't handle a message defined at line " | 163 DCHECK(handled) << "Didn't handle a message defined at line " |
| 163 << IPC_MESSAGE_ID_LINE(msg.type()); | 164 << IPC_MESSAGE_ID_LINE(msg.type()); |
| 164 } | 165 } |
| 165 | 166 |
| 166 bool IndexedDBDispatcher::Send(IPC::Message* msg) { | 167 bool IndexedDBDispatcher::Send(IPC::Message* msg) { |
| 167 return thread_safe_sender_->Send(msg); | 168 return thread_safe_sender_->Send(msg); |
| 168 } | 169 } |
| 169 | 170 |
| 171 int32_t IndexedDBDispatcher::AddIDBObserver(int32_t ipc_database_id, |
| 172 int64_t transaction_id, |
| 173 blink::IDBObserver* observer) { |
| 174 // TODO(palakj): generate id through IDMap here. |
| 175 int32_t observer_id = 0; |
| 176 Send(new IndexedDBHostMsg_DatabaseObserve(CurrentWorkerId(), ipc_database_id, |
| 177 transaction_id, observer_id)); |
| 178 return observer_id; |
| 179 } |
| 180 |
| 181 std::vector<int32_t> IndexedDBDispatcher::RemoveIDBObserver( |
| 182 int32_t ipc_database_id, |
| 183 blink::IDBObserver* observer) { |
| 184 std::vector<int32_t> remove_observers; |
| 185 // TODO(palakj): iterate over map to find observer and collect id's in |
| 186 // remove_observers |
| 187 |
| 188 Send(new IndexedDBHostMsg_DatabaseUnobserve( |
| 189 CurrentWorkerId(), ipc_database_id, remove_observers)); |
| 190 return remove_observers; |
| 191 } |
| 192 |
| 170 void IndexedDBDispatcher::RequestIDBCursorAdvance( | 193 void IndexedDBDispatcher::RequestIDBCursorAdvance( |
| 171 unsigned long count, | 194 unsigned long count, |
| 172 WebIDBCallbacks* callbacks_ptr, | 195 WebIDBCallbacks* callbacks_ptr, |
| 173 int32_t ipc_cursor_id, | 196 int32_t ipc_cursor_id, |
| 174 int64_t transaction_id) { | 197 int64_t transaction_id) { |
| 175 // Reset all cursor prefetch caches except for this cursor. | 198 // Reset all cursor prefetch caches except for this cursor. |
| 176 ResetCursorPrefetchCaches(transaction_id, ipc_cursor_id); | 199 ResetCursorPrefetchCaches(transaction_id, ipc_cursor_id); |
| 177 | 200 |
| 178 std::unique_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 201 std::unique_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 179 | 202 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; | 823 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; |
| 801 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 824 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 802 if (i->first == ipc_exception_cursor_id || | 825 if (i->first == ipc_exception_cursor_id || |
| 803 i->second->transaction_id() != transaction_id) | 826 i->second->transaction_id() != transaction_id) |
| 804 continue; | 827 continue; |
| 805 i->second->ResetPrefetchCache(); | 828 i->second->ResetPrefetchCache(); |
| 806 } | 829 } |
| 807 } | 830 } |
| 808 | 831 |
| 809 } // namespace content | 832 } // namespace content |
| OLD | NEW |