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/browser/indexed_db/indexed_db_dispatcher_host.h" | 5 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 BrowserThread::DeleteOnIOThread::Destruct(this); | 88 BrowserThread::DeleteOnIOThread::Destruct(this); |
89 } | 89 } |
90 | 90 |
91 void IndexedDBDispatcherHost::ResetDispatcherHosts() { | 91 void IndexedDBDispatcherHost::ResetDispatcherHosts() { |
92 // It is important that the various *_dispatcher_host_ members are reset | 92 // It is important that the various *_dispatcher_host_ members are reset |
93 // on the IndexedDB thread, since there might be incoming messages on that | 93 // on the IndexedDB thread, since there might be incoming messages on that |
94 // thread, and we must not reset the dispatcher hosts until after those | 94 // thread, and we must not reset the dispatcher hosts until after those |
95 // messages are processed. | 95 // messages are processed. |
96 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 96 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
97 | 97 |
| 98 // Prevent any pending connections from being processed. |
| 99 is_open_ = false; |
| 100 |
98 // Note that we explicitly separate CloseAll() from destruction of the | 101 // Note that we explicitly separate CloseAll() from destruction of the |
99 // DatabaseDispatcherHost, since CloseAll() can invoke callbacks which need to | 102 // DatabaseDispatcherHost, since CloseAll() can invoke callbacks which need to |
100 // be dispatched through database_dispatcher_host_. | 103 // be dispatched through database_dispatcher_host_. |
101 database_dispatcher_host_->CloseAll(); | 104 database_dispatcher_host_->CloseAll(); |
102 database_dispatcher_host_.reset(); | 105 database_dispatcher_host_.reset(); |
103 cursor_dispatcher_host_.reset(); | 106 cursor_dispatcher_host_.reset(); |
104 } | 107 } |
105 | 108 |
106 base::TaskRunner* IndexedDBDispatcherHost::OverrideTaskRunnerForMessage( | 109 base::TaskRunner* IndexedDBDispatcherHost::OverrideTaskRunnerForMessage( |
107 const IPC::Message& message) { | 110 const IPC::Message& message) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 return; | 244 return; |
242 } | 245 } |
243 | 246 |
244 DCHECK_GE(iter->second.second, 1); | 247 DCHECK_GE(iter->second.second, 1); |
245 if (iter->second.second == 1) | 248 if (iter->second.second == 1) |
246 blob_data_handle_map_.erase(iter); | 249 blob_data_handle_map_.erase(iter); |
247 else | 250 else |
248 --iter->second.second; | 251 --iter->second.second; |
249 } | 252 } |
250 | 253 |
| 254 bool IndexedDBDispatcherHost::IsOpen() const { |
| 255 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
| 256 return is_open_; |
| 257 } |
| 258 |
251 IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId( | 259 IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId( |
252 int32_t ipc_cursor_id) { | 260 int32_t ipc_cursor_id) { |
253 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); | 261 DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); |
254 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); | 262 return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); |
255 } | 263 } |
256 | 264 |
257 ::IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata( | 265 ::IndexedDBDatabaseMetadata IndexedDBDispatcherHost::ConvertMetadata( |
258 const content::IndexedDBDatabaseMetadata& web_metadata) { | 266 const content::IndexedDBDatabaseMetadata& web_metadata) { |
259 ::IndexedDBDatabaseMetadata metadata; | 267 ::IndexedDBDatabaseMetadata metadata; |
260 metadata.id = web_metadata.id; | 268 metadata.id = web_metadata.id; |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 DLOG(ERROR) << "Unable to reset prefetch"; | 1100 DLOG(ERROR) << "Unable to reset prefetch"; |
1093 } | 1101 } |
1094 | 1102 |
1095 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( | 1103 void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( |
1096 int32_t ipc_object_id) { | 1104 int32_t ipc_object_id) { |
1097 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); | 1105 DCHECK(parent_->context()->TaskRunner()->RunsTasksOnCurrentThread()); |
1098 parent_->DestroyObject(&map_, ipc_object_id); | 1106 parent_->DestroyObject(&map_, ipc_object_id); |
1099 } | 1107 } |
1100 | 1108 |
1101 } // namespace content | 1109 } // namespace content |
OLD | NEW |