| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/proxy/ppb_audio_config_proxy.h" | 5 #include "ppapi/proxy/ppb_audio_config_proxy.h" |
| 6 | 6 |
| 7 #include "ppapi/c/ppb_audio_config.h" | 7 #include "ppapi/c/ppb_audio_config.h" |
| 8 #include "ppapi/proxy/plugin_dispatcher.h" | 8 #include "ppapi/proxy/plugin_dispatcher.h" |
| 9 #include "ppapi/proxy/ppapi_messages.h" | 9 #include "ppapi/proxy/ppapi_messages.h" |
| 10 #include "ppapi/shared_impl/audio_config_impl.h" | 10 #include "ppapi/shared_impl/audio_config_impl.h" |
| 11 #include "ppapi/thunk/thunk.h" | 11 #include "ppapi/thunk/thunk.h" |
| 12 | 12 |
| 13 using ppapi::HostResource; | 13 namespace ppapi { |
| 14 using ppapi::Resource; | |
| 15 | |
| 16 namespace pp { | |
| 17 namespace proxy { | 14 namespace proxy { |
| 18 | 15 |
| 19 // The implementation is actually in AudioConfigImpl. | 16 // The implementation is actually in AudioConfigImpl. |
| 20 class AudioConfig : public Resource, public ppapi::AudioConfigImpl { | 17 class AudioConfig : public Resource, public AudioConfigImpl { |
| 21 public: | 18 public: |
| 22 // Note that you must call Init (on AudioConfigImpl) before using this class. | 19 // Note that you must call Init (on AudioConfigImpl) before using this class. |
| 23 AudioConfig(const HostResource& resource); | 20 AudioConfig(const HostResource& resource); |
| 24 virtual ~AudioConfig(); | 21 virtual ~AudioConfig(); |
| 25 | 22 |
| 26 // Resource overrides. | 23 // Resource overrides. |
| 27 virtual ::ppapi::thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() OVERRIDE; | 24 virtual thunk::PPB_AudioConfig_API* AsPPB_AudioConfig_API() OVERRIDE; |
| 28 | 25 |
| 29 private: | 26 private: |
| 30 DISALLOW_COPY_AND_ASSIGN(AudioConfig); | 27 DISALLOW_COPY_AND_ASSIGN(AudioConfig); |
| 31 }; | 28 }; |
| 32 | 29 |
| 33 AudioConfig::AudioConfig(const HostResource& resource) : Resource(resource) { | 30 AudioConfig::AudioConfig(const HostResource& resource) : Resource(resource) { |
| 34 } | 31 } |
| 35 | 32 |
| 36 AudioConfig::~AudioConfig() { | 33 AudioConfig::~AudioConfig() { |
| 37 } | 34 } |
| 38 | 35 |
| 39 ::ppapi::thunk::PPB_AudioConfig_API* AudioConfig::AsPPB_AudioConfig_API() { | 36 thunk::PPB_AudioConfig_API* AudioConfig::AsPPB_AudioConfig_API() { |
| 40 return this; | 37 return this; |
| 41 } | 38 } |
| 42 | 39 |
| 43 namespace { | 40 namespace { |
| 44 | 41 |
| 45 InterfaceProxy* CreateAudioConfigProxy(Dispatcher* dispatcher, | 42 InterfaceProxy* CreateAudioConfigProxy(Dispatcher* dispatcher, |
| 46 const void* target_interface) { | 43 const void* target_interface) { |
| 47 return new PPB_AudioConfig_Proxy(dispatcher, target_interface); | 44 return new PPB_AudioConfig_Proxy(dispatcher, target_interface); |
| 48 } | 45 } |
| 49 | 46 |
| 50 } // namespace | 47 } // namespace |
| 51 | 48 |
| 52 PPB_AudioConfig_Proxy::PPB_AudioConfig_Proxy(Dispatcher* dispatcher, | 49 PPB_AudioConfig_Proxy::PPB_AudioConfig_Proxy(Dispatcher* dispatcher, |
| 53 const void* target_interface) | 50 const void* target_interface) |
| 54 : InterfaceProxy(dispatcher, target_interface) { | 51 : InterfaceProxy(dispatcher, target_interface) { |
| 55 } | 52 } |
| 56 | 53 |
| 57 PPB_AudioConfig_Proxy::~PPB_AudioConfig_Proxy() { | 54 PPB_AudioConfig_Proxy::~PPB_AudioConfig_Proxy() { |
| 58 } | 55 } |
| 59 | 56 |
| 60 // static | 57 // static |
| 61 const InterfaceProxy::Info* PPB_AudioConfig_Proxy::GetInfo() { | 58 const InterfaceProxy::Info* PPB_AudioConfig_Proxy::GetInfo() { |
| 62 static const Info info = { | 59 static const Info info = { |
| 63 ::ppapi::thunk::GetPPB_AudioConfig_Thunk(), | 60 thunk::GetPPB_AudioConfig_Thunk(), |
| 64 PPB_AUDIO_CONFIG_INTERFACE, | 61 PPB_AUDIO_CONFIG_INTERFACE, |
| 65 INTERFACE_ID_PPB_AUDIO_CONFIG, | 62 INTERFACE_ID_PPB_AUDIO_CONFIG, |
| 66 false, | 63 false, |
| 67 &CreateAudioConfigProxy, | 64 &CreateAudioConfigProxy, |
| 68 }; | 65 }; |
| 69 return &info; | 66 return &info; |
| 70 } | 67 } |
| 71 | 68 |
| 72 // static | 69 // static |
| 73 PP_Resource PPB_AudioConfig_Proxy::CreateProxyResource( | 70 PP_Resource PPB_AudioConfig_Proxy::CreateProxyResource( |
| 74 PP_Instance instance, | 71 PP_Instance instance, |
| 75 PP_AudioSampleRate sample_rate, | 72 PP_AudioSampleRate sample_rate, |
| 76 uint32_t sample_frame_count) { | 73 uint32_t sample_frame_count) { |
| 77 scoped_refptr<AudioConfig> object(new AudioConfig( | 74 scoped_refptr<AudioConfig> object(new AudioConfig( |
| 78 HostResource::MakeInstanceOnly(instance))); | 75 HostResource::MakeInstanceOnly(instance))); |
| 79 if (!object->Init(sample_rate, sample_frame_count)) | 76 if (!object->Init(sample_rate, sample_frame_count)) |
| 80 return 0; | 77 return 0; |
| 81 return object->GetReference(); | 78 return object->GetReference(); |
| 82 } | 79 } |
| 83 | 80 |
| 84 bool PPB_AudioConfig_Proxy::OnMessageReceived(const IPC::Message& msg) { | 81 bool PPB_AudioConfig_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 85 // There are no IPC messages for this interface. | 82 // There are no IPC messages for this interface. |
| 86 NOTREACHED(); | 83 NOTREACHED(); |
| 87 return false; | 84 return false; |
| 88 } | 85 } |
| 89 | 86 |
| 90 } // namespace proxy | 87 } // namespace proxy |
| 91 } // namespace pp | 88 } // namespace ppapi |
| OLD | NEW |