Chromium Code Reviews| Index: Source/core/platform/audio/HRTFDatabaseLoader.h |
| diff --git a/Source/core/platform/audio/HRTFDatabaseLoader.h b/Source/core/platform/audio/HRTFDatabaseLoader.h |
| index 4562db7665e52b54512937aaab2486f5484cf62d..701ddb35862383c6ddd2bba5a7309310fd33c4b2 100644 |
| --- a/Source/core/platform/audio/HRTFDatabaseLoader.h |
| +++ b/Source/core/platform/audio/HRTFDatabaseLoader.h |
| @@ -30,10 +30,11 @@ |
| #define HRTFDatabaseLoader_h |
| #include "core/platform/audio/HRTFDatabase.h" |
| -#include <wtf/PassRefPtr.h> |
| -#include <wtf/RefCounted.h> |
| -#include <wtf/RefPtr.h> |
| -#include <wtf/Threading.h> |
| +#include "wtf/HashMap.h" |
| +#include "wtf/PassRefPtr.h" |
| +#include "wtf/RefCounted.h" |
| +#include "wtf/RefPtr.h" |
| +#include "wtf/Threading.h" |
| namespace WebCore { |
| @@ -41,14 +42,12 @@ namespace WebCore { |
| class HRTFDatabaseLoader : public RefCounted<HRTFDatabaseLoader> { |
| public: |
| - // Lazily creates the singleton HRTFDatabaseLoader (if not already created) and starts loading asynchronously (when created the first time). |
| - // Returns the singleton HRTFDatabaseLoader. |
| + // Lazily creates a HRTFDatabaseLoader (if not already created) for the given sample-rate |
| + // and starts loading asynchronously (when created the first time). |
| + // Returns the HRTFDatabaseLoader. |
| // Must be called from the main thread. |
| static PassRefPtr<HRTFDatabaseLoader> createAndLoadAsynchronouslyIfNecessary(float sampleRate); |
| - // Returns the singleton HRTFDatabaseLoader. |
| - static HRTFDatabaseLoader* loader() { return s_loader; } |
| - |
| // Both constructor and destructor must be called from the main thread. |
| ~HRTFDatabaseLoader(); |
| @@ -65,13 +64,16 @@ public: |
| // Called in asynchronous loading thread. |
| void load(); |
| - // defaultHRTFDatabase() gives access to the loaded database. |
| - // This can be called from any thread, but it is the callers responsibilty to call this while the context (and thus HRTFDatabaseLoader) |
| - // is still alive. Otherwise this will return 0. |
| - static HRTFDatabase* defaultHRTFDatabase(); |
| - |
| void reportMemoryUsage(MemoryObjectInfo*) const; |
| + // Map from sample-rate to loader. |
| + class LoaderMap : public HashMap<double, HRTFDatabaseLoader*> { |
| + public: |
| + void reportMemoryUsage(MemoryObjectInfo*) const; |
| + }; |
| + |
| + static HRTFDatabaseLoader::LoaderMap* loaderMap() { return s_loaderMap; } |
|
Ken Russell (switch to Gerrit)
2013/05/13 21:44:18
It seems a bad idea to expose the LoaderMap direct
Chris Rogers
2013/05/14 20:23:10
Agreed that it's not ideal, but PlatformMemoryInst
|
| + |
| private: |
| // Both constructor and destructor must be called from the main thread. |
| explicit HRTFDatabaseLoader(float sampleRate); |
| @@ -80,7 +82,9 @@ private: |
| // This must be called from the main thread. |
| void loadAsynchronously(); |
| - static HRTFDatabaseLoader* s_loader; // singleton |
| + // Keeps track of loaders on a per-sample-rate basis. |
| + static LoaderMap* s_loaderMap; // singleton |
| + |
| OwnPtr<HRTFDatabase> m_hrtfDatabase; |
| // Holding a m_threadLock is required when accessing m_databaseLoaderThread. |