| OLD | NEW |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 : m_transactionClient(adoptPtr(new SQLTransactionClient())) | 44 : m_transactionClient(adoptPtr(new SQLTransactionClient())) |
| 45 , m_transactionCoordinator(adoptPtrWillBeNoop(new SQLTransactionCoordinator(
))) | 45 , m_transactionCoordinator(adoptPtrWillBeNoop(new SQLTransactionCoordinator(
))) |
| 46 , m_cleanupSync(0) | 46 , m_cleanupSync(0) |
| 47 , m_terminationRequested(false) | 47 , m_terminationRequested(false) |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 DatabaseThread::~DatabaseThread() | 51 DatabaseThread::~DatabaseThread() |
| 52 { | 52 { |
| 53 ASSERT(m_openDatabaseSet.isEmpty()); | 53 ASSERT(m_openDatabaseSet.isEmpty()); |
| 54 // Oilpan: The database thread must have finished its cleanup tasks before | 54 ASSERT(!m_thread); |
| 55 // the following clear(). Otherwise, WebThread destructor blocks the caller | |
| 56 // thread, and causes a deadlock with ThreadState cleanup. | |
| 57 // DatabaseContext::stop() asks the database thread to close all of | |
| 58 // databases, and wait until GC heap cleanup of the database thread. So we | |
| 59 // can safely destruct WebThread here. | |
| 60 m_thread.clear(); | |
| 61 } | 55 } |
| 62 | 56 |
| 63 void DatabaseThread::trace(Visitor* visitor) | 57 void DatabaseThread::trace(Visitor* visitor) |
| 64 { | 58 { |
| 65 #if ENABLE(OILPAN) | 59 #if ENABLE(OILPAN) |
| 66 visitor->trace(m_openDatabaseSet); | 60 visitor->trace(m_openDatabaseSet); |
| 67 visitor->trace(m_transactionCoordinator); | 61 visitor->trace(m_transactionCoordinator); |
| 68 #endif | 62 #endif |
| 69 } | 63 } |
| 70 | 64 |
| 65 void DatabaseThread::dispose() |
| 66 { |
| 67 // Oilpan: The database thread must have finished its cleanup tasks before |
| 68 // the following clear(). Otherwise, the WebThread destructor blocks the |
| 69 // caller thread, and causes a deadlock with ThreadState cleanup. |
| 70 m_thread.clear(); |
| 71 } |
| 72 |
| 71 void DatabaseThread::start() | 73 void DatabaseThread::start() |
| 72 { | 74 { |
| 73 if (m_thread) | 75 if (m_thread) |
| 74 return; | 76 return; |
| 75 m_thread = WebThreadSupportingGC::create("WebCore: Database"); | 77 m_thread = WebThreadSupportingGC::create("WebCore: Database"); |
| 76 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::setupDatabaseThread,
this))); | 78 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::setupDatabaseThread,
this))); |
| 77 } | 79 } |
| 78 | 80 |
| 79 void DatabaseThread::setupDatabaseThread() | 81 void DatabaseThread::setupDatabaseThread() |
| 80 { | 82 { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 158 |
| 157 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) | 159 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) |
| 158 { | 160 { |
| 159 ASSERT(m_thread); | 161 ASSERT(m_thread); |
| 160 ASSERT(!task->hasSynchronizer() || task->hasCheckedForTermination()); | 162 ASSERT(!task->hasSynchronizer() || task->hasCheckedForTermination()); |
| 161 // WebThread takes ownership of the task. | 163 // WebThread takes ownership of the task. |
| 162 m_thread->postTask(task.leakPtr()); | 164 m_thread->postTask(task.leakPtr()); |
| 163 } | 165 } |
| 164 | 166 |
| 165 } // namespace blink | 167 } // namespace blink |
| OLD | NEW |