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

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 }
18
19 DirectiveHandler::~DirectiveHandler() {
20 }
21
22 void DirectiveHandler::AddDirective(const Directive& directive) {
23 // We only handle Token directives; wifi/ble requests aren't implemented.
24 DCHECK_EQ(directive.instruction_type(), TOKEN);
25
26 const TokenInstruction& ti = directive.token_instruction();
27 // We currently only support audio.
28 DCHECK_EQ(ti.medium(), AUDIO_ULTRASOUND_PASSBAND);
29 audio_handler_->AddInstruction(
30 ti, base::TimeDelta::FromMilliseconds(directive.ttl_millis()));
31 }
32
33 void DirectiveHandler::RemoveDirectives(const std::string& /* op_id */) {
34 // TODO(rkc): Forward the remove directive call to all the directive handlers.
35 }
36
37 } // namespace copresence
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698