Index: components/copresence/handlers/directive_handler.cc |
diff --git a/components/copresence/handlers/directive_handler.cc b/components/copresence/handlers/directive_handler.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..79ddf8fbe243a582cb861272304651226224a6a2 |
--- /dev/null |
+++ b/components/copresence/handlers/directive_handler.cc |
@@ -0,0 +1,38 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/copresence/handlers/directive_handler.h" |
+ |
+#include "base/time/time.h" |
+#include "components/copresence/handlers/audio/audio_directive_handler.h" |
+#include "components/copresence/proto/data.pb.h" |
+ |
+namespace copresence { |
+ |
+DirectiveHandler::DirectiveHandler( |
+ const AudioRecorder::DecodeSamplesCallback& decode_cb, |
+ const AudioDirectiveList::EncodeTokenCallback& encode_cb) |
+ : audio_handler_(new AudioDirectiveHandler(decode_cb, encode_cb)) { |
+ audio_handler_->Initialize(); |
+} |
+ |
+DirectiveHandler::~DirectiveHandler() { |
+} |
+ |
+void DirectiveHandler::AddDirective(const Directive& directive) { |
+ // We only handle Token directives; wifi/ble requests aren't implemented. |
+ DCHECK_EQ(directive.instruction_type(), TOKEN); |
+ |
+ const TokenInstruction& ti = directive.token_instruction(); |
+ // We currently only support audio. |
+ DCHECK_EQ(ti.medium(), AUDIO_ULTRASOUND_PASSBAND); |
+ audio_handler_->AddInstruction( |
+ ti, base::TimeDelta::FromMilliseconds(directive.ttl_millis())); |
+} |
+ |
+void DirectiveHandler::RemoveDirectives(const std::string& /* op_id */) { |
+ // TODO(rkc): Forward the remove directive call to all the directive handlers. |
+} |
+ |
+} // namespace copresence |