| 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 | 30 |
| 31 #if ENABLE(WEB_AUDIO) | 31 #if ENABLE(WEB_AUDIO) |
| 32 | 32 |
| 33 #include "platform/audio/HRTFDatabaseLoader.h" | 33 #include "platform/audio/HRTFDatabaseLoader.h" |
| 34 | 34 |
| 35 #include "platform/Task.h" | 35 #include "platform/Task.h" |
| 36 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 37 #include "wtf/MainThread.h" | 37 #include "wtf/MainThread.h" |
| 38 #include "wtf/UnretainedPtr.h" |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 typedef HeapHashMap<double, WeakMember<HRTFDatabaseLoader> > LoaderMap; | 42 typedef HeapHashMap<double, WeakMember<HRTFDatabaseLoader> > LoaderMap; |
| 42 | 43 |
| 43 static LoaderMap& loaderMap() | 44 static LoaderMap& loaderMap() |
| 44 { | 45 { |
| 45 DEFINE_STATIC_LOCAL(Persistent<LoaderMap>, map, (new LoaderMap)); | 46 DEFINE_STATIC_LOCAL(Persistent<LoaderMap>, map, (new LoaderMap)); |
| 46 return *map; | 47 return *map; |
| 47 } | 48 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 88 |
| 88 void HRTFDatabaseLoader::loadAsynchronously() | 89 void HRTFDatabaseLoader::loadAsynchronously() |
| 89 { | 90 { |
| 90 ASSERT(isMainThread()); | 91 ASSERT(isMainThread()); |
| 91 | 92 |
| 92 MutexLocker locker(m_threadLock); | 93 MutexLocker locker(m_threadLock); |
| 93 | 94 |
| 94 if (!m_hrtfDatabase && !m_databaseLoaderThread) { | 95 if (!m_hrtfDatabase && !m_databaseLoaderThread) { |
| 95 // Start the asynchronous database loading process. | 96 // Start the asynchronous database loading process. |
| 96 m_databaseLoaderThread = adoptPtr(Platform::current()->createThread("HRT
F database loader")); | 97 m_databaseLoaderThread = adoptPtr(Platform::current()->createThread("HRT
F database loader")); |
| 97 m_databaseLoaderThread->postTask(new Task(WTF::bind(&HRTFDatabaseLoader:
:load, this))); | 98 m_databaseLoaderThread->postTask(new Task(WTF::bind(&HRTFDatabaseLoader:
:load, UnretainedPtr<HRTFDatabaseLoader>(this)))); |
| 98 } | 99 } |
| 99 } | 100 } |
| 100 | 101 |
| 101 bool HRTFDatabaseLoader::isLoaded() const | 102 bool HRTFDatabaseLoader::isLoaded() const |
| 102 { | 103 { |
| 103 return m_hrtfDatabase; | 104 return m_hrtfDatabase; |
| 104 } | 105 } |
| 105 | 106 |
| 106 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() | 107 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() |
| 107 { | 108 { |
| 108 MutexLocker locker(m_threadLock); | 109 MutexLocker locker(m_threadLock); |
| 109 m_databaseLoaderThread.clear(); | 110 m_databaseLoaderThread.clear(); |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace blink | 113 } // namespace blink |
| 113 | 114 |
| 114 #endif // ENABLE(WEB_AUDIO) | 115 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |