| 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> | |
| 10 | 9 |
| 11 #include "base/callback.h" | 10 #include "base/callback.h" |
| 12 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_vector.h" |
| 13 #include "components/copresence/public/copresence_constants.h" | 13 #include "components/copresence/public/copresence_constants.h" |
| 14 #include "components/copresence/public/whispernet_client.h" | 14 #include "components/copresence/public/whispernet_client.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class BrowserContext; | 17 class BrowserContext; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 |
| 22 struct Event; |
| 23 class EventRouter; |
| 24 |
| 21 namespace api { | 25 namespace api { |
| 22 namespace copresence_private { | 26 namespace copresence_private { |
| 23 struct AudioParameters; | 27 struct AudioParameters; |
| 24 } | 28 } |
| 25 } | 29 } |
| 26 } | 30 |
| 31 } // namespace extensions |
| 27 | 32 |
| 28 namespace media { | 33 namespace media { |
| 29 class AudioBusRefCounted; | 34 class AudioBusRefCounted; |
| 30 } | 35 } |
| 31 | 36 |
| 32 // This class is responsible for communication with our ledger_proxy extension | 37 // This class is responsible for communication with our ledger_proxy extension |
| 33 // that talks to the whispernet audio library. | 38 // that talks to the whispernet audio library. |
| 34 class ChromeWhispernetClient final : public copresence::WhispernetClient { | 39 class ChromeWhispernetClient final : public copresence::WhispernetClient { |
| 35 public: | 40 public: |
| 36 // The browser context needs to outlive this class. | 41 // The browser context needs to outlive this class. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 57 copresence::SamplesCallback GetSamplesCallback() override; | 62 copresence::SamplesCallback GetSamplesCallback() override; |
| 58 copresence::SuccessCallback GetDetectBroadcastCallback() override; | 63 copresence::SuccessCallback GetDetectBroadcastCallback() override; |
| 59 copresence::SuccessCallback GetInitializedCallback() override; | 64 copresence::SuccessCallback GetInitializedCallback() override; |
| 60 | 65 |
| 61 static const char kWhispernetProxyExtensionId[]; | 66 static const char kWhispernetProxyExtensionId[]; |
| 62 | 67 |
| 63 private: | 68 private: |
| 64 // Fire an event to configure whispernet with the given audio parameters. | 69 // Fire an event to configure whispernet with the given audio parameters. |
| 65 void AudioConfiguration(const copresence::config::AudioParamData& params); | 70 void AudioConfiguration(const copresence::config::AudioParamData& params); |
| 66 | 71 |
| 72 void SendEventIfLoaded(scoped_ptr<extensions::Event> event); |
| 73 |
| 67 // This gets called twice; once when the proxy extension loads, the second | 74 // This gets called twice; once when the proxy extension loads, the second |
| 68 // time when we have initialized the proxy extension's encoder and decoder. | 75 // time when we have initialized the proxy extension's encoder and decoder. |
| 69 void OnExtensionLoaded(bool success); | 76 void OnExtensionLoaded(bool success); |
| 70 | 77 |
| 71 content::BrowserContext* browser_context_; | 78 content::BrowserContext* const browser_context_; |
| 79 extensions::EventRouter* const event_router_; |
| 72 | 80 |
| 73 copresence::SuccessCallback extension_loaded_callback_; | 81 copresence::SuccessCallback extension_loaded_callback_; |
| 74 copresence::SuccessCallback init_callback_; | 82 copresence::SuccessCallback init_callback_; |
| 75 | 83 |
| 76 copresence::TokensCallback tokens_callback_; | 84 copresence::TokensCallback tokens_callback_; |
| 77 copresence::SamplesCallback samples_callback_; | 85 copresence::SamplesCallback samples_callback_; |
| 78 copresence::SuccessCallback db_callback_; | 86 copresence::SuccessCallback db_callback_; |
| 79 | 87 |
| 88 ScopedVector<extensions::Event> queued_events_; |
| 80 bool extension_loaded_; | 89 bool extension_loaded_; |
| 81 | 90 |
| 82 DISALLOW_COPY_AND_ASSIGN(ChromeWhispernetClient); | 91 DISALLOW_COPY_AND_ASSIGN(ChromeWhispernetClient); |
| 83 }; | 92 }; |
| 84 | 93 |
| 85 #endif // CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ | 94 #endif // CHROME_BROWSER_COPRESENCE_CHROME_WHISPERNET_CLIENT_H_ |
| OLD | NEW |