OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/process.h" | 9 #include "base/process.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 audio_input_man->Stop(session_id); | 367 audio_input_man->Stop(session_id); |
368 | 368 |
369 // Delete the session entry. | 369 // Delete the session entry. |
370 session_entries_.erase(session_id); | 370 session_entries_.erase(session_id); |
371 } | 371 } |
372 | 372 |
373 void AudioInputRendererHost::CloseAndDeleteStream(AudioEntry* entry) { | 373 void AudioInputRendererHost::CloseAndDeleteStream(AudioEntry* entry) { |
374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
375 | 375 |
376 if (!entry->pending_close) { | 376 if (!entry->pending_close) { |
377 entry->controller->Close(base::Bind(&AudioInputRendererHost::OnStreamClosed, | 377 entry->controller->Close(base::Bind(&AudioInputRendererHost::DeleteEntry, |
378 this, entry)); | 378 this, entry)); |
379 entry->pending_close = true; | 379 entry->pending_close = true; |
380 } | 380 } |
381 } | 381 } |
382 | 382 |
383 void AudioInputRendererHost::OnStreamClosed(AudioEntry* entry) { | |
384 // We should be on the the audio-manager thread now. | |
385 DCHECK(entry->controller->message_loop()->BelongsToCurrentThread()); | |
386 | |
387 // Delete the entry after we've closed the stream. | |
388 BrowserThread::PostTask( | |
389 BrowserThread::IO, FROM_HERE, | |
390 base::Bind(&AudioInputRendererHost::DeleteEntry, this, entry)); | |
391 } | |
392 | |
393 void AudioInputRendererHost::DeleteEntry(AudioEntry* entry) { | 383 void AudioInputRendererHost::DeleteEntry(AudioEntry* entry) { |
394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 384 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
395 | 385 |
396 // Delete the entry when this method goes out of scope. | 386 // Delete the entry when this method goes out of scope. |
397 scoped_ptr<AudioEntry> entry_deleter(entry); | 387 scoped_ptr<AudioEntry> entry_deleter(entry); |
398 | 388 |
399 // Erase the entry from the map. | 389 // Erase the entry from the map. |
400 audio_entries_.erase(entry->stream_id); | 390 audio_entries_.erase(entry->stream_id); |
401 } | 391 } |
402 | 392 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 427 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
438 | 428 |
439 for (SessionEntryMap::iterator it = session_entries_.begin(); | 429 for (SessionEntryMap::iterator it = session_entries_.begin(); |
440 it != session_entries_.end(); ++it) { | 430 it != session_entries_.end(); ++it) { |
441 if (stream_id == it->second) { | 431 if (stream_id == it->second) { |
442 return it->first; | 432 return it->first; |
443 } | 433 } |
444 } | 434 } |
445 return 0; | 435 return 0; |
446 } | 436 } |
OLD | NEW |