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 COMPONENTS_COPRESENCE_HANDLERS_DIRECTIVE_HANDLER_IMPL_H_ | 5 #ifndef COMPONENTS_COPRESENCE_HANDLERS_DIRECTIVE_HANDLER_IMPL_H_ |
6 #define COMPONENTS_COPRESENCE_HANDLERS_DIRECTIVE_HANDLER_IMPL_H_ | 6 #define COMPONENTS_COPRESENCE_HANDLERS_DIRECTIVE_HANDLER_IMPL_H_ |
7 | 7 |
8 #include "components/copresence/handlers/directive_handler.h" | 8 #include "components/copresence/handlers/directive_handler.h" |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "components/copresence/handlers/audio/audio_directive_handler_impl.h" | 15 #include "components/copresence/handlers/audio/audio_directive_handler_impl.h" |
16 #include "components/copresence/public/copresence_constants.h" | |
17 | 16 |
18 namespace copresence { | 17 namespace copresence { |
19 | 18 |
20 // The directive handler manages transmit and receive directives. | 19 // The directive handler manages transmit and receive directives. |
21 class DirectiveHandlerImpl final : public DirectiveHandler { | 20 class DirectiveHandlerImpl final : public DirectiveHandler { |
22 public: | 21 public: |
23 explicit DirectiveHandlerImpl( | 22 explicit DirectiveHandlerImpl(scoped_ptr<AudioDirectiveHandler> |
24 const DirectivesCallback& update_directives_callback); | 23 audio_handler = make_scoped_ptr(new AudioDirectiveHandlerImpl)); |
25 DirectiveHandlerImpl( | |
26 const DirectivesCallback& update_directives_callback, | |
27 scoped_ptr<AudioDirectiveHandler> audio_handler); | |
28 ~DirectiveHandlerImpl() override; | 24 ~DirectiveHandlerImpl() override; |
29 | 25 |
30 // DirectiveHandler overrides. | 26 // DirectiveHandler overrides |
31 void Start(WhispernetClient* whispernet_client, | 27 void Start(WhispernetClient* whispernet_client, |
32 const TokensCallback& tokens_cb) override; | 28 const TokensCallback& tokens_cb) override; |
33 void AddDirective(const Directive& directive) override; | 29 void AddDirective(const Directive& directive) override; |
34 void RemoveDirectives(const std::string& op_id) override; | 30 void RemoveDirectives(const std::string& op_id) override; |
35 const std::string GetCurrentAudioToken(AudioType type) const override; | 31 const std::string GetCurrentAudioToken(AudioType type) const override; |
36 bool IsAudioTokenHeard(AudioType type) const override; | 32 bool IsAudioTokenHeard(AudioType type) const override; |
37 | 33 |
38 private: | 34 private: |
39 // Starts actually running a directive. | 35 // Starts actually running a directive. |
40 void StartDirective(const std::string& op_id, const Directive& directive); | 36 void StartDirective(const std::string& op_id, const Directive& directive); |
41 | 37 |
42 scoped_ptr<AudioDirectiveHandler> audio_handler_; | 38 scoped_ptr<AudioDirectiveHandler> audio_handler_; |
43 std::map<std::string, std::vector<Directive>> pending_directives_; | 39 std::map<std::string, std::vector<Directive>> pending_directives_; |
44 | 40 |
45 bool is_started_; | 41 bool is_started_; |
46 | 42 |
47 DISALLOW_COPY_AND_ASSIGN(DirectiveHandlerImpl); | 43 DISALLOW_COPY_AND_ASSIGN(DirectiveHandlerImpl); |
48 }; | 44 }; |
49 | 45 |
50 } // namespace copresence | 46 } // namespace copresence |
51 | 47 |
52 #endif // COMPONENTS_COPRESENCE_HANDLERS_DIRECTIVE_HANDLER_IMPL_H_ | 48 #endif // COMPONENTS_COPRESENCE_HANDLERS_DIRECTIVE_HANDLER_IMPL_H_ |
OLD | NEW |