Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/indexed_db/indexed_db_dispatcher.h" | 5 #include "content/common/indexed_db/indexed_db_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/threading/thread_local.h" | 8 #include "base/threading/thread_local.h" |
| 9 #include "content/common/child_thread.h" | 9 #include "content/common/child_thread.h" |
| 10 #include "content/common/indexed_db/indexed_db_messages.h" | 10 #include "content/common/indexed_db/indexed_db_messages.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 } | 47 } |
| 48 } // unnamed namespace | 48 } // unnamed namespace |
| 49 | 49 |
| 50 const size_t kMaxIDBValueSizeInBytes = 64 * 1024 * 1024; | 50 const size_t kMaxIDBValueSizeInBytes = 64 * 1024 * 1024; |
| 51 | 51 |
| 52 IndexedDBDispatcher::IndexedDBDispatcher() { | 52 IndexedDBDispatcher::IndexedDBDispatcher() { |
| 53 g_idb_dispatcher_tls.Pointer()->Set(this); | 53 g_idb_dispatcher_tls.Pointer()->Set(this); |
| 54 } | 54 } |
| 55 | 55 |
| 56 IndexedDBDispatcher::~IndexedDBDispatcher() { | 56 IndexedDBDispatcher::~IndexedDBDispatcher() { |
| 57 | |
| 58 // Clear any pending callbacks - which may result in dispatch requests - | |
| 59 // before marking the dispatcher as deleted. | |
| 60 for (IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer>::iterator | |
| 61 it(&pending_callbacks_); !it.IsAtEnd(); it.Advance()) { | |
| 62 pending_callbacks_.Remove(it.GetCurrentKey()); | |
|
michaeln
2012/10/24 19:54:49
Odd that there's no .Clear() method on the IDMap<>
| |
| 63 } | |
| 64 for (IDMap<WebKit::WebIDBDatabaseCallbacks, IDMapOwnPointer>::iterator | |
| 65 it(&pending_database_callbacks_); !it.IsAtEnd(); it.Advance()) { | |
| 66 pending_database_callbacks_.Remove(it.GetCurrentKey()); | |
| 67 } | |
| 68 for (IDMap<WebKit::WebIDBTransactionCallbacks, IDMapOwnPointer>::iterator | |
| 69 it(&pending_transaction_callbacks_); !it.IsAtEnd(); it.Advance()) { | |
| 70 pending_transaction_callbacks_.Remove(it.GetCurrentKey()); | |
| 71 } | |
| 72 | |
| 73 DCHECK(pending_callbacks_.IsEmpty()); | |
| 74 DCHECK(pending_database_callbacks_.IsEmpty()); | |
| 75 DCHECK(pending_transaction_callbacks_.IsEmpty()); | |
| 76 | |
| 57 g_idb_dispatcher_tls.Pointer()->Set(kHasBeenDeleted); | 77 g_idb_dispatcher_tls.Pointer()->Set(kHasBeenDeleted); |
| 58 } | 78 } |
| 59 | 79 |
| 60 IndexedDBDispatcher* IndexedDBDispatcher::ThreadSpecificInstance() { | 80 IndexedDBDispatcher* IndexedDBDispatcher::ThreadSpecificInstance() { |
| 61 if (g_idb_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { | 81 if (g_idb_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { |
| 62 NOTREACHED() << "Re-instantiating TLS IndexedDBDispatcher."; | 82 NOTREACHED() << "Re-instantiating TLS IndexedDBDispatcher."; |
| 63 g_idb_dispatcher_tls.Pointer()->Set(NULL); | 83 g_idb_dispatcher_tls.Pointer()->Set(NULL); |
| 64 } | 84 } |
| 65 if (g_idb_dispatcher_tls.Pointer()->Get()) | 85 if (g_idb_dispatcher_tls.Pointer()->Get()) |
| 66 return g_idb_dispatcher_tls.Pointer()->Get(); | 86 return g_idb_dispatcher_tls.Pointer()->Get(); |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { | 789 void IndexedDBDispatcher::ResetCursorPrefetchCaches(int32 exception_cursor_id) { |
| 770 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; | 790 typedef std::map<int32, RendererWebIDBCursorImpl*>::iterator Iterator; |
| 771 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 791 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
| 772 if (i->first == exception_cursor_id) | 792 if (i->first == exception_cursor_id) |
| 773 continue; | 793 continue; |
| 774 i->second->ResetPrefetchCache(); | 794 i->second->ResetPrefetchCache(); |
| 775 } | 795 } |
| 776 } | 796 } |
| 777 | 797 |
| 778 } // namespace content | 798 } // namespace content |
| OLD | NEW |