| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 void HRTFDatabaseLoader::loadAsynchronously() | 94 void HRTFDatabaseLoader::loadAsynchronously() |
| 95 { | 95 { |
| 96 ASSERT(isMainThread()); | 96 ASSERT(isMainThread()); |
| 97 | 97 |
| 98 MutexLocker locker(m_lock); | 98 MutexLocker locker(m_lock); |
| 99 if (!m_hrtfDatabase && !m_thread) { | 99 if (!m_hrtfDatabase && !m_thread) { |
| 100 // Start the asynchronous database loading process. | 100 // Start the asynchronous database loading process. |
| 101 m_thread = adoptPtr(Platform::current()->createThread("HRTF database loa
der")); | 101 m_thread = adoptPtr(Platform::current()->createThread("HRTF database loa
der")); |
| 102 // TODO(alexclarke): Should this be posted as a loading task? | 102 // TODO(alexclarke): Should this be posted as a loading task? |
| 103 m_thread->taskRunner()->postTask(FROM_HERE, new Task(threadSafeBind(&HRT
FDatabaseLoader::loadTask, AllowCrossThreadAccess(this)))); | 103 m_thread->taskRunner()->postTask(BLINK_FROM_HERE, new Task(threadSafeBin
d(&HRTFDatabaseLoader::loadTask, AllowCrossThreadAccess(this)))); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool HRTFDatabaseLoader::isLoaded() | 107 bool HRTFDatabaseLoader::isLoaded() |
| 108 { | 108 { |
| 109 MutexLocker locker(m_lock); | 109 MutexLocker locker(m_lock); |
| 110 return m_hrtfDatabase; | 110 return m_hrtfDatabase; |
| 111 } | 111 } |
| 112 | 112 |
| 113 // This cleanup task is needed just to make sure that the loader thread finishes | 113 // This cleanup task is needed just to make sure that the loader thread finishes |
| 114 // the load task and thus the loader thread doesn't touch m_thread any more. | 114 // the load task and thus the loader thread doesn't touch m_thread any more. |
| 115 void HRTFDatabaseLoader::cleanupTask(TaskSynchronizer* sync) | 115 void HRTFDatabaseLoader::cleanupTask(TaskSynchronizer* sync) |
| 116 { | 116 { |
| 117 sync->taskCompleted(); | 117 sync->taskCompleted(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() | 120 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() |
| 121 { | 121 { |
| 122 if (!m_thread) | 122 if (!m_thread) |
| 123 return; | 123 return; |
| 124 | 124 |
| 125 TaskSynchronizer sync; | 125 TaskSynchronizer sync; |
| 126 // TODO(alexclarke): Should this be posted as a loading task? | 126 // TODO(alexclarke): Should this be posted as a loading task? |
| 127 m_thread->taskRunner()->postTask(FROM_HERE, new Task(threadSafeBind(&HRTFDat
abaseLoader::cleanupTask, AllowCrossThreadAccess(this), AllowCrossThreadAccess(&
sync)))); | 127 m_thread->taskRunner()->postTask(BLINK_FROM_HERE, new Task(threadSafeBind(&H
RTFDatabaseLoader::cleanupTask, AllowCrossThreadAccess(this), AllowCrossThreadAc
cess(&sync)))); |
| 128 sync.waitForTaskCompletion(); | 128 sync.waitForTaskCompletion(); |
| 129 m_thread.clear(); | 129 m_thread.clear(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace blink | 132 } // namespace blink |
| 133 | 133 |
| 134 #endif // ENABLE(WEB_AUDIO) | 134 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |