Chromium Code Reviews| 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 "components/copresence/test/stub_whispernet_client.h" | 5 #include "components/copresence/test/stub_whispernet_client.h" |
| 6 | 6 |
| 7 #include "components/copresence/test/audio_test_support.h" | |
| 8 #include "media/base/audio_bus.h" | |
| 9 | |
| 7 namespace copresence { | 10 namespace copresence { |
| 8 | 11 |
| 9 WhispernetClient::TokensCallback StubWhispernetClient::GetTokensCallback() { | 12 StubWhispernetClient::StubWhispernetClient() { |
| 10 return TokensCallback(); | |
| 11 } | 13 } |
| 12 | 14 |
| 13 WhispernetClient::SamplesCallback StubWhispernetClient::GetSamplesCallback() { | 15 StubWhispernetClient::~StubWhispernetClient() { |
| 14 return SamplesCallback(); | |
| 15 } | 16 } |
| 16 | 17 |
| 17 WhispernetClient::SuccessCallback | 18 void StubWhispernetClient::EncodeToken(const std::string& token, |
| 18 StubWhispernetClient::GetDetectBroadcastCallback() { | 19 AudioType type) { |
| 20 if (!samples_cb_.is_null()) | |
| 21 samples_cb_.Run(type, token, CreateRandomAudioRefCounted(0x123, 1, 0x321)); | |
|
Charlie
2014/11/06 17:28:22
These samples can get passed into the constructor,
rkc
2014/11/06 19:58:24
Done.
| |
| 22 } | |
| 23 | |
| 24 void StubWhispernetClient::DecodeSamples(AudioType type, | |
| 25 const std::string& samples) { | |
| 26 if (!tokens_cb_.is_null()) { | |
| 27 std::vector<AudioToken> tokens; | |
|
Charlie
2014/11/06 17:28:22
Pass these into the constructor instead of hardcod
rkc
2014/11/06 19:58:24
Done.
| |
| 28 tokens.push_back(AudioToken("abcdef", true)); | |
| 29 tokens.push_back(AudioToken("123456", false)); | |
| 30 tokens_cb_.Run(tokens); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 void StubWhispernetClient::RegisterTokensCallback( | |
| 35 const TokensCallback& tokens_cb) { | |
| 36 tokens_cb_ = tokens_cb; | |
| 37 } | |
| 38 | |
| 39 void StubWhispernetClient::RegisterSamplesCallback( | |
| 40 const SamplesCallback& samples_cb) { | |
| 41 samples_cb_ = samples_cb; | |
| 42 } | |
| 43 | |
| 44 TokensCallback StubWhispernetClient::GetTokensCallback() { | |
| 45 return tokens_cb_; | |
| 46 } | |
| 47 | |
| 48 SamplesCallback StubWhispernetClient::GetSamplesCallback() { | |
| 49 return samples_cb_; | |
| 50 } | |
| 51 | |
| 52 SuccessCallback StubWhispernetClient::GetDetectBroadcastCallback() { | |
| 19 return SuccessCallback(); | 53 return SuccessCallback(); |
| 20 } | 54 } |
| 21 | 55 |
| 22 WhispernetClient::SuccessCallback | 56 SuccessCallback StubWhispernetClient::GetInitializedCallback() { |
| 23 StubWhispernetClient::GetInitializedCallback() { | |
| 24 return SuccessCallback(); | 57 return SuccessCallback(); |
| 25 } | 58 } |
| 26 | 59 |
| 27 } // namespace copresence | 60 } // namespace copresence |
| OLD | NEW |