Index: components/copresence/handlers/directive_handler.cc |
diff --git a/components/copresence/handlers/directive_handler.cc b/components/copresence/handlers/directive_handler.cc |
index a7ca573ed4c13e901e1e535eb172d4a26fc0cda4..e76dde6fed26116274c1e57ef3403717f132d058 100644 |
--- a/components/copresence/handlers/directive_handler.cc |
+++ b/components/copresence/handlers/directive_handler.cc |
@@ -14,7 +14,7 @@ DirectiveHandler::DirectiveHandler() {} |
void DirectiveHandler::Initialize( |
const AudioRecorder::DecodeSamplesCallback& decode_cb, |
- const AudioDirectiveList::EncodeTokenCallback& encode_cb) { |
+ const AudioDirectiveHandler::EncodeTokenCallback& encode_cb) { |
audio_handler_.reset(new AudioDirectiveHandler(decode_cb, encode_cb)); |
audio_handler_->Initialize(); |
} |
@@ -26,6 +26,16 @@ void DirectiveHandler::AddDirective(const Directive& directive) { |
// We only handle Token directives; wifi/ble requests aren't implemented. |
DCHECK_EQ(directive.instruction_type(), TOKEN); |
+ std::string op_id; |
+ if (directive.has_published_message_id()) { |
+ op_id = directive.published_message_id(); |
+ } else if (directive.has_subscription_id()) { |
+ op_id = directive.subscription_id(); |
+ } else { |
+ NOTREACHED() << "No operation associated with directive!"; |
+ return; |
+ } |
+ |
const TokenInstruction& ti = directive.token_instruction(); |
DCHECK(audio_handler_.get()) << "Clients must call Initialize() before " |
<< "any other DirectiveHandler methods."; |
@@ -33,14 +43,22 @@ void DirectiveHandler::AddDirective(const Directive& directive) { |
if (ti.medium() == AUDIO_ULTRASOUND_PASSBAND || |
ti.medium() == AUDIO_AUDIBLE_DTMF) { |
audio_handler_->AddInstruction( |
- ti, base::TimeDelta::FromMilliseconds(directive.ttl_millis())); |
+ ti, op_id, 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. |
+void DirectiveHandler::RemoveDirectives(const std::string& op_id) { |
DCHECK(audio_handler_.get()) << "Clients must call Initialize() before " |
<< "any other DirectiveHandler methods."; |
+ audio_handler_->RemoveInstructions(op_id); |
+} |
+ |
+const std::string& DirectiveHandler::CurrentAudibleToken() const { |
+ return audio_handler_->PlayingAudibleToken(); |
+} |
+ |
+const std::string& DirectiveHandler::CurrentInaudibleToken() const { |
+ return audio_handler_->PlayingInaudibleToken(); |
} |
} // namespace copresence |