| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 DCHECK(IsMainThread()); | 88 DCHECK(IsMainThread()); |
| 89 | 89 |
| 90 // m_hrtfDatabase and m_thread should both be unset because this should be a | 90 // m_hrtfDatabase and m_thread should both be unset because this should be a |
| 91 // new HRTFDatabaseLoader object that was just created by | 91 // new HRTFDatabaseLoader object that was just created by |
| 92 // createAndLoadAsynchronouslyIfNecessary and because we haven't started | 92 // createAndLoadAsynchronouslyIfNecessary and because we haven't started |
| 93 // loadTask yet for this object. | 93 // loadTask yet for this object. |
| 94 DCHECK(!hrtf_database_); | 94 DCHECK(!hrtf_database_); |
| 95 DCHECK(!thread_); | 95 DCHECK(!thread_); |
| 96 | 96 |
| 97 // Start the asynchronous database loading process. | 97 // Start the asynchronous database loading process. |
| 98 thread_ = WTF::WrapUnique( | 98 thread_ = Platform::Current()->CreateThread("HRTF database loader"); |
| 99 Platform::Current()->CreateThread("HRTF database loader")); | |
| 100 // TODO(alexclarke): Should this be posted as a loading task? | 99 // TODO(alexclarke): Should this be posted as a loading task? |
| 101 thread_->GetWebTaskRunner()->PostTask( | 100 thread_->GetWebTaskRunner()->PostTask( |
| 102 BLINK_FROM_HERE, CrossThreadBind(&HRTFDatabaseLoader::LoadTask, | 101 BLINK_FROM_HERE, CrossThreadBind(&HRTFDatabaseLoader::LoadTask, |
| 103 CrossThreadUnretained(this))); | 102 CrossThreadUnretained(this))); |
| 104 } | 103 } |
| 105 | 104 |
| 106 HRTFDatabase* HRTFDatabaseLoader::Database() { | 105 HRTFDatabase* HRTFDatabaseLoader::Database() { |
| 107 DCHECK(!IsMainThread()); | 106 DCHECK(!IsMainThread()); |
| 108 | 107 |
| 109 // Seeing that this is only called from the audio thread, we can't block. | 108 // Seeing that this is only called from the audio thread, we can't block. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 130 // TODO(alexclarke): Should this be posted as a loading task? | 129 // TODO(alexclarke): Should this be posted as a loading task? |
| 131 thread_->GetWebTaskRunner()->PostTask( | 130 thread_->GetWebTaskRunner()->PostTask( |
| 132 BLINK_FROM_HERE, CrossThreadBind(&HRTFDatabaseLoader::CleanupTask, | 131 BLINK_FROM_HERE, CrossThreadBind(&HRTFDatabaseLoader::CleanupTask, |
| 133 CrossThreadUnretained(this), | 132 CrossThreadUnretained(this), |
| 134 CrossThreadUnretained(&sync))); | 133 CrossThreadUnretained(&sync))); |
| 135 sync.Wait(); | 134 sync.Wait(); |
| 136 thread_.reset(); | 135 thread_.reset(); |
| 137 } | 136 } |
| 138 | 137 |
| 139 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |