Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: third_party/WebKit/Source/platform/audio/HRTFDatabaseLoader.h

Issue 2288983004: Merge TaskSynchronizer into WaitableEvent. (Closed)
Patch Set: fix Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 20 matching lines...) Expand all
31 31
32 #include "platform/audio/HRTFDatabase.h" 32 #include "platform/audio/HRTFDatabase.h"
33 #include "public/platform/WebThread.h" 33 #include "public/platform/WebThread.h"
34 #include "wtf/HashMap.h" 34 #include "wtf/HashMap.h"
35 #include "wtf/RefCounted.h" 35 #include "wtf/RefCounted.h"
36 #include "wtf/ThreadingPrimitives.h" 36 #include "wtf/ThreadingPrimitives.h"
37 #include <memory> 37 #include <memory>
38 38
39 namespace blink { 39 namespace blink {
40 40
41 class TaskSynchronizer; 41 class WaitableEvent;
42 42
43 // HRTFDatabaseLoader will asynchronously load the default HRTFDatabase in a new thread. 43 // HRTFDatabaseLoader will asynchronously load the default HRTFDatabase in a new thread.
44
45 class PLATFORM_EXPORT HRTFDatabaseLoader final : public RefCounted<HRTFDatabaseL oader> { 44 class PLATFORM_EXPORT HRTFDatabaseLoader final : public RefCounted<HRTFDatabaseL oader> {
46 public: 45 public:
47 // Lazily creates a HRTFDatabaseLoader (if not already created) for the give n sample-rate 46 // Lazily creates a HRTFDatabaseLoader (if not already created) for the give n sample-rate
48 // and starts loading asynchronously (when created the first time). 47 // and starts loading asynchronously (when created the first time).
49 // Returns the HRTFDatabaseLoader. 48 // Returns the HRTFDatabaseLoader.
50 // Must be called from the main thread. 49 // Must be called from the main thread.
51 static PassRefPtr<HRTFDatabaseLoader> createAndLoadAsynchronouslyIfNecessary (float sampleRate); 50 static PassRefPtr<HRTFDatabaseLoader> createAndLoadAsynchronouslyIfNecessary (float sampleRate);
52 51
53 // Both constructor and destructor must be called from the main thread. 52 // Both constructor and destructor must be called from the main thread.
54 ~HRTFDatabaseLoader(); 53 ~HRTFDatabaseLoader();
(...skipping 14 matching lines...) Expand all
69 private: 68 private:
70 // Both constructor and destructor must be called from the main thread. 69 // Both constructor and destructor must be called from the main thread.
71 explicit HRTFDatabaseLoader(float sampleRate); 70 explicit HRTFDatabaseLoader(float sampleRate);
72 71
73 // If it hasn't already been loaded, creates a new thread and initiates asyn chronous loading of the default database. 72 // If it hasn't already been loaded, creates a new thread and initiates asyn chronous loading of the default database.
74 // This must be called from the main thread. 73 // This must be called from the main thread.
75 void loadAsynchronously(); 74 void loadAsynchronously();
76 75
77 // Called in asynchronous loading thread. 76 // Called in asynchronous loading thread.
78 void loadTask(); 77 void loadTask();
79 void cleanupTask(TaskSynchronizer*); 78 void cleanupTask(WaitableEvent*);
80 79
81 // Holding a m_lock is required when accessing m_hrtfDatabase since we acces s it from multiple threads. 80 // Holding a m_lock is required when accessing m_hrtfDatabase since we acces s it from multiple threads.
82 Mutex m_lock; 81 Mutex m_lock;
83 std::unique_ptr<HRTFDatabase> m_hrtfDatabase; 82 std::unique_ptr<HRTFDatabase> m_hrtfDatabase;
84 83
85 std::unique_ptr<WebThread> m_thread; 84 std::unique_ptr<WebThread> m_thread;
86 85
87 float m_databaseSampleRate; 86 float m_databaseSampleRate;
88 }; 87 };
89 88
90 } // namespace blink 89 } // namespace blink
91 90
92 #endif // HRTFDatabaseLoader_h 91 #endif // HRTFDatabaseLoader_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/WaitableEvent.cpp ('k') | third_party/WebKit/Source/platform/audio/HRTFDatabaseLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698