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

Unified Diff: components/copresence/rpc/rpc_handler.cc

Issue 685983007: RpcHandlerTest cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating TODO Created 6 years, 1 month 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
« no previous file with comments | « components/copresence/rpc/rpc_handler.h ('k') | components/copresence/rpc/rpc_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/copresence/rpc/rpc_handler.cc
diff --git a/components/copresence/rpc/rpc_handler.cc b/components/copresence/rpc/rpc_handler.cc
index 07b28a423882a798646e2b883bae6f95fe36ac2b..d82159f2454d3174e3c6b37787b843101904b085 100644
--- a/components/copresence/rpc/rpc_handler.cc
+++ b/components/copresence/rpc/rpc_handler.cc
@@ -153,16 +153,21 @@ void AddTokenToRequest(const AudioToken& token, ReportRequest* request) {
// Public methods
RpcHandler::RpcHandler(CopresenceDelegate* delegate,
- DirectiveHandler* directive_handler)
+ DirectiveHandler* directive_handler,
+ const PostCallback& server_post_callback)
: delegate_(delegate),
directive_handler_(directive_handler),
invalid_audio_token_cache_(
base::TimeDelta::FromMilliseconds(kInvalidTokenExpiryTimeMs),
kMaxInvalidTokens),
- server_post_callback_(base::Bind(&RpcHandler::SendHttpPost,
- base::Unretained(this))) {
+ server_post_callback_(server_post_callback) {
DCHECK(delegate_);
DCHECK(directive_handler_);
+
+ if (server_post_callback_.is_null()) {
+ server_post_callback_ =
+ base::Bind(&RpcHandler::SendHttpPost, base::Unretained(this));
+ }
}
RpcHandler::~RpcHandler() {
@@ -170,13 +175,11 @@ RpcHandler::~RpcHandler() {
delete post;
}
- if (delegate_->GetWhispernetClient()) {
- // TODO(ckehoe): Use CancelableCallbacks instead.
- delegate_->GetWhispernetClient()->RegisterTokensCallback(
- WhispernetClient::TokensCallback());
- delegate_->GetWhispernetClient()->RegisterSamplesCallback(
- WhispernetClient::SamplesCallback());
- }
+ // TODO(ckehoe): Register and cancel these callbacks in the same class.
+ delegate_->GetWhispernetClient()->RegisterTokensCallback(
+ WhispernetClient::TokensCallback());
+ delegate_->GetWhispernetClient()->RegisterSamplesCallback(
+ WhispernetClient::SamplesCallback());
}
void RpcHandler::RegisterForToken(const std::string& auth_token,
« no previous file with comments | « components/copresence/rpc/rpc_handler.h ('k') | components/copresence/rpc/rpc_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698