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

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

Issue 1925583003: Replace AllowCrossThreadAccess() + non-GCed pointers with crossThreadUnretained() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Kuroneko_4
Patch Set: Rebase. Created 4 years, 5 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 void HRTFDatabaseLoader::loadAsynchronously() 89 void HRTFDatabaseLoader::loadAsynchronously()
90 { 90 {
91 ASSERT(isMainThread()); 91 ASSERT(isMainThread());
92 92
93 MutexLocker locker(m_lock); 93 MutexLocker locker(m_lock);
94 if (!m_hrtfDatabase && !m_thread) { 94 if (!m_hrtfDatabase && !m_thread) {
95 // Start the asynchronous database loading process. 95 // Start the asynchronous database loading process.
96 m_thread = wrapUnique(Platform::current()->createThread("HRTF database l oader")); 96 m_thread = wrapUnique(Platform::current()->createThread("HRTF database l oader"));
97 // TODO(alexclarke): Should this be posted as a loading task? 97 // TODO(alexclarke): Should this be posted as a loading task?
98 m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(& HRTFDatabaseLoader::loadTask, AllowCrossThreadAccess(this))); 98 m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(& HRTFDatabaseLoader::loadTask, crossThreadUnretained(this)));
99 } 99 }
100 } 100 }
101 101
102 bool HRTFDatabaseLoader::isLoaded() 102 bool HRTFDatabaseLoader::isLoaded()
103 { 103 {
104 MutexLocker locker(m_lock); 104 MutexLocker locker(m_lock);
105 return m_hrtfDatabase.get(); 105 return m_hrtfDatabase.get();
106 } 106 }
107 107
108 // This cleanup task is needed just to make sure that the loader thread finishes 108 // This cleanup task is needed just to make sure that the loader thread finishes
109 // the load task and thus the loader thread doesn't touch m_thread any more. 109 // the load task and thus the loader thread doesn't touch m_thread any more.
110 void HRTFDatabaseLoader::cleanupTask(TaskSynchronizer* sync) 110 void HRTFDatabaseLoader::cleanupTask(TaskSynchronizer* sync)
111 { 111 {
112 sync->taskCompleted(); 112 sync->taskCompleted();
113 } 113 }
114 114
115 void HRTFDatabaseLoader::waitForLoaderThreadCompletion() 115 void HRTFDatabaseLoader::waitForLoaderThreadCompletion()
116 { 116 {
117 if (!m_thread) 117 if (!m_thread)
118 return; 118 return;
119 119
120 TaskSynchronizer sync; 120 TaskSynchronizer sync;
121 // TODO(alexclarke): Should this be posted as a loading task? 121 // TODO(alexclarke): Should this be posted as a loading task?
122 m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&HRTF DatabaseLoader::cleanupTask, AllowCrossThreadAccess(this), AllowCrossThreadAcces s(&sync))); 122 m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&HRTF DatabaseLoader::cleanupTask, crossThreadUnretained(this), crossThreadUnretained( &sync)));
123 sync.waitForTaskCompletion(); 123 sync.waitForTaskCompletion();
124 m_thread.reset(); 124 m_thread.reset();
125 } 125 }
126 126
127 } // namespace blink 127 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/CrossThreadCopier.h ('k') | third_party/WebKit/Source/platform/audio/ReverbConvolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698