| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/extensions/api/copresence_private/copresence_private_ap
i.h" | 5 #include "chrome/browser/extensions/api/copresence_private/copresence_private_ap
i.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 | 53 |
| 54 scoped_ptr<api::copresence_private::SendSamples::Params> params( | 54 scoped_ptr<api::copresence_private::SendSamples::Params> params( |
| 55 api::copresence_private::SendSamples::Params::Create(*args_)); | 55 api::copresence_private::SendSamples::Params::Create(*args_)); |
| 56 EXTENSION_FUNCTION_VALIDATE(params.get()); | 56 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 57 | 57 |
| 58 scoped_refptr<media::AudioBusRefCounted> samples = | 58 scoped_refptr<media::AudioBusRefCounted> samples = |
| 59 media::AudioBusRefCounted::Create(1, | 59 media::AudioBusRefCounted::Create(1, |
| 60 params->samples.size() / sizeof(float)); | 60 params->samples.size() / sizeof(float)); |
| 61 | 61 |
| 62 memcpy(samples->channel(0), | 62 memcpy(samples->channel(0), vector_as_array(¶ms->samples), |
| 63 string_as_array(¶ms->samples), | |
| 64 params->samples.size()); | 63 params->samples.size()); |
| 65 | 64 |
| 66 GetWhispernetClient()->GetSamplesCallback().Run( | 65 GetWhispernetClient()->GetSamplesCallback().Run( |
| 67 params->token.audible ? copresence::AUDIBLE : copresence::INAUDIBLE, | 66 params->token.audible ? copresence::AUDIBLE : copresence::INAUDIBLE, |
| 68 params->token.token, samples); | 67 params->token.token, samples); |
| 69 return RespondNow(NoArguments()); | 68 return RespondNow(NoArguments()); |
| 70 } | 69 } |
| 71 | 70 |
| 72 // CopresenceSendDetectFunction implementation: | 71 // CopresenceSendDetectFunction implementation: |
| 73 ExtensionFunction::ResponseAction CopresencePrivateSendDetectFunction::Run() { | 72 ExtensionFunction::ResponseAction CopresencePrivateSendDetectFunction::Run() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 94 | 93 |
| 95 scoped_ptr<api::copresence_private::SendInitialized::Params> params( | 94 scoped_ptr<api::copresence_private::SendInitialized::Params> params( |
| 96 api::copresence_private::SendInitialized::Params::Create(*args_)); | 95 api::copresence_private::SendInitialized::Params::Create(*args_)); |
| 97 EXTENSION_FUNCTION_VALIDATE(params.get()); | 96 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 98 | 97 |
| 99 GetWhispernetClient()->GetInitializedCallback().Run(params->success); | 98 GetWhispernetClient()->GetInitializedCallback().Run(params->success); |
| 100 return RespondNow(NoArguments()); | 99 return RespondNow(NoArguments()); |
| 101 } | 100 } |
| 102 | 101 |
| 103 } // namespace extensions | 102 } // namespace extensions |
| OLD | NEW |