Index: components/copresence/handlers/audio/audio_directive_handler_impl.h |
diff --git a/components/copresence/handlers/audio/audio_directive_handler.h b/components/copresence/handlers/audio/audio_directive_handler_impl.h |
similarity index 62% |
copy from components/copresence/handlers/audio/audio_directive_handler.h |
copy to components/copresence/handlers/audio/audio_directive_handler_impl.h |
index fa690b62535bf9aa6721f160495a52ed95e14668..37b172f639a3eacd3cf143e85461f28a472e334a 100644 |
--- a/components/copresence/handlers/audio/audio_directive_handler.h |
+++ b/components/copresence/handlers/audio/audio_directive_handler_impl.h |
@@ -2,21 +2,19 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_H_ |
-#define COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_H_ |
+#ifndef COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ |
+#define COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ |
#include <string> |
-#include "base/basictypes.h" |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
-#include "base/time/time.h" |
-#include "components/copresence/handlers/audio/audio_directive_list.h" |
-#include "components/copresence/mediums/audio/audio_manager.h" |
-#include "components/copresence/proto/data.pb.h" |
+#include "base/memory/scoped_vector.h" |
+#include "components/copresence/handlers/audio/audio_directive_handler.h" |
namespace base { |
+class TimeTicks; |
class Timer; |
} |
@@ -26,6 +24,7 @@ class AudioBusRefCounted; |
namespace copresence { |
+class AudioDirectiveList; |
class TickClockRefCounted; |
// The AudioDirectiveHandler handles audio transmit and receive instructions. |
@@ -35,60 +34,55 @@ class TickClockRefCounted; |
// out token encoding to a separate class, or allowing whispernet to have |
// multiple callbacks for encoded tokens being sent back and have two versions |
// of this class. |
-class AudioDirectiveHandler final { |
+class AudioDirectiveHandlerImpl final : public AudioDirectiveHandler { |
public: |
- AudioDirectiveHandler(); |
- ~AudioDirectiveHandler(); |
+ AudioDirectiveHandlerImpl(); |
+ AudioDirectiveHandlerImpl(scoped_ptr<AudioManager> audio_manager, |
+ scoped_ptr<base::Timer> timer, |
+ const scoped_refptr<TickClockRefCounted>& clock); |
+ |
+ ~AudioDirectiveHandlerImpl(); |
// Do not use this class before calling this. |
void Initialize(const AudioManager::DecodeSamplesCallback& decode_cb, |
- const AudioManager::EncodeTokenCallback& encode_cb); |
+ const AudioManager::EncodeTokenCallback& encode_cb) override; |
// Adds an instruction to our handler. The instruction will execute and be |
// removed after the ttl expires. |
void AddInstruction(const copresence::TokenInstruction& instruction, |
const std::string& op_id, |
- base::TimeDelta ttl_ms); |
+ base::TimeDelta ttl_ms) override; |
// Removes all instructions associated with this operation id. |
- void RemoveInstructions(const std::string& op_id); |
+ void RemoveInstructions(const std::string& op_id) override; |
// Returns the currently playing token. |
- const std::string PlayingToken(AudioType type) const; |
- |
- // The manager being passed in needs to be uninitialized. |
- void set_audio_manager_for_testing(scoped_ptr<AudioManager> manager) { |
- audio_manager_ = manager.Pass(); |
- } |
- |
- void set_clock_for_testing(const scoped_refptr<TickClockRefCounted>& clock); |
- void set_timer_for_testing(scoped_ptr<base::Timer> timer); |
+ const std::string PlayingToken(AudioType type) const override; |
private: |
- // Processes the next active instruction, updating our audio manager state |
- // accordingly. |
+ // Processes the next active instruction, |
+ // updating our audio manager state accordingly. |
void ProcessNextInstruction(); |
// Returns the time that an instruction expires at. This will always return |
// the earliest expiry time among all the active receive and transmit |
- // instructions. In case we don't have any active instructions, this method |
- // returns false. |
+ // instructions. If we don't have any active instructions, returns false. |
bool GetNextInstructionExpiry(base::TimeTicks* next_event); |
scoped_ptr<AudioManager> audio_manager_; |
- // Audible and inaudible lists. |
- // AUDIBLE = 0, INAUDIBLE = 1 (see copresence_constants.h). |
- AudioDirectiveList transmits_list_[2]; |
- AudioDirectiveList receives_list_[2]; |
- |
scoped_ptr<base::Timer> audio_event_timer_; |
- |
scoped_refptr<TickClockRefCounted> clock_; |
- DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandler); |
+ // Lists of transmits and receives, for both audible and inaudible tokens. |
+ // AUDIBLE = element 0, INAUDIBLE = element 1 (see copresence_constants.h). |
+ ScopedVector<AudioDirectiveList> transmits_lists_; |
+ ScopedVector<AudioDirectiveList> receives_lists_; |
+ |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AudioDirectiveHandlerImpl); |
}; |
} // namespace copresence |
-#endif // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_H_ |
+#endif // COMPONENTS_COPRESENCE_HANDLERS_AUDIO_AUDIO_DIRECTIVE_HANDLER_IMPL_H_ |