Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 using blink::WebBlobInfo; | 24 using blink::WebBlobInfo; |
| 25 using blink::WebData; | 25 using blink::WebData; |
| 26 using blink::WebIDBCallbacks; | 26 using blink::WebIDBCallbacks; |
| 27 using blink::WebIDBCursor; | 27 using blink::WebIDBCursor; |
| 28 using blink::WebIDBDatabase; | 28 using blink::WebIDBDatabase; |
| 29 using blink::WebIDBDatabaseCallbacks; | 29 using blink::WebIDBDatabaseCallbacks; |
| 30 using blink::WebIDBDatabaseError; | 30 using blink::WebIDBDatabaseError; |
| 31 using blink::WebIDBKey; | 31 using blink::WebIDBKey; |
| 32 using blink::WebIDBMetadata; | 32 using blink::WebIDBMetadata; |
| 33 using blink::WebIDBObserver; | |
| 33 using blink::WebIDBValue; | 34 using blink::WebIDBValue; |
| 34 using blink::WebString; | 35 using blink::WebString; |
| 35 using blink::WebVector; | 36 using blink::WebVector; |
| 36 using base::ThreadLocalPointer; | 37 using base::ThreadLocalPointer; |
| 37 | 38 |
| 38 namespace content { | 39 namespace content { |
| 39 static base::LazyInstance<ThreadLocalPointer<IndexedDBDispatcher> >::Leaky | 40 static base::LazyInstance<ThreadLocalPointer<IndexedDBDispatcher> >::Leaky |
| 40 g_idb_dispatcher_tls = LAZY_INSTANCE_INITIALIZER; | 41 g_idb_dispatcher_tls = LAZY_INSTANCE_INITIALIZER; |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| (...skipping 117 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 WebIDBObserver* observer_ptr) { | |
| 174 std::unique_ptr<WebIDBObserver> observer(observer_ptr); | |
|
dmurph
2016/06/28 18:53:50
This is weird, just pass the observer_ptr to the o
palakj1
2016/06/29 23:02:40
I had been imitating the previous styles. But, you
| |
| 175 int32_t observer_id = observers_.Add(observer.release()); | |
| 176 Send(new IndexedDBHostMsg_DatabaseObserve(ipc_database_id, transaction_id, | |
| 177 observer_id)); | |
| 178 return observer_id; | |
| 179 } | |
| 180 | |
| 181 void IndexedDBDispatcher::RemoveIDBObserversFromDatabase( | |
| 182 int32_t ipc_database_id, | |
| 183 const std::vector<int32_t>& observer_ids_to_remove) { | |
| 184 for (int32_t id_to_remove : observer_ids_to_remove) { | |
| 185 observers_.Remove(id_to_remove); | |
| 186 } | |
| 187 Send(new IndexedDBHostMsg_DatabaseUnobserve(ipc_database_id, | |
| 188 observer_ids_to_remove)); | |
| 189 } | |
| 190 | |
| 191 void IndexedDBDispatcher::RemoveIDBObservers( | |
| 192 const std::set<int32_t>& observer_ids_to_remove) { | |
| 193 for (int32_t id : observer_ids_to_remove) { | |
| 194 WebIDBObserver* observer = observers_.Lookup(id); | |
| 195 observer->removeObserver(id); | |
| 196 observers_.Remove(id); | |
| 197 } | |
| 198 } | |
| 199 | |
| 170 void IndexedDBDispatcher::RequestIDBCursorAdvance( | 200 void IndexedDBDispatcher::RequestIDBCursorAdvance( |
| 171 unsigned long count, | 201 unsigned long count, |
| 172 WebIDBCallbacks* callbacks_ptr, | 202 WebIDBCallbacks* callbacks_ptr, |
| 173 int32_t ipc_cursor_id, | 203 int32_t ipc_cursor_id, |
| 174 int64_t transaction_id) { | 204 int64_t transaction_id) { |
| 175 // Reset all cursor prefetch caches except for this cursor. | 205 // Reset all cursor prefetch caches except for this cursor. |
| 176 ResetCursorPrefetchCaches(transaction_id, ipc_cursor_id); | 206 ResetCursorPrefetchCaches(transaction_id, ipc_cursor_id); |
| 177 | 207 |
| 178 std::unique_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); | 208 std::unique_ptr<WebIDBCallbacks> callbacks(callbacks_ptr); |
| 179 | 209 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 800 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; | 830 typedef std::map<int32_t, WebIDBCursorImpl*>::iterator Iterator; |
| 801 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 831 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 802 if (i->first == ipc_exception_cursor_id || | 832 if (i->first == ipc_exception_cursor_id || |
| 803 i->second->transaction_id() != transaction_id) | 833 i->second->transaction_id() != transaction_id) |
| 804 continue; | 834 continue; |
| 805 i->second->ResetPrefetchCache(); | 835 i->second->ResetPrefetchCache(); |
| 806 } | 836 } |
| 807 } | 837 } |
| 808 | 838 |
| 809 } // namespace content | 839 } // namespace content |
| OLD | NEW |