OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) | 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) |
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 | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // FULL - Any writing calls to the DB block until the data is actually on th
e disk surface | 90 // FULL - Any writing calls to the DB block until the data is actually on th
e disk surface |
91 // NORMAL - SQLite pauses at some critical moments when writing, but much le
ss than FULL | 91 // NORMAL - SQLite pauses at some critical moments when writing, but much le
ss than FULL |
92 // OFF - Calls return immediately after the data has been passed to disk | 92 // OFF - Calls return immediately after the data has been passed to disk |
93 enum SynchronousPragma { SyncOff = 0, SyncNormal = 1, SyncFull = 2 }; | 93 enum SynchronousPragma { SyncOff = 0, SyncNormal = 1, SyncFull = 2 }; |
94 void setSynchronous(SynchronousPragma); | 94 void setSynchronous(SynchronousPragma); |
95 | 95 |
96 int lastError(); | 96 int lastError(); |
97 const char* lastErrorMsg(); | 97 const char* lastErrorMsg(); |
98 | 98 |
99 sqlite3* sqlite3Handle() const { | 99 sqlite3* sqlite3Handle() const { |
100 ASSERT(currentThread() == m_openingThread); | 100 ASSERT(m_sharable || currentThread() == m_openingThread); |
101 return m_db; | 101 return m_db; |
102 } | 102 } |
103 | 103 |
104 void setAuthorizer(PassRefPtr<DatabaseAuthorizer>); | 104 void setAuthorizer(PassRefPtr<DatabaseAuthorizer>); |
105 | 105 |
106 // (un)locks the database like a mutex | 106 // (un)locks the database like a mutex |
107 void lock(); | 107 void lock(); |
108 void unlock(); | 108 void unlock(); |
109 bool isAutoCommitOn() const; | 109 bool isAutoCommitOn() const; |
110 | 110 |
| 111 // Set this flag to allow access from multiple threads. Not all multi-threa
ded accesses are safe! |
| 112 // See http://www.sqlite.org/cvstrac/wiki?p=MultiThreading for more info, an
d you must be running with compile flags and SQLite version appropriate |
| 113 // to your cross-thread uses. |
| 114 bool sharable() { return m_sharable; } |
| 115 void setSharable(bool sharable) { m_sharable = sharable; } |
| 116 |
111 private: | 117 private: |
112 static int authorizerFunction(void*, int, const char*, const char*, const ch
ar*, const char*); | 118 static int authorizerFunction(void*, int, const char*, const char*, const ch
ar*, const char*); |
113 | 119 |
114 void enableAuthorizer(bool enable); | 120 void enableAuthorizer(bool enable); |
115 | 121 |
116 int pageSize(); | 122 int pageSize(); |
117 | 123 |
118 sqlite3* m_db; | 124 sqlite3* m_db; |
119 int m_lastError; | 125 int m_lastError; |
120 int m_pageSize; | 126 int m_pageSize; |
121 | 127 |
122 bool m_transactionInProgress; | 128 bool m_transactionInProgress; |
| 129 bool m_sharable; |
123 | 130 |
124 Mutex m_authorizerLock; | 131 Mutex m_authorizerLock; |
125 RefPtr<DatabaseAuthorizer> m_authorizer; | 132 RefPtr<DatabaseAuthorizer> m_authorizer; |
126 | 133 |
127 Mutex m_lockingMutex; | 134 Mutex m_lockingMutex; |
128 ThreadIdentifier m_openingThread; | 135 ThreadIdentifier m_openingThread; |
129 | 136 |
130 }; // class SQLiteDatabase | 137 }; // class SQLiteDatabase |
131 | 138 |
132 } // namespace WebCore | 139 } // namespace WebCore |
133 | 140 |
134 #endif | 141 #endif |
OLD | NEW |