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_constants.h" | |
18 #include "content/common/indexed_db/indexed_db_messages.h" | 17 #include "content/common/indexed_db/indexed_db_messages.h" |
19 #include "ipc/ipc_channel.h" | 18 #include "ipc/ipc_channel.h" |
20 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal
lbacks.h" | 19 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal
lbacks.h" |
21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr
or.h" | 20 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr
or.h" |
22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc
eption.h" | 21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc
eption.h" |
23 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBValue.h" | 22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBValue.h" |
24 | 23 |
25 using blink::WebBlobInfo; | 24 using blink::WebBlobInfo; |
26 using blink::WebData; | 25 using blink::WebData; |
27 using blink::WebIDBCallbacks; | 26 using blink::WebIDBCallbacks; |
(...skipping 12 matching lines...) Expand all Loading... |
40 static base::LazyInstance<ThreadLocalPointer<IndexedDBDispatcher> >::Leaky | 39 static base::LazyInstance<ThreadLocalPointer<IndexedDBDispatcher> >::Leaky |
41 g_idb_dispatcher_tls = LAZY_INSTANCE_INITIALIZER; | 40 g_idb_dispatcher_tls = LAZY_INSTANCE_INITIALIZER; |
42 | 41 |
43 namespace { | 42 namespace { |
44 | 43 |
45 IndexedDBDispatcher* const kHasBeenDeleted = | 44 IndexedDBDispatcher* const kHasBeenDeleted = |
46 reinterpret_cast<IndexedDBDispatcher*>(0x1); | 45 reinterpret_cast<IndexedDBDispatcher*>(0x1); |
47 | 46 |
48 } // unnamed namespace | 47 } // unnamed namespace |
49 | 48 |
50 const size_t kMaxIDBValueSizeInBytes = | |
51 IPC::Channel::kMaximumMessageSize - kMaxIDBMessageOverhead; | |
52 | |
53 IndexedDBDispatcher::IndexedDBDispatcher(ThreadSafeSender* thread_safe_sender) | 49 IndexedDBDispatcher::IndexedDBDispatcher(ThreadSafeSender* thread_safe_sender) |
54 : thread_safe_sender_(thread_safe_sender), | 50 : thread_safe_sender_(thread_safe_sender) { |
55 max_put_value_size_(kMaxIDBValueSizeInBytes) { | |
56 g_idb_dispatcher_tls.Pointer()->Set(this); | 51 g_idb_dispatcher_tls.Pointer()->Set(this); |
57 } | 52 } |
58 | 53 |
59 IndexedDBDispatcher::~IndexedDBDispatcher() { | 54 IndexedDBDispatcher::~IndexedDBDispatcher() { |
60 // Clear any pending callbacks - which may result in dispatch requests - | 55 // Clear any pending callbacks - which may result in dispatch requests - |
61 // before marking the dispatcher as deleted. | 56 // before marking the dispatcher as deleted. |
62 pending_callbacks_.Clear(); | 57 pending_callbacks_.Clear(); |
63 pending_database_callbacks_.Clear(); | 58 pending_database_callbacks_.Clear(); |
64 | 59 |
65 DCHECK(pending_callbacks_.IsEmpty()); | 60 DCHECK(pending_callbacks_.IsEmpty()); |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 typedef std::map<int32, WebIDBCursorImpl*>::iterator Iterator; | 827 typedef std::map<int32, WebIDBCursorImpl*>::iterator Iterator; |
833 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 828 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
834 if (i->first == ipc_exception_cursor_id || | 829 if (i->first == ipc_exception_cursor_id || |
835 i->second->transaction_id() != transaction_id) | 830 i->second->transaction_id() != transaction_id) |
836 continue; | 831 continue; |
837 i->second->ResetPrefetchCache(); | 832 i->second->ResetPrefetchCache(); |
838 } | 833 } |
839 } | 834 } |
840 | 835 |
841 } // namespace content | 836 } // namespace content |
OLD | NEW |