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

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

Issue 2746333002: DevTools: move recurring flag into AsyncTask, control cancelation from embedder only. (Closed)
Patch Set: using _END now Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/WebIDBCallbacksImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 SQLTransactionErrorCallback* errorCallback, 65 SQLTransactionErrorCallback* errorCallback,
66 bool readOnly) 66 bool readOnly)
67 : m_database(db), 67 : m_database(db),
68 m_callback(callback), 68 m_callback(callback),
69 m_successCallback(successCallback), 69 m_successCallback(successCallback),
70 m_errorCallback(errorCallback), 70 m_errorCallback(errorCallback),
71 m_executeSqlAllowed(false), 71 m_executeSqlAllowed(false),
72 m_readOnly(readOnly) { 72 m_readOnly(readOnly) {
73 DCHECK(isMainThread()); 73 DCHECK(isMainThread());
74 ASSERT(m_database); 74 ASSERT(m_database);
75 probe::asyncTaskScheduled(db->getExecutionContext(), "SQLTransaction", this, 75 probe::asyncTaskScheduled(db->getExecutionContext(), "SQLTransaction", this);
76 true);
77 } 76 }
78 77
79 SQLTransaction::~SQLTransaction() {} 78 SQLTransaction::~SQLTransaction() {}
80 79
81 DEFINE_TRACE(SQLTransaction) { 80 DEFINE_TRACE(SQLTransaction) {
82 visitor->trace(m_database); 81 visitor->trace(m_database);
83 visitor->trace(m_backend); 82 visitor->trace(m_backend);
84 visitor->trace(m_callback); 83 visitor->trace(m_callback);
85 visitor->trace(m_successCallback); 84 visitor->trace(m_successCallback);
86 visitor->trace(m_errorCallback); 85 visitor->trace(m_errorCallback);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (hasErrorCallback()) 145 if (hasErrorCallback())
147 return SQLTransactionState::DeliverTransactionErrorCallback; 146 return SQLTransactionState::DeliverTransactionErrorCallback;
148 147
149 // No error callback, so fast-forward to: 148 // No error callback, so fast-forward to:
150 // Transaction Step 11 - Rollback the transaction. 149 // Transaction Step 11 - Rollback the transaction.
151 return SQLTransactionState::CleanupAfterTransactionErrorCallback; 150 return SQLTransactionState::CleanupAfterTransactionErrorCallback;
152 } 151 }
153 152
154 SQLTransactionState SQLTransaction::deliverTransactionCallback() { 153 SQLTransactionState SQLTransaction::deliverTransactionCallback() {
155 bool shouldDeliverErrorCallback = false; 154 bool shouldDeliverErrorCallback = false;
156 probe::AsyncTask asyncTask(m_database->getExecutionContext(), this); 155 probe::AsyncTask asyncTask(m_database->getExecutionContext(), this,
156 "transaction");
157 157
158 // Spec 4.3.2 4: Invoke the transaction callback with the new SQLTransaction 158 // Spec 4.3.2 4: Invoke the transaction callback with the new SQLTransaction
159 // object. 159 // object.
160 if (SQLTransactionCallback* callback = m_callback.release()) { 160 if (SQLTransactionCallback* callback = m_callback.release()) {
161 m_executeSqlAllowed = true; 161 m_executeSqlAllowed = true;
162 shouldDeliverErrorCallback = !callback->handleEvent(this); 162 shouldDeliverErrorCallback = !callback->handleEvent(this);
163 m_executeSqlAllowed = false; 163 m_executeSqlAllowed = false;
164 } 164 }
165 165
166 // Spec 4.3.2 5: If the transaction callback was null or raised an exception, 166 // Spec 4.3.2 5: If the transaction callback was null or raised an exception,
167 // jump to the error callback. 167 // jump to the error callback.
168 SQLTransactionState nextState = SQLTransactionState::RunStatements; 168 SQLTransactionState nextState = SQLTransactionState::RunStatements;
169 if (shouldDeliverErrorCallback) { 169 if (shouldDeliverErrorCallback) {
170 m_database->reportStartTransactionResult(5, SQLError::kUnknownErr, 0); 170 m_database->reportStartTransactionResult(5, SQLError::kUnknownErr, 0);
171 m_transactionError = SQLErrorData::create( 171 m_transactionError = SQLErrorData::create(
172 SQLError::kUnknownErr, 172 SQLError::kUnknownErr,
173 "the SQLTransactionCallback was null or threw an exception"); 173 "the SQLTransactionCallback was null or threw an exception");
174 nextState = SQLTransactionState::DeliverTransactionErrorCallback; 174 nextState = SQLTransactionState::DeliverTransactionErrorCallback;
175 } 175 }
176 m_database->reportStartTransactionResult(0, -1, 0); // OK 176 m_database->reportStartTransactionResult(0, -1, 0); // OK
177 return nextState; 177 return nextState;
178 } 178 }
179 179
180 SQLTransactionState SQLTransaction::deliverTransactionErrorCallback() { 180 SQLTransactionState SQLTransaction::deliverTransactionErrorCallback() {
181 probe::AsyncTask asyncTask(m_database->getExecutionContext(), this); 181 probe::AsyncTask asyncTask(m_database->getExecutionContext(), this);
182 probe::asyncTaskCanceled(m_database->getExecutionContext(), this);
183 182
184 // Spec 4.3.2.10: If exists, invoke error callback with the last 183 // Spec 4.3.2.10: If exists, invoke error callback with the last
185 // error to have occurred in this transaction. 184 // error to have occurred in this transaction.
186 if (SQLTransactionErrorCallback* errorCallback = m_errorCallback.release()) { 185 if (SQLTransactionErrorCallback* errorCallback = m_errorCallback.release()) {
187 // If we get here with an empty m_transactionError, then the backend 186 // If we get here with an empty m_transactionError, then the backend
188 // must be waiting in the idle state waiting for this state to finish. 187 // must be waiting in the idle state waiting for this state to finish.
189 // Hence, it's thread safe to fetch the backend transactionError without 188 // Hence, it's thread safe to fetch the backend transactionError without
190 // a lock. 189 // a lock.
191 if (!m_transactionError) { 190 if (!m_transactionError) {
192 ASSERT(m_backend->transactionError()); 191 ASSERT(m_backend->transactionError());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 bool shouldRetryCurrentStatement = 235 bool shouldRetryCurrentStatement =
237 m_database->transactionClient()->didExceedQuota(database()); 236 m_database->transactionClient()->didExceedQuota(database());
238 m_backend->setShouldRetryCurrentStatement(shouldRetryCurrentStatement); 237 m_backend->setShouldRetryCurrentStatement(shouldRetryCurrentStatement);
239 238
240 return SQLTransactionState::RunStatements; 239 return SQLTransactionState::RunStatements;
241 } 240 }
242 241
243 SQLTransactionState SQLTransaction::deliverSuccessCallback() { 242 SQLTransactionState SQLTransaction::deliverSuccessCallback() {
244 DCHECK(isMainThread()); 243 DCHECK(isMainThread());
245 probe::AsyncTask asyncTask(m_database->getExecutionContext(), this); 244 probe::AsyncTask asyncTask(m_database->getExecutionContext(), this);
246 probe::asyncTaskCanceled(m_database->getExecutionContext(), this);
247 245
248 // Spec 4.3.2.8: Deliver success callback. 246 // Spec 4.3.2.8: Deliver success callback.
249 if (VoidCallback* successCallback = m_successCallback.release()) 247 if (VoidCallback* successCallback = m_successCallback.release())
250 successCallback->handleEvent(); 248 successCallback->handleEvent();
251 249
252 clearCallbacks(); 250 clearCallbacks();
253 251
254 // Schedule a "post-success callback" step to return control to the database 252 // Schedule a "post-success callback" step to return control to the database
255 // thread in case there are further transactions queued up for this Database. 253 // thread in case there are further transactions queued up for this Database.
256 return SQLTransactionState::CleanupAndTerminate; 254 return SQLTransactionState::CleanupAndTerminate;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 m_callback.clear(); 351 m_callback.clear();
354 m_successCallback.clear(); 352 m_successCallback.clear();
355 m_errorCallback.clear(); 353 m_errorCallback.clear();
356 } 354 }
357 355
358 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() { 356 SQLTransactionErrorCallback* SQLTransaction::releaseErrorCallback() {
359 return m_errorCallback.release(); 357 return m_errorCallback.release();
360 } 358 }
361 359
362 } // namespace blink 360 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/indexeddb/WebIDBCallbacksImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698