| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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), |
| 63 string_as_array(¶ms->samples), | 63 string_as_array(¶ms->samples), |
| 64 params->samples.size()); | 64 params->samples.size()); |
| 65 | 65 |
| 66 GetWhispernetClient()->GetSamplesCallback().Run( | 66 GetWhispernetClient()->GetSamplesCallback().Run( |
| 67 params->token.token, | |
| 68 params->token.audible ? copresence::AUDIBLE : copresence::INAUDIBLE, | 67 params->token.audible ? copresence::AUDIBLE : copresence::INAUDIBLE, |
| 69 samples); | 68 params->token.token, samples); |
| 70 return RespondNow(NoArguments()); | 69 return RespondNow(NoArguments()); |
| 71 } | 70 } |
| 72 | 71 |
| 73 // CopresenceSendDetectFunction implementation: | 72 // CopresenceSendDetectFunction implementation: |
| 74 ExtensionFunction::ResponseAction CopresencePrivateSendDetectFunction::Run() { | 73 ExtensionFunction::ResponseAction CopresencePrivateSendDetectFunction::Run() { |
| 75 if (!GetWhispernetClient() || | 74 if (!GetWhispernetClient() || |
| 76 GetWhispernetClient()->GetDetectBroadcastCallback().is_null()) { | 75 GetWhispernetClient()->GetDetectBroadcastCallback().is_null()) { |
| 77 return RespondNow(NoArguments()); | 76 return RespondNow(NoArguments()); |
| 78 } | 77 } |
| 79 | 78 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 95 | 94 |
| 96 scoped_ptr<api::copresence_private::SendInitialized::Params> params( | 95 scoped_ptr<api::copresence_private::SendInitialized::Params> params( |
| 97 api::copresence_private::SendInitialized::Params::Create(*args_)); | 96 api::copresence_private::SendInitialized::Params::Create(*args_)); |
| 98 EXTENSION_FUNCTION_VALIDATE(params.get()); | 97 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 99 | 98 |
| 100 GetWhispernetClient()->GetInitializedCallback().Run(params->success); | 99 GetWhispernetClient()->GetInitializedCallback().Run(params->success); |
| 101 return RespondNow(NoArguments()); | 100 return RespondNow(NoArguments()); |
| 102 } | 101 } |
| 103 | 102 |
| 104 } // namespace extensions | 103 } // namespace extensions |
| OLD | NEW |