Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3164)

Side by Side Diff: components/copresence/handlers/directive_handler.cc

Issue 419073002: Add the copresence DirectiveHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "components/copresence/handlers/directive_handler.h"
6
7 #include "base/time/time.h"
8 #include "components/copresence/handlers/audio/audio_directive_handler.h"
9 #include "components/copresence/proto/data.pb.h"
10
11 namespace copresence {
12
13 DirectiveHandler::DirectiveHandler(
14 const AudioRecorder::DecodeSamplesCallback& decode_cb,
15 const AudioDirectiveList::EncodeTokenCallback& encode_cb)
16 : audio_handler_(new AudioDirectiveHandler(decode_cb, encode_cb)) {
17 audio_handler_->Initialize();
18 }
19
20 DirectiveHandler::~DirectiveHandler() {
21 }
22
23 void DirectiveHandler::AddDirective(const Directive& directive) {
24 // We only handle Token directives; wifi/ble requests aren't implemented.
25 DCHECK_EQ(directive.instruction_type(), TOKEN);
26
27 const TokenInstruction& ti = directive.token_instruction();
28 // We currently only support audio.
29 DCHECK_EQ(ti.medium(), AUDIO_ULTRASOUND_PASSBAND);
30 audio_handler_->AddInstruction(
31 ti, base::TimeDelta::FromMilliseconds(directive.ttl_millis()));
32 }
33
34 void DirectiveHandler::RemoveDirectives(const std::string& /* op_id */) {
35 // TODO(rkc): Forward the remove directive call to all the directive handlers.
36 }
37
38 } // namespace copresence
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698