OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/copresence/rpc/rpc_handler.h" | 5 #include "components/copresence/rpc/rpc_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 // If we are unpublishing or unsubscribing, we need to stop those publish or | 266 // If we are unpublishing or unsubscribing, we need to stop those publish or |
267 // subscribes right away, we don't need to wait for the server to tell us. | 267 // subscribes right away, we don't need to wait for the server to tell us. |
268 ProcessRemovedOperations(*request); | 268 ProcessRemovedOperations(*request); |
269 | 269 |
270 request->mutable_update_signals_request()->set_allocated_state( | 270 request->mutable_update_signals_request()->set_allocated_state( |
271 GetDeviceCapabilities(*request).release()); | 271 GetDeviceCapabilities(*request).release()); |
272 | 272 |
273 AddPlayingTokens(request.get()); | 273 AddPlayingTokens(request.get()); |
274 | 274 |
| 275 // TODO(ckehoe): Currently the server supports only BROADCAST_AND_SCAN. |
| 276 // Remove this once b/16715253 is fixed. |
| 277 if (request->has_manage_messages_request()) { |
| 278 RepeatedPtrField<PublishedMessage>* messages = request |
| 279 ->mutable_manage_messages_request()->mutable_message_to_publish(); |
| 280 for (int i = 0; i < messages->size(); ++i) { |
| 281 messages->Mutable(i)->mutable_token_exchange_strategy() |
| 282 ->set_broadcast_scan_configuration(BROADCAST_AND_SCAN); |
| 283 } |
| 284 } |
| 285 if (request->has_manage_subscriptions_request()) { |
| 286 RepeatedPtrField<Subscription>* subscriptions = |
| 287 request->mutable_manage_subscriptions_request()->mutable_subscription(); |
| 288 for (int i = 0; i < subscriptions->size(); ++i) { |
| 289 subscriptions->Mutable(i)->mutable_token_exchange_strategy() |
| 290 ->set_broadcast_scan_configuration(BROADCAST_AND_SCAN); |
| 291 } |
| 292 } |
| 293 |
275 SendServerRequest(kReportRequestRpcName, | 294 SendServerRequest(kReportRequestRpcName, |
276 app_id, | 295 app_id, |
277 request.Pass(), | 296 request.Pass(), |
278 // On destruction, this request will be cancelled. | 297 // On destruction, this request will be cancelled. |
279 base::Bind(&RpcHandler::ReportResponseHandler, | 298 base::Bind(&RpcHandler::ReportResponseHandler, |
280 base::Unretained(this), | 299 base::Unretained(this), |
281 status_callback)); | 300 status_callback)); |
282 } | 301 } |
283 | 302 |
284 void RpcHandler::ReportTokens(const std::vector<AudioToken>& tokens) { | 303 void RpcHandler::ReportTokens(const std::vector<AudioToken>& tokens) { |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 bool audible, | 568 bool audible, |
550 const WhispernetClient::SamplesCallback& samples_callback) { | 569 const WhispernetClient::SamplesCallback& samples_callback) { |
551 WhispernetClient* whispernet_client = delegate_->GetWhispernetClient(); | 570 WhispernetClient* whispernet_client = delegate_->GetWhispernetClient(); |
552 if (whispernet_client) { | 571 if (whispernet_client) { |
553 whispernet_client->RegisterSamplesCallback(samples_callback); | 572 whispernet_client->RegisterSamplesCallback(samples_callback); |
554 whispernet_client->EncodeToken(token, audible); | 573 whispernet_client->EncodeToken(token, audible); |
555 } | 574 } |
556 } | 575 } |
557 | 576 |
558 } // namespace copresence | 577 } // namespace copresence |
OLD | NEW |