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