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

Side by Side Diff: Source/modules/webdatabase/SQLTransactionBackendSync.cpp

Issue 198793003: Oilpan: Prepare to move SQLTransactionBackendSync and SQLTransactionSync to Oilpan heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: DatabaseSync owns observers. Created 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 : m_database(db) 55 : m_database(db)
56 , m_callback(callback) 56 , m_callback(callback)
57 , m_readOnly(readOnly) 57 , m_readOnly(readOnly)
58 , m_hasVersionMismatch(false) 58 , m_hasVersionMismatch(false)
59 , m_modifiedDatabase(false) 59 , m_modifiedDatabase(false)
60 , m_transactionClient(adoptPtr(new SQLTransactionClient())) 60 , m_transactionClient(adoptPtr(new SQLTransactionClient()))
61 { 61 {
62 ASSERT(m_database->executionContext()->isContextThread()); 62 ASSERT(m_database->executionContext()->isContextThread());
63 } 63 }
64 64
65 void SQLTransactionBackendSync::rollbackIfInProgress()
66 {
67 ASSERT(!m_database->executionContext() || m_database->executionContext()->is ContextThread());
68 if (m_sqliteTransaction && m_sqliteTransaction->inProgress())
69 rollback();
70 }
71
65 SQLTransactionBackendSync::~SQLTransactionBackendSync() 72 SQLTransactionBackendSync::~SQLTransactionBackendSync()
66 { 73 {
67 ASSERT(m_database->executionContext()->isContextThread()); 74 #if ENABLE(OILPAN)
68 if (m_sqliteTransaction && m_sqliteTransaction->inProgress()) 75 ASSERT(!m_sqliteTransaction || !m_sqliteTransaction->inProgress());
69 rollback(); 76 #else
77 rollbackIfInProgress();
78 #endif
79 }
80
81 void SQLTransactionBackendSync::trace(Visitor* visitor)
82 {
83 visitor->trace(m_database);
70 } 84 }
71 85
72 PassRefPtr<SQLResultSet> SQLTransactionBackendSync::executeSQL(const String& sql Statement, const Vector<SQLValue>& arguments, ExceptionState& exceptionState) 86 PassRefPtr<SQLResultSet> SQLTransactionBackendSync::executeSQL(const String& sql Statement, const Vector<SQLValue>& arguments, ExceptionState& exceptionState)
73 { 87 {
74 ASSERT(m_database->executionContext()->isContextThread()); 88 ASSERT(m_database->executionContext()->isContextThread());
75 89
76 m_database->setLastErrorMessage(""); 90 m_database->setLastErrorMessage("");
77 91
78 if (!m_database->opened()) { 92 if (!m_database->opened()) {
79 m_database->setLastErrorMessage("cannot executeSQL because the database is not open"); 93 m_database->setLastErrorMessage("cannot executeSQL because the database is not open");
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (m_database->hadDeletes()) 236 if (m_database->hadDeletes())
223 m_database->incrementalVacuumIfNeeded(); 237 m_database->incrementalVacuumIfNeeded();
224 238
225 // The commit was successful. If the transaction modified this database, not ify the delegates. 239 // The commit was successful. If the transaction modified this database, not ify the delegates.
226 if (m_modifiedDatabase) 240 if (m_modifiedDatabase)
227 m_transactionClient->didCommitWriteTransaction(database()); 241 m_transactionClient->didCommitWriteTransaction(database());
228 242
229 m_database->reportCommitTransactionResult(0, -1, 0); // OK 243 m_database->reportCommitTransactionResult(0, -1, 0); // OK
230 } 244 }
231 245
246 // This can be called during GC. Do not allocate new on-heap objects.
Vyacheslav Egorov (Google) 2014/03/18 07:54:55 I don't think comments like this scale as long you
232 void SQLTransactionBackendSync::rollback() 247 void SQLTransactionBackendSync::rollback()
233 { 248 {
234 ASSERT(m_database->executionContext()->isContextThread()); 249 ASSERT(!m_database->executionContext() || m_database->executionContext()->is ContextThread());
235 m_database->disableAuthorizer(); 250 m_database->disableAuthorizer();
236 if (m_sqliteTransaction) { 251 if (m_sqliteTransaction) {
Vyacheslav Egorov (Google) 2014/03/18 07:54:55 from my reading of the code this whole if can be j
237 m_sqliteTransaction->rollback(); 252 m_sqliteTransaction->rollback();
238 m_sqliteTransaction.clear(); 253 m_sqliteTransaction.clear();
239 } 254 }
240 m_database->enableAuthorizer(); 255 m_database->enableAuthorizer();
241 256
242 ASSERT(!m_database->sqliteDatabase().transactionInProgress()); 257 ASSERT(!m_database->sqliteDatabase().transactionInProgress());
243 } 258 }
244 259
245 } // namespace WebCore 260 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698