Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(812)

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/SQLTransaction.cpp

Issue 1909813002: Enable per thread heap for database thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 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 * 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 17 matching lines...) Expand all
28 28
29 #include "modules/webdatabase/SQLTransaction.h" 29 #include "modules/webdatabase/SQLTransaction.h"
30 30
31 #include "bindings/core/v8/ExceptionState.h" 31 #include "bindings/core/v8/ExceptionState.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "core/html/VoidCallback.h" 33 #include "core/html/VoidCallback.h"
34 #include "core/inspector/InspectorInstrumentation.h" 34 #include "core/inspector/InspectorInstrumentation.h"
35 #include "modules/webdatabase/Database.h" 35 #include "modules/webdatabase/Database.h"
36 #include "modules/webdatabase/DatabaseAuthorizer.h" 36 #include "modules/webdatabase/DatabaseAuthorizer.h"
37 #include "modules/webdatabase/DatabaseContext.h" 37 #include "modules/webdatabase/DatabaseContext.h"
38 #include "modules/webdatabase/DatabaseThread.h"
38 #include "modules/webdatabase/SQLError.h" 39 #include "modules/webdatabase/SQLError.h"
39 #include "modules/webdatabase/SQLStatementCallback.h" 40 #include "modules/webdatabase/SQLStatementCallback.h"
40 #include "modules/webdatabase/SQLStatementErrorCallback.h" 41 #include "modules/webdatabase/SQLStatementErrorCallback.h"
41 #include "modules/webdatabase/SQLTransactionBackend.h" 42 #include "modules/webdatabase/SQLTransactionBackend.h"
42 #include "modules/webdatabase/SQLTransactionCallback.h" 43 #include "modules/webdatabase/SQLTransactionCallback.h"
43 #include "modules/webdatabase/SQLTransactionClient.h" // FIXME: Should be used i n the backend only. 44 #include "modules/webdatabase/SQLTransactionClient.h" // FIXME: Should be used i n the backend only.
44 #include "modules/webdatabase/SQLTransactionErrorCallback.h" 45 #include "modules/webdatabase/SQLTransactionErrorCallback.h"
45 #include "platform/Logging.h" 46 #include "platform/Logging.h"
46 #include "wtf/StdLibExtras.h" 47 #include "wtf/StdLibExtras.h"
47 #include "wtf/Vector.h" 48 #include "wtf/Vector.h"
48 49
49 namespace blink { 50 namespace blink {
50 51
51 SQLTransaction* SQLTransaction::create(Database* db, SQLTransactionCallback* cal lback, 52 SQLTransaction* SQLTransaction::create(Database* db, SQLTransactionCallback* cal lback,
52 VoidCallback* successCallback, SQLTransactionErrorCallback* errorCallback, b ool readOnly) 53 VoidCallback* successCallback, SQLTransactionErrorCallback* errorCallback, b ool readOnly)
53 { 54 {
54 return new SQLTransaction(db, callback, successCallback, errorCallback, read Only); 55 return new SQLTransaction(db, callback, successCallback, errorCallback, read Only);
55 } 56 }
56 57
57 SQLTransaction::SQLTransaction(Database* db, SQLTransactionCallback* callback, 58 SQLTransaction::SQLTransaction(Database* db, SQLTransactionCallback* callback,
58 VoidCallback* successCallback, SQLTransactionErrorCallback* errorCallback, 59 VoidCallback* successCallback, SQLTransactionErrorCallback* errorCallback,
59 bool readOnly) 60 bool readOnly)
60 : m_database(db) 61 : m_database(db)
61 , m_callback(callback) 62 , m_callback(callback)
62 , m_successCallback(successCallback) 63 , m_successCallback(successCallback)
63 , m_errorCallback(errorCallback) 64 , m_errorCallback(errorCallback)
64 , m_executeSqlAllowed(false) 65 , m_executeSqlAllowed(false)
65 , m_readOnly(readOnly) 66 , m_readOnly(readOnly)
66 { 67 {
68 DCHECK(isMainThread());
67 ASSERT(m_database); 69 ASSERT(m_database);
68 InspectorInstrumentation::asyncTaskScheduled(db->getExecutionContext(), "SQL Transaction", this, true); 70 InspectorInstrumentation::asyncTaskScheduled(db->getExecutionContext(), "SQL Transaction", this, true);
69 } 71 }
70 72
71 SQLTransaction::~SQLTransaction() 73 SQLTransaction::~SQLTransaction()
72 { 74 {
73 } 75 }
74 76
75 DEFINE_TRACE(SQLTransaction) 77 DEFINE_TRACE(SQLTransaction)
76 { 78 {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 195 }
194 196
195 clearCallbacks(); 197 clearCallbacks();
196 198
197 // Spec 4.3.2.10: Rollback the transaction. 199 // Spec 4.3.2.10: Rollback the transaction.
198 return SQLTransactionState::CleanupAfterTransactionErrorCallback; 200 return SQLTransactionState::CleanupAfterTransactionErrorCallback;
199 } 201 }
200 202
201 SQLTransactionState SQLTransaction::deliverStatementCallback() 203 SQLTransactionState SQLTransaction::deliverStatementCallback()
202 { 204 {
205 DCHECK(isMainThread());
203 // Spec 4.3.2.6.6 and 4.3.2.6.3: If the statement callback went wrong, jump to the transaction error callback 206 // Spec 4.3.2.6.6 and 4.3.2.6.3: If the statement callback went wrong, jump to the transaction error callback
204 // Otherwise, continue to loop through the statement queue 207 // Otherwise, continue to loop through the statement queue
205 m_executeSqlAllowed = true; 208 m_executeSqlAllowed = true;
206 209
207 SQLStatement* currentStatement = m_backend->currentStatement(); 210 SQLStatement* currentStatement = m_backend->currentStatement();
208 ASSERT(currentStatement); 211 ASSERT(currentStatement);
209 212
210 bool result = currentStatement->performCallback(this); 213 bool result = currentStatement->performCallback(this);
211 214
212 m_executeSqlAllowed = false; 215 m_executeSqlAllowed = false;
213 216
214 if (result) { 217 if (result) {
215 m_database->reportCommitTransactionResult(2, SQLError::UNKNOWN_ERR, 0); 218 m_database->reportCommitTransactionResult(2, SQLError::UNKNOWN_ERR, 0);
216 m_transactionError = SQLErrorData::create(SQLError::UNKNOWN_ERR, "the st atement callback raised an exception or statement error callback did not return false"); 219 m_transactionError = SQLErrorData::create(SQLError::UNKNOWN_ERR, "the st atement callback raised an exception or statement error callback did not return false");
217 return nextStateForTransactionError(); 220 return nextStateForTransactionError();
218 } 221 }
219 return SQLTransactionState::RunStatements; 222 return SQLTransactionState::RunStatements;
220 } 223 }
221 224
222 SQLTransactionState SQLTransaction::deliverQuotaIncreaseCallback() 225 SQLTransactionState SQLTransaction::deliverQuotaIncreaseCallback()
223 { 226 {
227 DCHECK(isMainThread());
224 ASSERT(m_backend->currentStatement()); 228 ASSERT(m_backend->currentStatement());
225 229
226 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee dQuota(database()); 230 bool shouldRetryCurrentStatement = m_database->transactionClient()->didExcee dQuota(database());
227 m_backend->setShouldRetryCurrentStatement(shouldRetryCurrentStatement); 231 m_backend->setShouldRetryCurrentStatement(shouldRetryCurrentStatement);
228 232
229 return SQLTransactionState::RunStatements; 233 return SQLTransactionState::RunStatements;
230 } 234 }
231 235
232 SQLTransactionState SQLTransaction::deliverSuccessCallback() 236 SQLTransactionState SQLTransaction::deliverSuccessCallback()
233 { 237 {
238 DCHECK(isMainThread());
234 InspectorInstrumentation::AsyncTask asyncTask(m_database->getExecutionContex t(), this); 239 InspectorInstrumentation::AsyncTask asyncTask(m_database->getExecutionContex t(), this);
235 InspectorInstrumentation::asyncTaskCanceled(m_database->getExecutionContext( ), this); 240 InspectorInstrumentation::asyncTaskCanceled(m_database->getExecutionContext( ), this);
236 241
237 // Spec 4.3.2.8: Deliver success callback. 242 // Spec 4.3.2.8: Deliver success callback.
238 if (VoidCallback* successCallback = m_successCallback.release()) 243 if (VoidCallback* successCallback = m_successCallback.release())
239 successCallback->handleEvent(); 244 successCallback->handleEvent();
240 245
241 clearCallbacks(); 246 clearCallbacks();
242 247
243 // Schedule a "post-success callback" step to return control to the database thread in case there 248 // Schedule a "post-success callback" step to return control to the database thread in case there
(...skipping 12 matching lines...) Expand all
256 261
257 SQLTransactionState SQLTransaction::sendToBackendState() 262 SQLTransactionState SQLTransaction::sendToBackendState()
258 { 263 {
259 ASSERT(m_nextState != SQLTransactionState::Idle); 264 ASSERT(m_nextState != SQLTransactionState::Idle);
260 m_backend->requestTransitToState(m_nextState); 265 m_backend->requestTransitToState(m_nextState);
261 return SQLTransactionState::Idle; 266 return SQLTransactionState::Idle;
262 } 267 }
263 268
264 void SQLTransaction::performPendingCallback() 269 void SQLTransaction::performPendingCallback()
265 { 270 {
271 DCHECK(isMainThread());
266 computeNextStateAndCleanupIfNeeded(); 272 computeNextStateAndCleanupIfNeeded();
267 runStateMachine(); 273 runStateMachine();
268 } 274 }
269 275
270 void SQLTransaction::executeSQL(const String& sqlStatement, const Vector<SQLValu e>& arguments, SQLStatementCallback* callback, SQLStatementErrorCallback* callba ckError, ExceptionState& exceptionState) 276 void SQLTransaction::executeSQL(const String& sqlStatement, const Vector<SQLValu e>& arguments, SQLStatementCallback* callback, SQLStatementErrorCallback* callba ckError, ExceptionState& exceptionState)
271 { 277 {
278 DCHECK(isMainThread());
272 if (!m_executeSqlAllowed) { 279 if (!m_executeSqlAllowed) {
273 exceptionState.throwDOMException(InvalidStateError, "SQL execution is di sallowed."); 280 exceptionState.throwDOMException(InvalidStateError, "SQL execution is di sallowed.");
274 return; 281 return;
275 } 282 }
276 283
277 if (!m_database->opened()) { 284 if (!m_database->opened()) {
278 exceptionState.throwDOMException(InvalidStateError, "The database has no t been opened."); 285 exceptionState.throwDOMException(InvalidStateError, "The database has no t been opened.");
279 return; 286 return;
280 } 287 }
281 288
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 m_successCallback.clear(); 338 m_successCallback.clear();
332 m_errorCallback.clear(); 339 m_errorCallback.clear();
333 } 340 }
334 341
335 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() 342 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback()
336 { 343 {
337 return m_errorCallback.release(); 344 return m_errorCallback.release();
338 } 345 }
339 346
340 } // namespace blink 347 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698