| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 visitor->trace(m_openDatabaseSet); | 58 visitor->trace(m_openDatabaseSet); |
| 59 visitor->trace(m_transactionCoordinator); | 59 visitor->trace(m_transactionCoordinator); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void DatabaseThread::start() | 62 void DatabaseThread::start() |
| 63 { | 63 { |
| 64 ASSERT(isMainThread()); | 64 ASSERT(isMainThread()); |
| 65 if (m_thread) | 65 if (m_thread) |
| 66 return; | 66 return; |
| 67 m_thread = WebThreadSupportingGC::create("WebCore: Database"); | 67 m_thread = WebThreadSupportingGC::create("WebCore: Database"); |
| 68 m_thread->postTask(BLINK_FROM_HERE, threadSafeBind(&DatabaseThread::setupDat
abaseThread, this)); | 68 m_thread->postTask(BLINK_FROM_HERE, threadSafeBind(&DatabaseThread::setupDat
abaseThread, wrapCrossThreadPersistent(this))); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void DatabaseThread::setupDatabaseThread() | 71 void DatabaseThread::setupDatabaseThread() |
| 72 { | 72 { |
| 73 m_thread->initialize(); | 73 m_thread->initialize(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void DatabaseThread::terminate() | 76 void DatabaseThread::terminate() |
| 77 { | 77 { |
| 78 ASSERT(isMainThread()); | 78 ASSERT(isMainThread()); |
| 79 TaskSynchronizer sync; | 79 TaskSynchronizer sync; |
| 80 { | 80 { |
| 81 MutexLocker lock(m_terminationRequestedMutex); | 81 MutexLocker lock(m_terminationRequestedMutex); |
| 82 ASSERT(!m_terminationRequested); | 82 ASSERT(!m_terminationRequested); |
| 83 m_terminationRequested = true; | 83 m_terminationRequested = true; |
| 84 m_cleanupSync = &sync; | 84 m_cleanupSync = &sync; |
| 85 WTF_LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this); | 85 WTF_LOG(StorageAPI, "DatabaseThread %p was asked to terminate\n", this); |
| 86 m_thread->postTask(BLINK_FROM_HERE, threadSafeBind(&DatabaseThread::clea
nupDatabaseThread, this)); | 86 m_thread->postTask(BLINK_FROM_HERE, threadSafeBind(&DatabaseThread::clea
nupDatabaseThread, wrapCrossThreadPersistent(this))); |
| 87 } | 87 } |
| 88 sync.waitForTaskCompletion(); | 88 sync.waitForTaskCompletion(); |
| 89 // The WebThread destructor blocks until all the tasks of the database | 89 // The WebThread destructor blocks until all the tasks of the database |
| 90 // thread are processed. However, it shouldn't block at all because | 90 // thread are processed. However, it shouldn't block at all because |
| 91 // the database thread has already finished processing the cleanup task. | 91 // the database thread has already finished processing the cleanup task. |
| 92 m_thread.clear(); | 92 m_thread.clear(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void DatabaseThread::cleanupDatabaseThread() | 95 void DatabaseThread::cleanupDatabaseThread() |
| 96 { | 96 { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 { | 166 { |
| 167 MutexLocker lock(m_terminationRequestedMutex); | 167 MutexLocker lock(m_terminationRequestedMutex); |
| 168 ASSERT(!m_terminationRequested); | 168 ASSERT(!m_terminationRequested); |
| 169 } | 169 } |
| 170 #endif | 170 #endif |
| 171 // WebThread takes ownership of the task. | 171 // WebThread takes ownership of the task. |
| 172 m_thread->postTask(BLINK_FROM_HERE, threadSafeBind(&DatabaseTask::run, std::
move(task))); | 172 m_thread->postTask(BLINK_FROM_HERE, threadSafeBind(&DatabaseTask::run, std::
move(task))); |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace blink | 175 } // namespace blink |
| OLD | NEW |