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/in_process_webkit/indexed_db_dispatcher_host.h" | 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 | 158 |
159 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database, | 159 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database, |
160 int32 thread_id, | 160 int32 thread_id, |
161 const GURL& origin_url) { | 161 const GURL& origin_url) { |
162 if (!database_dispatcher_host_.get()) { | 162 if (!database_dispatcher_host_.get()) { |
163 delete idb_database; | 163 delete idb_database; |
164 return 0; | 164 return 0; |
165 } | 165 } |
166 int32 idb_database_id = database_dispatcher_host_->map_.Add(idb_database); | 166 int32 idb_database_id = database_dispatcher_host_->map_.Add(idb_database); |
167 Context()->ConnectionOpened(origin_url); | 167 Context()->ConnectionOpened(origin_url, idb_database); |
168 database_dispatcher_host_->database_url_map_[idb_database_id] = origin_url; | 168 database_dispatcher_host_->database_url_map_[idb_database_id] = origin_url; |
169 return idb_database_id; | 169 return idb_database_id; |
170 } | 170 } |
171 | 171 |
172 int32 IndexedDBDispatcherHost::Add(WebIDBIndex* idb_index) { | 172 int32 IndexedDBDispatcherHost::Add(WebIDBIndex* idb_index) { |
173 if (!index_dispatcher_host_.get()) { | 173 if (!index_dispatcher_host_.get()) { |
174 delete idb_index; | 174 delete idb_index; |
175 return 0; | 175 return 0; |
176 } | 176 } |
177 if (!idb_index) | 177 if (!idb_index) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 IndexedDBDispatcherHost::DatabaseDispatcherHost::DatabaseDispatcherHost( | 294 IndexedDBDispatcherHost::DatabaseDispatcherHost::DatabaseDispatcherHost( |
295 IndexedDBDispatcherHost* parent) | 295 IndexedDBDispatcherHost* parent) |
296 : parent_(parent) { | 296 : parent_(parent) { |
297 map_.set_check_on_null_data(true); | 297 map_.set_check_on_null_data(true); |
298 } | 298 } |
299 | 299 |
300 IndexedDBDispatcherHost::DatabaseDispatcherHost::~DatabaseDispatcherHost() { | 300 IndexedDBDispatcherHost::DatabaseDispatcherHost::~DatabaseDispatcherHost() { |
301 for (WebIDBObjectIDToURLMap::iterator iter = database_url_map_.begin(); | 301 for (WebIDBObjectIDToURLMap::iterator iter = database_url_map_.begin(); |
302 iter != database_url_map_.end(); iter++) { | 302 iter != database_url_map_.end(); iter++) { |
303 WebIDBDatabase* database = map_.Lookup(iter->first); | 303 WebIDBDatabase* database = map_.Lookup(iter->first); |
304 if (database) | 304 if (database) { |
305 database->close(); | 305 database->close(); |
306 parent_->Context()->ConnectionClosed(iter->second); | 306 parent_->Context()->ConnectionClosed(iter->second, database); |
| 307 } |
307 } | 308 } |
308 } | 309 } |
309 | 310 |
310 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( | 311 bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( |
311 const IPC::Message& message, bool* msg_is_ok) { | 312 const IPC::Message& message, bool* msg_is_ok) { |
312 bool handled = true; | 313 bool handled = true; |
313 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, | 314 IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost, |
314 message, *msg_is_ok) | 315 message, *msg_is_ok) |
315 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) | 316 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata) |
316 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, | 317 IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 int32 idb_database_id) { | 467 int32 idb_database_id) { |
467 WebIDBDatabase* database = parent_->GetOrTerminateProcess( | 468 WebIDBDatabase* database = parent_->GetOrTerminateProcess( |
468 &map_, idb_database_id); | 469 &map_, idb_database_id); |
469 if (!database) | 470 if (!database) |
470 return; | 471 return; |
471 database->close(); | 472 database->close(); |
472 } | 473 } |
473 | 474 |
474 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( | 475 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( |
475 int32 object_id) { | 476 int32 object_id) { |
476 parent_->Context()->ConnectionClosed(database_url_map_[object_id]); | 477 WebIDBDatabase* database = map_.Lookup(object_id); |
| 478 parent_->Context()->ConnectionClosed(database_url_map_[object_id], database); |
477 database_url_map_.erase(object_id); | 479 database_url_map_.erase(object_id); |
478 parent_->DestroyObject(&map_, object_id); | 480 parent_->DestroyObject(&map_, object_id); |
479 } | 481 } |
480 | 482 |
481 | 483 |
482 ////////////////////////////////////////////////////////////////////// | 484 ////////////////////////////////////////////////////////////////////// |
483 // IndexedDBDispatcherHost::IndexDispatcherHost | 485 // IndexedDBDispatcherHost::IndexDispatcherHost |
484 // | 486 // |
485 | 487 |
486 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( | 488 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 } | 1110 } |
1109 | 1111 |
1110 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( | 1112 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( |
1111 int32 object_id) { | 1113 int32 object_id) { |
1112 // TODO(dgrogan): This doesn't seem to be happening with some version change | 1114 // TODO(dgrogan): This doesn't seem to be happening with some version change |
1113 // transactions. Possibly introduced with integer version support. | 1115 // transactions. Possibly introduced with integer version support. |
1114 transaction_size_map_.erase(object_id); | 1116 transaction_size_map_.erase(object_id); |
1115 transaction_url_map_.erase(object_id); | 1117 transaction_url_map_.erase(object_id); |
1116 parent_->DestroyObject(&map_, object_id); | 1118 parent_->DestroyObject(&map_, object_id); |
1117 } | 1119 } |
OLD | NEW |