Extension syncing: Introduce a NeedsSync pref
[chromium-blink-merge.git] / components / copresence / handlers / directive_handler_impl.h
blob5191e1d938f0cf34947f6cf07f7b93f134ad0e84
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_COPRESENCE_HANDLERS_DIRECTIVE_HANDLER_IMPL_H_
6 #define COMPONENTS_COPRESENCE_HANDLERS_DIRECTIVE_HANDLER_IMPL_H_
8 #include "components/copresence/handlers/directive_handler.h"
10 #include <map>
11 #include <string>
12 #include <vector>
14 #include "base/memory/scoped_ptr.h"
15 #include "components/copresence/handlers/audio/audio_directive_handler_impl.h"
16 #include "components/copresence/public/copresence_constants.h"
18 namespace copresence {
20 // The directive handler manages transmit and receive directives.
21 class DirectiveHandlerImpl final : public DirectiveHandler {
22 public:
23 DirectiveHandlerImpl();
24 explicit DirectiveHandlerImpl(
25 const DirectivesCallback& update_directives_callback);
26 DirectiveHandlerImpl(
27 scoped_ptr<AudioDirectiveHandler> audio_handler);
28 ~DirectiveHandlerImpl() override;
30 // DirectiveHandler overrides.
31 void Start(audio_modem::WhispernetClient* whispernet_client,
32 const audio_modem::TokensCallback& tokens_cb) override;
33 void AddDirective(const Directive& directive) override;
34 void RemoveDirectives(const std::string& op_id) override;
35 const std::string
36 GetCurrentAudioToken(audio_modem::AudioType type) const override;
37 bool IsAudioTokenHeard(audio_modem::AudioType type) const override;
39 private:
40 // Starts actually running a directive.
41 void StartDirective(const std::string& op_id, const Directive& directive);
43 scoped_ptr<AudioDirectiveHandler> audio_handler_;
44 std::map<std::string, std::vector<Directive>> pending_directives_;
46 bool is_started_;
48 DISALLOW_COPY_AND_ASSIGN(DirectiveHandlerImpl);
51 } // namespace copresence
53 #endif // COMPONENTS_COPRESENCE_HANDLERS_DIRECTIVE_HANDLER_IMPL_H_