Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/pepper/pepper_audio_control_delegate.h" | |
| 6 | |
| 7 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | |
| 8 #include "content/renderer/pepper/ppb_audio_impl.h" | |
| 9 #include "content/renderer/render_frame_impl.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 PepperAudioControlDelegate::PepperAudioControlDelegate( | |
| 14 PepperPluginInstanceImpl* pepper_instance) | |
| 15 : pepper_instance_(pepper_instance) { | |
| 16 DCHECK(pepper_instance_); | |
| 17 } | |
| 18 | |
| 19 PepperAudioControlDelegate::~PepperAudioControlDelegate() { | |
| 20 DCHECK(!pepper_instance_); | |
|
bbudge
2016/06/22 18:14:55
It seems to me like you could instead:
if (instan
Zhiqiang Zhang (Slow)
2016/06/22 21:00:42
Done.
| |
| 21 } | |
| 22 | |
| 23 void PepperAudioControlDelegate::AddActiveAudioInstance(PPB_Audio_Impl* audio) { | |
| 24 if (!pepper_instance_) return; | |
| 25 if (ppb_audios_.count(audio)) return; | |
|
bbudge
2016/06/22 18:14:54
It might be better to DCHECK that the instance isn
Zhiqiang Zhang (Slow)
2016/06/22 21:00:42
The StartPlayback signal originates from Pepper. I
| |
| 26 | |
| 27 if (ppb_audios_.empty()) { | |
| 28 RenderFrameImpl* render_frame = pepper_instance_->render_frame(); | |
| 29 if (render_frame) | |
| 30 render_frame->PepperStartsPlayback(pepper_instance_); | |
| 31 } | |
| 32 | |
| 33 ppb_audios_.insert(audio); | |
| 34 } | |
| 35 | |
| 36 void PepperAudioControlDelegate::RemoveActiveAudioInstance( | |
| 37 PPB_Audio_Impl* audio) { | |
| 38 if (!pepper_instance_) return; | |
| 39 if (!ppb_audios_.count(audio)) return; | |
|
bbudge
2016/06/22 18:14:54
DCHECK?
Zhiqiang Zhang (Slow)
2016/06/22 21:00:42
Ditto.
| |
| 40 | |
| 41 ppb_audios_.erase(audio); | |
| 42 | |
| 43 if (ppb_audios_.empty()) { | |
| 44 RenderFrameImpl* render_frame = pepper_instance_->render_frame(); | |
| 45 if (render_frame) | |
| 46 render_frame->PepperStopsPlayback(pepper_instance_); | |
| 47 } | |
| 48 } | |
| 49 | |
| 50 void PepperAudioControlDelegate::SetVolume(double volume) { | |
| 51 if (!pepper_instance_) return; | |
| 52 | |
| 53 for (auto* ppb_audio : ppb_audios_) | |
| 54 ppb_audio->SetVolume(volume); | |
| 55 } | |
| 56 | |
| 57 void PepperAudioControlDelegate::OnPepperInstanceDeleted() { | |
| 58 DCHECK(!pepper_instance_); | |
|
bbudge
2016/06/22 18:14:54
DCHECK(instance_);
Zhiqiang Zhang (Slow)
2016/06/22 21:00:42
Done.
| |
| 59 | |
| 60 if (!ppb_audios_.empty()) { | |
| 61 RenderFrameImpl* render_frame = pepper_instance_->render_frame(); | |
| 62 if (render_frame) | |
| 63 render_frame->PepperStopsPlayback(pepper_instance_); | |
| 64 } | |
|
bbudge
2016/06/22 18:14:54
This duplicated code could be moved to a private h
Zhiqiang Zhang (Slow)
2016/06/22 21:00:42
Done.
| |
| 65 | |
| 66 ppb_audios_.clear(); | |
| 67 pepper_instance_ = nullptr; | |
| 68 } | |
| 69 | |
| 70 } | |
| OLD | NEW |