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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
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 m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&HRTFDatabaseLoade
r::loadTask, AllowCrossThreadAccess(this)))); | 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 } | 104 } |
104 } | 105 } |
105 | 106 |
106 bool HRTFDatabaseLoader::isLoaded() | 107 bool HRTFDatabaseLoader::isLoaded() |
107 { | 108 { |
108 MutexLocker locker(m_lock); | 109 MutexLocker locker(m_lock); |
109 return m_hrtfDatabase; | 110 return m_hrtfDatabase; |
110 } | 111 } |
111 | 112 |
112 // 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 |
113 // 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. |
114 void HRTFDatabaseLoader::cleanupTask(TaskSynchronizer* sync) | 115 void HRTFDatabaseLoader::cleanupTask(TaskSynchronizer* sync) |
115 { | 116 { |
116 sync->taskCompleted(); | 117 sync->taskCompleted(); |
117 } | 118 } |
118 | 119 |
119 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() | 120 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() |
120 { | 121 { |
121 if (!m_thread) | 122 if (!m_thread) |
122 return; | 123 return; |
123 | 124 |
124 TaskSynchronizer sync; | 125 TaskSynchronizer sync; |
125 m_thread->postTask(FROM_HERE, new Task(threadSafeBind(&HRTFDatabaseLoader::c
leanupTask, AllowCrossThreadAccess(this), AllowCrossThreadAccess(&sync)))); | 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)))); |
126 sync.waitForTaskCompletion(); | 128 sync.waitForTaskCompletion(); |
127 m_thread.clear(); | 129 m_thread.clear(); |
128 } | 130 } |
129 | 131 |
130 } // namespace blink | 132 } // namespace blink |
131 | 133 |
132 #endif // ENABLE(WEB_AUDIO) | 134 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |