Mac: Fix performance issues with remote CoreAnimation
[chromium-blink-merge.git] / components / copresence / test / stub_whispernet_client.cc
blobee67f9b0f53746718d0e36596f16f5ed9154d5b4
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
3 // found in the LICENSE file.
5 #include "components/copresence/test/stub_whispernet_client.h"
7 #include "components/copresence/test/audio_test_support.h"
8 #include "media/base/audio_bus.h"
10 namespace copresence {
12 StubWhispernetClient::StubWhispernetClient(bool complete_initialization)
13 : complete_initialization_(complete_initialization) {
14 tokens_.push_back(AudioToken("abcdef", true));
15 tokens_.push_back(AudioToken("123456", false));
16 samples_ = CreateRandomAudioRefCounted(0x123, 1, 0x321);
19 StubWhispernetClient::~StubWhispernetClient() {
22 void StubWhispernetClient::Initialize(const SuccessCallback& init_callback) {
23 // TODO(ckehoe): Consider updating tests to use this.
24 if (complete_initialization_)
25 init_callback.Run(true);
28 void StubWhispernetClient::EncodeToken(const std::string& token,
29 AudioType type) {
30 if (!samples_cb_.is_null())
31 samples_cb_.Run(type, token, samples_);
34 void StubWhispernetClient::DecodeSamples(AudioType type,
35 const std::string& samples) {
36 if (!tokens_cb_.is_null())
37 tokens_cb_.Run(tokens_);
40 void StubWhispernetClient::RegisterTokensCallback(
41 const TokensCallback& tokens_cb) {
42 tokens_cb_ = tokens_cb;
45 void StubWhispernetClient::RegisterSamplesCallback(
46 const SamplesCallback& samples_cb) {
47 samples_cb_ = samples_cb;
50 TokensCallback StubWhispernetClient::GetTokensCallback() {
51 return tokens_cb_;
54 SamplesCallback StubWhispernetClient::GetSamplesCallback() {
55 return samples_cb_;
58 SuccessCallback StubWhispernetClient::GetDetectBroadcastCallback() {
59 return SuccessCallback();
62 SuccessCallback StubWhispernetClient::GetInitializedCallback() {
63 return SuccessCallback();
66 } // namespace copresence