| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // Start the asynchronous database loading process. | 94 // Start the asynchronous database loading process. |
| 95 m_thread = adoptPtr(Platform::current()->createThread("HRTF database loa
der")); | 95 m_thread = adoptPtr(Platform::current()->createThread("HRTF database loa
der")); |
| 96 // TODO(alexclarke): Should this be posted as a loading task? | 96 // TODO(alexclarke): Should this be posted as a loading task? |
| 97 m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&
HRTFDatabaseLoader::loadTask, AllowCrossThreadAccess(this))); | 97 m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&
HRTFDatabaseLoader::loadTask, AllowCrossThreadAccess(this))); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool HRTFDatabaseLoader::isLoaded() | 101 bool HRTFDatabaseLoader::isLoaded() |
| 102 { | 102 { |
| 103 MutexLocker locker(m_lock); | 103 MutexLocker locker(m_lock); |
| 104 return m_hrtfDatabase; | 104 return m_hrtfDatabase.get(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // This cleanup task is needed just to make sure that the loader thread finishes | 107 // This cleanup task is needed just to make sure that the loader thread finishes |
| 108 // the load task and thus the loader thread doesn't touch m_thread any more. | 108 // the load task and thus the loader thread doesn't touch m_thread any more. |
| 109 void HRTFDatabaseLoader::cleanupTask(TaskSynchronizer* sync) | 109 void HRTFDatabaseLoader::cleanupTask(TaskSynchronizer* sync) |
| 110 { | 110 { |
| 111 sync->taskCompleted(); | 111 sync->taskCompleted(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() | 114 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() |
| 115 { | 115 { |
| 116 if (!m_thread) | 116 if (!m_thread) |
| 117 return; | 117 return; |
| 118 | 118 |
| 119 TaskSynchronizer sync; | 119 TaskSynchronizer sync; |
| 120 // TODO(alexclarke): Should this be posted as a loading task? | 120 // TODO(alexclarke): Should this be posted as a loading task? |
| 121 m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&HRTF
DatabaseLoader::cleanupTask, AllowCrossThreadAccess(this), AllowCrossThreadAcces
s(&sync))); | 121 m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&HRTF
DatabaseLoader::cleanupTask, AllowCrossThreadAccess(this), AllowCrossThreadAcces
s(&sync))); |
| 122 sync.waitForTaskCompletion(); | 122 sync.waitForTaskCompletion(); |
| 123 m_thread.clear(); | 123 m_thread.clear(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace blink | 126 } // namespace blink |
| OLD | NEW |