| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 : next_state_(SQLTransactionState::kIdle), | 68 : next_state_(SQLTransactionState::kIdle), |
| 69 requested_state_(SQLTransactionState::kIdle) { | 69 requested_state_(SQLTransactionState::kIdle) { |
| 70 #if DCHECK_IS_ON() | 70 #if DCHECK_IS_ON() |
| 71 for (int i = 0; i < kSizeOfStateAuditTrail; i++) | 71 for (int i = 0; i < kSizeOfStateAuditTrail; i++) |
| 72 state_audit_trail_[i] = SQLTransactionState::kNumberOfStates; | 72 state_audit_trail_[i] = SQLTransactionState::kNumberOfStates; |
| 73 #endif | 73 #endif |
| 74 } | 74 } |
| 75 | 75 |
| 76 template <typename T> | 76 template <typename T> |
| 77 void SQLTransactionStateMachine<T>::SetStateToRequestedState() { | 77 void SQLTransactionStateMachine<T>::SetStateToRequestedState() { |
| 78 ASSERT(next_state_ == SQLTransactionState::kIdle); | 78 DCHECK_EQ(next_state_, SQLTransactionState::kIdle); |
| 79 ASSERT(requested_state_ != SQLTransactionState::kIdle); | 79 DCHECK_NE(requested_state_, SQLTransactionState::kIdle); |
| 80 next_state_ = requested_state_; | 80 next_state_ = requested_state_; |
| 81 requested_state_ = SQLTransactionState::kIdle; | 81 requested_state_ = SQLTransactionState::kIdle; |
| 82 } | 82 } |
| 83 | 83 |
| 84 template <typename T> | 84 template <typename T> |
| 85 void SQLTransactionStateMachine<T>::RunStateMachine() { | 85 void SQLTransactionStateMachine<T>::RunStateMachine() { |
| 86 ASSERT(SQLTransactionState::kEnd < SQLTransactionState::kIdle); | 86 DCHECK_LT(SQLTransactionState::kEnd, SQLTransactionState::kIdle); |
| 87 while (next_state_ > SQLTransactionState::kIdle) { | 87 while (next_state_ > SQLTransactionState::kIdle) { |
| 88 ASSERT(next_state_ < SQLTransactionState::kNumberOfStates); | 88 DCHECK_LT(next_state_, SQLTransactionState::kNumberOfStates); |
| 89 StateFunction state_function = StateFunctionFor(next_state_); | 89 StateFunction state_function = StateFunctionFor(next_state_); |
| 90 ASSERT(state_function); | 90 DCHECK(state_function); |
| 91 | 91 |
| 92 #if DCHECK_IS_ON() | 92 #if DCHECK_IS_ON() |
| 93 state_audit_trail_[next_state_audit_entry_] = next_state_; | 93 state_audit_trail_[next_state_audit_entry_] = next_state_; |
| 94 next_state_audit_entry_ = | 94 next_state_audit_entry_ = |
| 95 (next_state_audit_entry_ + 1) % kSizeOfStateAuditTrail; | 95 (next_state_audit_entry_ + 1) % kSizeOfStateAuditTrail; |
| 96 #endif | 96 #endif |
| 97 next_state_ = (static_cast<T*>(this)->*state_function)(); | 97 next_state_ = (static_cast<T*>(this)->*state_function)(); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace blink | 101 } // namespace blink |
| 102 | 102 |
| 103 #endif // SQLTransactionStateMachine_h | 103 #endif // SQLTransactionStateMachine_h |
| OLD | NEW |