OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 old_database_metadata_(old_metadata) { | 158 old_database_metadata_(old_metadata) { |
159 DCHECK(database_); | 159 DCHECK(database_); |
160 DCHECK(open_db_request_); | 160 DCHECK(open_db_request_); |
161 DCHECK(scope_.IsEmpty()); | 161 DCHECK(scope_.IsEmpty()); |
162 | 162 |
163 database_->TransactionCreated(this); | 163 database_->TransactionCreated(this); |
164 } | 164 } |
165 | 165 |
166 IDBTransaction::~IDBTransaction() { | 166 IDBTransaction::~IDBTransaction() { |
167 // Note: IDBTransaction is a ContextLifecycleObserver (rather than | 167 // Note: IDBTransaction is a ContextLifecycleObserver (rather than |
168 // ContextClient) only in order to be able call upon getExecutionContext() | 168 // ContextClient) only in order to be able call upon GetExecutionContext() |
169 // during this destructor. | 169 // during this destructor. |
170 DCHECK(state_ == kFinished || !GetExecutionContext()); | 170 DCHECK(state_ == kFinished || !GetExecutionContext()); |
171 DCHECK(request_list_.IsEmpty() || !GetExecutionContext()); | 171 DCHECK(request_list_.IsEmpty() || !GetExecutionContext()); |
172 } | 172 } |
173 | 173 |
174 DEFINE_TRACE(IDBTransaction) { | 174 DEFINE_TRACE(IDBTransaction) { |
175 visitor->Trace(database_); | 175 visitor->Trace(database_); |
176 visitor->Trace(open_db_request_); | 176 visitor->Trace(open_db_request_); |
177 visitor->Trace(error_); | 177 visitor->Trace(error_); |
178 visitor->Trace(request_list_); | 178 visitor->Trace(request_list_); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 << "A non-versionchange transaction renamed an object store"; | 298 << "A non-versionchange transaction renamed an object store"; |
299 | 299 |
300 DCHECK(!object_store_map_.Contains(new_name)); | 300 DCHECK(!object_store_map_.Contains(new_name)); |
301 DCHECK(object_store_map_.Contains(old_name)) | 301 DCHECK(object_store_map_.Contains(old_name)) |
302 << "The object store had to be accessed in order to be renamed."; | 302 << "The object store had to be accessed in order to be renamed."; |
303 object_store_map_.Set(new_name, object_store_map_.Take(old_name)); | 303 object_store_map_.Set(new_name, object_store_map_.Take(old_name)); |
304 } | 304 } |
305 | 305 |
306 void IDBTransaction::IndexDeleted(IDBIndex* index) { | 306 void IDBTransaction::IndexDeleted(IDBIndex* index) { |
307 DCHECK(index); | 307 DCHECK(index); |
308 DCHECK(!index->IsDeleted()) << "indexDeleted called twice for the same index"; | 308 DCHECK(!index->IsDeleted()) << "IndexDeleted called twice for the same index"; |
309 | 309 |
310 IDBObjectStore* object_store = index->objectStore(); | 310 IDBObjectStore* object_store = index->objectStore(); |
311 DCHECK_EQ(object_store->transaction(), this); | 311 DCHECK_EQ(object_store->transaction(), this); |
312 DCHECK(object_store_map_.Contains(object_store->name())) | 312 DCHECK(object_store_map_.Contains(object_store->name())) |
313 << "An index was deleted without accessing its object store"; | 313 << "An index was deleted without accessing its object store"; |
314 | 314 |
315 const auto& object_store_iterator = old_store_metadata_.Find(object_store); | 315 const auto& object_store_iterator = old_store_metadata_.Find(object_store); |
316 if (object_store_iterator == old_store_metadata_.end()) { | 316 if (object_store_iterator == old_store_metadata_.end()) { |
317 // The index's object store was created in this transaction, so this | 317 // The index's object store was created in this transaction, so this |
318 // index was also created (and deleted) in this transaction, and will | 318 // index was also created (and deleted) in this transaction, and will |
(...skipping 15 matching lines...) Expand all Loading... |
334 // The index's object store was created before this transaction, but the | 334 // The index's object store was created before this transaction, but the |
335 // index was created (and deleted) in this transaction, so it will not | 335 // index was created (and deleted) in this transaction, so it will not |
336 // be restored if the transaction aborts. | 336 // be restored if the transaction aborts. |
337 return; | 337 return; |
338 } | 338 } |
339 | 339 |
340 deleted_indexes_.push_back(index); | 340 deleted_indexes_.push_back(index); |
341 } | 341 } |
342 | 342 |
343 void IDBTransaction::SetActive(bool active) { | 343 void IDBTransaction::SetActive(bool active) { |
344 DCHECK_NE(state_, kFinished) << "A finished transaction tried to setActive(" | 344 DCHECK_NE(state_, kFinished) << "A finished transaction tried to SetActive(" |
345 << (active ? "true" : "false") << ")"; | 345 << (active ? "true" : "false") << ")"; |
346 if (state_ == kFinishing) | 346 if (state_ == kFinishing) |
347 return; | 347 return; |
348 DCHECK_NE(active, (state_ == kActive)); | 348 DCHECK_NE(active, (state_ == kActive)); |
349 state_ = active ? kActive : kInactive; | 349 state_ = active ? kActive : kInactive; |
350 | 350 |
351 if (!active && request_list_.IsEmpty() && BackendDB()) | 351 if (!active && request_list_.IsEmpty() && BackendDB()) |
352 BackendDB()->Commit(id_); | 352 BackendDB()->Commit(id_); |
353 } | 353 } |
354 | 354 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 // Remove references to the IDBObjectStore and IDBIndex instances held by | 581 // Remove references to the IDBObjectStore and IDBIndex instances held by |
582 // this transaction, so Oilpan can garbage-collect the instances that aren't | 582 // this transaction, so Oilpan can garbage-collect the instances that aren't |
583 // used by JavaScript. | 583 // used by JavaScript. |
584 | 584 |
585 for (auto& it : object_store_map_) { | 585 for (auto& it : object_store_map_) { |
586 IDBObjectStore* object_store = it.value; | 586 IDBObjectStore* object_store = it.value; |
587 if (!IsVersionChange() || object_store->IsNewlyCreated()) { | 587 if (!IsVersionChange() || object_store->IsNewlyCreated()) { |
588 DCHECK(!old_store_metadata_.Contains(object_store)); | 588 DCHECK(!old_store_metadata_.Contains(object_store)); |
589 object_store->ClearIndexCache(); | 589 object_store->ClearIndexCache(); |
590 } else { | 590 } else { |
591 // We'll call clearIndexCache() on this store in the loop below. | 591 // We'll call ClearIndexCache() on this store in the loop below. |
592 DCHECK(old_store_metadata_.Contains(object_store)); | 592 DCHECK(old_store_metadata_.Contains(object_store)); |
593 } | 593 } |
594 } | 594 } |
595 object_store_map_.Clear(); | 595 object_store_map_.Clear(); |
596 | 596 |
597 for (auto& it : old_store_metadata_) { | 597 for (auto& it : old_store_metadata_) { |
598 IDBObjectStore* object_store = it.key; | 598 IDBObjectStore* object_store = it.key; |
599 object_store->ClearIndexCache(); | 599 object_store->ClearIndexCache(); |
600 } | 600 } |
601 old_store_metadata_.Clear(); | 601 old_store_metadata_.Clear(); |
602 | 602 |
603 deleted_indexes_.Clear(); | 603 deleted_indexes_.Clear(); |
604 deleted_object_stores_.Clear(); | 604 deleted_object_stores_.Clear(); |
605 } | 605 } |
606 | 606 |
607 } // namespace blink | 607 } // namespace blink |
OLD | NEW |