| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #include "modules/webdatabase/SQLTransactionCoordinator.h" | 32 #include "modules/webdatabase/SQLTransactionCoordinator.h" |
| 33 | 33 |
| 34 #include "modules/webdatabase/Database.h" | 34 #include "modules/webdatabase/Database.h" |
| 35 #include "modules/webdatabase/SQLTransactionBackend.h" | 35 #include "modules/webdatabase/SQLTransactionBackend.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 static String GetDatabaseIdentifier(SQLTransactionBackend* transaction) { | 39 static String GetDatabaseIdentifier(SQLTransactionBackend* transaction) { |
| 40 Database* database = transaction->GetDatabase(); | 40 Database* database = transaction->GetDatabase(); |
| 41 ASSERT(database); | 41 DCHECK(database); |
| 42 return database->StringIdentifier(); | 42 return database->StringIdentifier(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 SQLTransactionCoordinator::SQLTransactionCoordinator() | 45 SQLTransactionCoordinator::SQLTransactionCoordinator() |
| 46 : is_shutting_down_(false) {} | 46 : is_shutting_down_(false) {} |
| 47 | 47 |
| 48 DEFINE_TRACE(SQLTransactionCoordinator) {} | 48 DEFINE_TRACE(SQLTransactionCoordinator) {} |
| 49 | 49 |
| 50 void SQLTransactionCoordinator::ProcessPendingTransactions( | 50 void SQLTransactionCoordinator::ProcessPendingTransactions( |
| 51 CoordinationInfo& info) { | 51 CoordinationInfo& info) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 63 info.pending_transactions.front()->IsReadOnly()); | 63 info.pending_transactions.front()->IsReadOnly()); |
| 64 } else if (info.active_read_transactions.IsEmpty()) { | 64 } else if (info.active_read_transactions.IsEmpty()) { |
| 65 info.pending_transactions.pop_front(); | 65 info.pending_transactions.pop_front(); |
| 66 info.active_write_transaction = first_pending_transaction; | 66 info.active_write_transaction = first_pending_transaction; |
| 67 first_pending_transaction->LockAcquired(); | 67 first_pending_transaction->LockAcquired(); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SQLTransactionCoordinator::AcquireLock( | 71 void SQLTransactionCoordinator::AcquireLock( |
| 72 SQLTransactionBackend* transaction) { | 72 SQLTransactionBackend* transaction) { |
| 73 ASSERT(!is_shutting_down_); | 73 DCHECK(!is_shutting_down_); |
| 74 | 74 |
| 75 String db_identifier = GetDatabaseIdentifier(transaction); | 75 String db_identifier = GetDatabaseIdentifier(transaction); |
| 76 | 76 |
| 77 CoordinationInfoHeapMap::iterator coordination_info_iterator = | 77 CoordinationInfoHeapMap::iterator coordination_info_iterator = |
| 78 coordination_info_map_.Find(db_identifier); | 78 coordination_info_map_.Find(db_identifier); |
| 79 if (coordination_info_iterator == coordination_info_map_.end()) { | 79 if (coordination_info_iterator == coordination_info_map_.end()) { |
| 80 // No pending transactions for this DB | 80 // No pending transactions for this DB |
| 81 CoordinationInfo& info = | 81 CoordinationInfo& info = |
| 82 coordination_info_map_.insert(db_identifier, CoordinationInfo()) | 82 coordination_info_map_.insert(db_identifier, CoordinationInfo()) |
| 83 .stored_value->value; | 83 .stored_value->value; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 96 return; | 96 return; |
| 97 | 97 |
| 98 String db_identifier = GetDatabaseIdentifier(transaction); | 98 String db_identifier = GetDatabaseIdentifier(transaction); |
| 99 | 99 |
| 100 CoordinationInfoHeapMap::iterator coordination_info_iterator = | 100 CoordinationInfoHeapMap::iterator coordination_info_iterator = |
| 101 coordination_info_map_.Find(db_identifier); | 101 coordination_info_map_.Find(db_identifier); |
| 102 SECURITY_DCHECK(coordination_info_iterator != coordination_info_map_.end()); | 102 SECURITY_DCHECK(coordination_info_iterator != coordination_info_map_.end()); |
| 103 CoordinationInfo& info = coordination_info_iterator->value; | 103 CoordinationInfo& info = coordination_info_iterator->value; |
| 104 | 104 |
| 105 if (transaction->IsReadOnly()) { | 105 if (transaction->IsReadOnly()) { |
| 106 ASSERT(info.active_read_transactions.Contains(transaction)); | 106 DCHECK(info.active_read_transactions.Contains(transaction)); |
| 107 info.active_read_transactions.erase(transaction); | 107 info.active_read_transactions.erase(transaction); |
| 108 } else { | 108 } else { |
| 109 ASSERT(info.active_write_transaction == transaction); | 109 DCHECK_EQ(info.active_write_transaction, transaction); |
| 110 info.active_write_transaction = nullptr; | 110 info.active_write_transaction = nullptr; |
| 111 } | 111 } |
| 112 | 112 |
| 113 ProcessPendingTransactions(info); | 113 ProcessPendingTransactions(info); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void SQLTransactionCoordinator::Shutdown() { | 116 void SQLTransactionCoordinator::Shutdown() { |
| 117 // Prevent releaseLock() from accessing / changing the coordinationInfo | 117 // Prevent releaseLock() from accessing / changing the coordinationInfo |
| 118 // while we're shutting down. | 118 // while we're shutting down. |
| 119 is_shutting_down_ = true; | 119 is_shutting_down_ = true; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 143 info.pending_transactions.TakeFirst(); | 143 info.pending_transactions.TakeFirst(); |
| 144 transaction->NotifyDatabaseThreadIsShuttingDown(); | 144 transaction->NotifyDatabaseThreadIsShuttingDown(); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 // Clean up all pending transactions for all databases | 148 // Clean up all pending transactions for all databases |
| 149 coordination_info_map_.Clear(); | 149 coordination_info_map_.Clear(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace blink | 152 } // namespace blink |
| OLD | NEW |