OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 void SQLiteTransaction::commit() { | 58 void SQLiteTransaction::commit() { |
59 if (m_inProgress) { | 59 if (m_inProgress) { |
60 ASSERT(m_db.m_transactionInProgress); | 60 ASSERT(m_db.m_transactionInProgress); |
61 m_inProgress = !m_db.executeCommand("COMMIT"); | 61 m_inProgress = !m_db.executeCommand("COMMIT"); |
62 m_db.m_transactionInProgress = m_inProgress; | 62 m_db.m_transactionInProgress = m_inProgress; |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 void SQLiteTransaction::rollback() { | 66 void SQLiteTransaction::rollback() { |
67 // We do not use the 'm_inProgress = m_db.executeCommand("ROLLBACK")' construc
t here, | 67 // We do not use the 'm_inProgress = m_db.executeCommand("ROLLBACK")' |
68 // because m_inProgress should always be set to false after a ROLLBACK, and | 68 // construct here, because m_inProgress should always be set to false after a |
69 // m_db.executeCommand("ROLLBACK") can sometimes harmlessly fail, thus returni
ng | 69 // ROLLBACK, and m_db.executeCommand("ROLLBACK") can sometimes harmlessly |
70 // a non-zero/true result (http://www.sqlite.org/lang_transaction.html). | 70 // fail, thus returning a non-zero/true result |
| 71 // (http://www.sqlite.org/lang_transaction.html). |
71 if (m_inProgress) { | 72 if (m_inProgress) { |
72 ASSERT(m_db.m_transactionInProgress); | 73 ASSERT(m_db.m_transactionInProgress); |
73 m_db.executeCommand("ROLLBACK"); | 74 m_db.executeCommand("ROLLBACK"); |
74 m_inProgress = false; | 75 m_inProgress = false; |
75 m_db.m_transactionInProgress = false; | 76 m_db.m_transactionInProgress = false; |
76 } | 77 } |
77 } | 78 } |
78 | 79 |
79 void SQLiteTransaction::stop() { | 80 void SQLiteTransaction::stop() { |
80 if (m_inProgress) { | 81 if (m_inProgress) { |
81 m_inProgress = false; | 82 m_inProgress = false; |
82 m_db.m_transactionInProgress = false; | 83 m_db.m_transactionInProgress = false; |
83 } | 84 } |
84 } | 85 } |
85 | 86 |
86 bool SQLiteTransaction::wasRolledBackBySqlite() const { | 87 bool SQLiteTransaction::wasRolledBackBySqlite() const { |
87 // According to http://www.sqlite.org/c3ref/get_autocommit.html, | 88 // According to http://www.sqlite.org/c3ref/get_autocommit.html, |
88 // the auto-commit flag should be off in the middle of a transaction | 89 // the auto-commit flag should be off in the middle of a transaction |
89 return m_inProgress && m_db.isAutoCommitOn(); | 90 return m_inProgress && m_db.isAutoCommitOn(); |
90 } | 91 } |
91 | 92 |
92 } // namespace blink | 93 } // namespace blink |
OLD | NEW |