Chromium Code Reviews| Index: chrome/browser/copresence/chrome_whispernet_client.h |
| diff --git a/chrome/browser/copresence/chrome_whispernet_client.h b/chrome/browser/copresence/chrome_whispernet_client.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c32c3a4388edfe7348e584bac9d7218ac4bfa940 |
| --- /dev/null |
| +++ b/chrome/browser/copresence/chrome_whispernet_client.h |
| @@ -0,0 +1,87 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ |
| +#define CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
|
xiyuan
2014/07/31 19:22:22
nit: not used.
rkc
2014/07/31 23:12:52
Done.
|
| +#include "components/copresence/public/whispernet_client.h" |
| + |
| +namespace content { |
| +class BrowserContext; |
| +} |
| + |
| +namespace extensions { |
| +namespace api { |
| +namespace copresence_private { |
| +struct AudioParameters; |
| +} |
| +} |
| +} |
| + |
| +namespace media { |
| +class AudioBusRefCounted; |
| +} |
| + |
| +// This class is responsible for communication with our ledger_proxy extension |
| +// that talks to the whispernet audio library. |
| +class ChromeWhispernetClient : public copresence::WhispernetClient { |
| + public: |
| + // The browser context needs to outlive this class. |
| + explicit ChromeWhispernetClient(content::BrowserContext* browser_context); |
| + |
| + // WhispernetClient overrides: |
|
xiyuan
2014/07/31 19:22:22
nit: move this down to just before "Initialize"
rkc
2014/07/31 23:12:52
Done.
|
| + |
| + virtual ~ChromeWhispernetClient() OVERRIDE; |
|
xiyuan
2014/07/31 19:22:22
I don't think we need OVERRIDE for virtual dtor.
rkc
2014/07/31 23:12:52
Done.
|
| + |
| + virtual void Initialize(const SuccessCallback& init_callback) OVERRIDE; |
| + virtual void Shutdown() OVERRIDE; |
| + |
| + virtual void EncodeToken(const std::string& token) OVERRIDE; |
| + virtual void DecodeSamples(const std::string& samples) OVERRIDE; |
| + virtual void DetectBroadcast() OVERRIDE; |
| + |
| + virtual void RegisterTokensCallback( |
| + const TokensCallback& tokens_callback) OVERRIDE; |
| + virtual void RegisterSamplesCallback( |
| + const SamplesCallback& samples_callback) OVERRIDE; |
| + virtual void RegisterDetectBroadcastCallback( |
| + const SuccessCallback& db_callback) OVERRIDE; |
| + |
| + virtual TokensCallback GetTokensCallback() OVERRIDE; |
| + virtual SamplesCallback GetSamplesCallback() OVERRIDE; |
| + virtual SuccessCallback GetDetectBroadcastCallback() OVERRIDE; |
| + virtual SuccessCallback GetInitializedCallback() OVERRIDE; |
| + |
| + static const char kWhispernetProxyExtensionId[]; |
| + |
| + private: |
| + // Fire an event to initialize whispernet with the given parameters. |
| + void InitializeWhispernet( |
| + const extensions::api::copresence_private::AudioParameters& params); |
| + |
| + // This gets called twice; once when the proxy extension loads, the second |
| + // time when we have initialized the proxy extension's encoder and decoder. |
| + void OnExtensionLoaded(bool success); |
| + |
| + content::BrowserContext* browser_context_; |
| + |
| + SuccessCallback extension_loaded_callback_; |
| + SuccessCallback init_callback_; |
| + |
| + TokensCallback tokens_callback_; |
| + SamplesCallback samples_callback_; |
| + SuccessCallback db_callback_; |
| + |
| + bool extension_loaded_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ChromeWhispernetClient); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ |