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

Unified Diff: components/copresence/handlers/directive_handler.cc

Issue 433283002: Adding the Copresence RpcHandler and HttpPost helper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@directive-handler
Patch Set: First round of review fixes 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 side-by-side diff with in-line comments
Download patch
Index: components/copresence/handlers/directive_handler.cc
diff --git a/components/copresence/handlers/directive_handler.cc b/components/copresence/handlers/directive_handler.cc
index 79ddf8fbe243a582cb861272304651226224a6a2..eefcc484d437179c6200cc079360dd07cff2abfd 100644
--- a/components/copresence/handlers/directive_handler.cc
+++ b/components/copresence/handlers/directive_handler.cc
@@ -1,6 +1,6 @@
// 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.
+// 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"
@@ -10,10 +10,12 @@
namespace copresence {
-DirectiveHandler::DirectiveHandler(
+DirectiveHandler::DirectiveHandler() {}
+
+void DirectiveHandler::Initialize(
const AudioRecorder::DecodeSamplesCallback& decode_cb,
- const AudioDirectiveList::EncodeTokenCallback& encode_cb)
- : audio_handler_(new AudioDirectiveHandler(decode_cb, encode_cb)) {
+ const AudioDirectiveList::EncodeTokenCallback& encode_cb) {
+ audio_handler_.reset(new AudioDirectiveHandler(decode_cb, encode_cb));
audio_handler_->Initialize();
}
@@ -27,12 +29,16 @@ void DirectiveHandler::AddDirective(const Directive& directive) {
const TokenInstruction& ti = directive.token_instruction();
// We currently only support audio.
DCHECK_EQ(ti.medium(), AUDIO_ULTRASOUND_PASSBAND);
+ DCHECK(audio_handler_.get()) << "Clients must call Initialize() before "
+ << "any other DirectiveHandler methods.";
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.
+ DCHECK(audio_handler_.get()) << "Clients must call Initialize() before "
+ << "any other DirectiveHandler methods.";
}
} // namespace copresence

Powered by Google App Engine
This is Rietveld 408576698