| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 return *map; | 46 return *map; |
| 47 } | 47 } |
| 48 | 48 |
| 49 PassRefPtr<HRTFDatabaseLoader> | 49 PassRefPtr<HRTFDatabaseLoader> |
| 50 HRTFDatabaseLoader::CreateAndLoadAsynchronouslyIfNecessary(float sample_rate) { | 50 HRTFDatabaseLoader::CreateAndLoadAsynchronouslyIfNecessary(float sample_rate) { |
| 51 DCHECK(IsMainThread()); | 51 DCHECK(IsMainThread()); |
| 52 | 52 |
| 53 RefPtr<HRTFDatabaseLoader> loader = GetLoaderMap().at(sample_rate); | 53 RefPtr<HRTFDatabaseLoader> loader = GetLoaderMap().at(sample_rate); |
| 54 if (loader) { | 54 if (loader) { |
| 55 DCHECK_EQ(sample_rate, loader->DatabaseSampleRate()); | 55 DCHECK_EQ(sample_rate, loader->DatabaseSampleRate()); |
| 56 return loader.Release(); | 56 return loader; |
| 57 } | 57 } |
| 58 | 58 |
| 59 loader = AdoptRef(new HRTFDatabaseLoader(sample_rate)); | 59 loader = AdoptRef(new HRTFDatabaseLoader(sample_rate)); |
| 60 GetLoaderMap().insert(sample_rate, loader.Get()); | 60 GetLoaderMap().insert(sample_rate, loader.Get()); |
| 61 loader->LoadAsynchronously(); | 61 loader->LoadAsynchronously(); |
| 62 return loader.Release(); | 62 return loader; |
| 63 } | 63 } |
| 64 | 64 |
| 65 HRTFDatabaseLoader::HRTFDatabaseLoader(float sample_rate) | 65 HRTFDatabaseLoader::HRTFDatabaseLoader(float sample_rate) |
| 66 : database_sample_rate_(sample_rate) { | 66 : database_sample_rate_(sample_rate) { |
| 67 DCHECK(IsMainThread()); | 67 DCHECK(IsMainThread()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 HRTFDatabaseLoader::~HRTFDatabaseLoader() { | 70 HRTFDatabaseLoader::~HRTFDatabaseLoader() { |
| 71 DCHECK(IsMainThread()); | 71 DCHECK(IsMainThread()); |
| 72 DCHECK(!thread_); | 72 DCHECK(!thread_); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // TODO(alexclarke): Should this be posted as a loading task? | 129 // TODO(alexclarke): Should this be posted as a loading task? |
| 130 thread_->GetWebTaskRunner()->PostTask( | 130 thread_->GetWebTaskRunner()->PostTask( |
| 131 BLINK_FROM_HERE, CrossThreadBind(&HRTFDatabaseLoader::CleanupTask, | 131 BLINK_FROM_HERE, CrossThreadBind(&HRTFDatabaseLoader::CleanupTask, |
| 132 CrossThreadUnretained(this), | 132 CrossThreadUnretained(this), |
| 133 CrossThreadUnretained(&sync))); | 133 CrossThreadUnretained(&sync))); |
| 134 sync.Wait(); | 134 sync.Wait(); |
| 135 thread_.reset(); | 135 thread_.reset(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |