| 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 #ifndef CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ |
| 6 #define CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ | 6 #define CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace media { | 27 namespace media { |
| 28 class AudioBusRefCounted; | 28 class AudioBusRefCounted; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // This class is responsible for communication with our ledger_proxy extension | 31 // This class is responsible for communication with our ledger_proxy extension |
| 32 // that talks to the whispernet audio library. | 32 // that talks to the whispernet audio library. |
| 33 class ChromeWhispernetClient : public copresence::WhispernetClient { | 33 class ChromeWhispernetClient : public copresence::WhispernetClient { |
| 34 public: | 34 public: |
| 35 // The browser context needs to outlive this class. | 35 // The browser context needs to outlive this class. |
| 36 explicit ChromeWhispernetClient(content::BrowserContext* browser_context); | 36 explicit ChromeWhispernetClient(content::BrowserContext* browser_context); |
| 37 virtual ~ChromeWhispernetClient(); | 37 ~ChromeWhispernetClient() override; |
| 38 | 38 |
| 39 // WhispernetClient overrides: | 39 // WhispernetClient overrides: |
| 40 virtual void Initialize(const SuccessCallback& init_callback) override; | 40 void Initialize(const SuccessCallback& init_callback) override; |
| 41 virtual void Shutdown() override; | 41 void Shutdown() override; |
| 42 | 42 |
| 43 virtual void EncodeToken(const std::string& token, bool audible) override; | 43 void EncodeToken(const std::string& token, bool audible) override; |
| 44 virtual void DecodeSamples(const std::string& samples) override; | 44 void DecodeSamples(const std::string& samples) override; |
| 45 virtual void DetectBroadcast() override; | 45 void DetectBroadcast() override; |
| 46 | 46 |
| 47 virtual void RegisterTokensCallback( | 47 void RegisterTokensCallback(const TokensCallback& tokens_callback) override; |
| 48 const TokensCallback& tokens_callback) override; | 48 void RegisterSamplesCallback( |
| 49 virtual void RegisterSamplesCallback( | |
| 50 const SamplesCallback& samples_callback) override; | 49 const SamplesCallback& samples_callback) override; |
| 51 virtual void RegisterDetectBroadcastCallback( | 50 void RegisterDetectBroadcastCallback( |
| 52 const SuccessCallback& db_callback) override; | 51 const SuccessCallback& db_callback) override; |
| 53 | 52 |
| 54 virtual TokensCallback GetTokensCallback() override; | 53 TokensCallback GetTokensCallback() override; |
| 55 virtual SamplesCallback GetSamplesCallback() override; | 54 SamplesCallback GetSamplesCallback() override; |
| 56 virtual SuccessCallback GetDetectBroadcastCallback() override; | 55 SuccessCallback GetDetectBroadcastCallback() override; |
| 57 virtual SuccessCallback GetInitializedCallback() override; | 56 SuccessCallback GetInitializedCallback() override; |
| 58 | 57 |
| 59 static const char kWhispernetProxyExtensionId[]; | 58 static const char kWhispernetProxyExtensionId[]; |
| 60 | 59 |
| 61 private: | 60 private: |
| 62 // Fire an event to initialize whispernet with the given parameters. | 61 // Fire an event to initialize whispernet with the given parameters. |
| 63 void InitializeWhispernet( | 62 void InitializeWhispernet( |
| 64 const extensions::api::copresence_private::AudioParameters& params); | 63 const extensions::api::copresence_private::AudioParameters& params); |
| 65 | 64 |
| 66 // This gets called twice; once when the proxy extension loads, the second | 65 // This gets called twice; once when the proxy extension loads, the second |
| 67 // time when we have initialized the proxy extension's encoder and decoder. | 66 // time when we have initialized the proxy extension's encoder and decoder. |
| 68 void OnExtensionLoaded(bool success); | 67 void OnExtensionLoaded(bool success); |
| 69 | 68 |
| 70 content::BrowserContext* browser_context_; | 69 content::BrowserContext* browser_context_; |
| 71 | 70 |
| 72 SuccessCallback extension_loaded_callback_; | 71 SuccessCallback extension_loaded_callback_; |
| 73 SuccessCallback init_callback_; | 72 SuccessCallback init_callback_; |
| 74 | 73 |
| 75 TokensCallback tokens_callback_; | 74 TokensCallback tokens_callback_; |
| 76 SamplesCallback samples_callback_; | 75 SamplesCallback samples_callback_; |
| 77 SuccessCallback db_callback_; | 76 SuccessCallback db_callback_; |
| 78 | 77 |
| 79 bool extension_loaded_; | 78 bool extension_loaded_; |
| 80 | 79 |
| 81 DISALLOW_COPY_AND_ASSIGN(ChromeWhispernetClient); | 80 DISALLOW_COPY_AND_ASSIGN(ChromeWhispernetClient); |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 #endif // CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ | 83 #endif // CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ |
| OLD | NEW |