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

Side by Side Diff: components/copresence/rpc/rpc_handler.cc

Issue 453793002: Add audible support to the copresence API. (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
« no previous file with comments | « components/copresence/rpc/rpc_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 if (broadcast_only) 134 if (broadcast_only)
135 return BROADCAST_ONLY; 135 return BROADCAST_ONLY;
136 if (scan_only) 136 if (scan_only)
137 return SCAN_ONLY; 137 return SCAN_ONLY;
138 138
139 // If nothing else is specified, default to both broadcast and scan. 139 // If nothing else is specified, default to both broadcast and scan.
140 return BROADCAST_AND_SCAN; 140 return BROADCAST_AND_SCAN;
141 } 141 }
142 142
143 // TODO(rkc): Fix this hack once the server supports setting strategies per
144 // operation.
145 bool ExtractIsAudibleStrategy(const ReportRequest& request) {
146 if (request.has_manage_messages_request()) {
147 const RepeatedPtrField<PublishedMessage> messages =
148 request.manage_messages_request().message_to_publish();
149 for (int i = 0; i < messages.size(); ++i) {
150 const PublishedMessage& msg = messages.Get(i);
151 if (msg.has_token_exchange_strategy() &&
152 msg.token_exchange_strategy().has_use_audible() &&
153 msg.token_exchange_strategy().use_audible()) {
154 return true;
155 }
156 }
157 }
158 return false;
159 }
160
143 scoped_ptr<DeviceState> GetDeviceCapabilities(const ReportRequest& request) { 161 scoped_ptr<DeviceState> GetDeviceCapabilities(const ReportRequest& request) {
144 scoped_ptr<DeviceState> state(new DeviceState); 162 scoped_ptr<DeviceState> state(new DeviceState);
145 163
146 // TODO(ckehoe): Currently this code causes a linker error on Windows. 164 // TODO(ckehoe): Currently this code causes a linker error on Windows.
147 #ifndef OS_WIN 165 #ifndef OS_WIN
148 TokenTechnology* token_technology = 166 TokenTechnology* token_technology =
149 state->mutable_capabilities()->add_token_technology(); 167 state->mutable_capabilities()->add_token_technology();
150 token_technology->set_medium(AUDIO_ULTRASOUND_PASSBAND); 168 token_technology->set_medium(AUDIO_ULTRASOUND_PASSBAND);
169 if (ExtractIsAudibleStrategy(request))
170 token_technology->set_medium(AUDIO_AUDIBLE_DTMF);
151 171
152 BroadcastScanConfiguration config = 172 BroadcastScanConfiguration config =
153 ExtractTokenExchangeStrategy(request); 173 ExtractTokenExchangeStrategy(request);
154 if (config == BROADCAST_ONLY || config == BROADCAST_AND_SCAN) 174 if (config == BROADCAST_ONLY || config == BROADCAST_AND_SCAN)
155 token_technology->add_instruction_type(TRANSMIT); 175 token_technology->add_instruction_type(TRANSMIT);
156 if (config == SCAN_ONLY || config == BROADCAST_AND_SCAN) 176 if (config == SCAN_ONLY || config == BROADCAST_AND_SCAN)
157 token_technology->add_instruction_type(RECEIVE); 177 token_technology->add_instruction_type(RECEIVE);
158 #endif 178 #endif
159 179
160 return state.Pass(); 180 return state.Pass();
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 copresence_server_host, 492 copresence_server_host,
473 rpc_name, 493 rpc_name,
474 tracing_token, 494 tracing_token,
475 *request_proto); 495 *request_proto);
476 http_post->Start(base::Bind(callback, http_post)); 496 http_post->Start(base::Bind(callback, http_post));
477 pending_posts_.insert(http_post); 497 pending_posts_.insert(http_post);
478 } 498 }
479 499
480 void RpcHandler::AudioDirectiveListToWhispernetConnector( 500 void RpcHandler::AudioDirectiveListToWhispernetConnector(
481 const std::string& token, 501 const std::string& token,
502 bool audible,
482 const WhispernetClient::SamplesCallback& samples_callback) { 503 const WhispernetClient::SamplesCallback& samples_callback) {
483 WhispernetClient* whispernet_client = delegate_->GetWhispernetClient(); 504 WhispernetClient* whispernet_client = delegate_->GetWhispernetClient();
484 if (whispernet_client) { 505 if (whispernet_client) {
485 whispernet_client->RegisterSamplesCallback(samples_callback); 506 whispernet_client->RegisterSamplesCallback(samples_callback);
486 whispernet_client->EncodeToken(token, false); 507 whispernet_client->EncodeToken(token, audible);
487 } 508 }
488 } 509 }
489 510
490 } // namespace copresence 511 } // namespace copresence
OLDNEW
« no previous file with comments | « components/copresence/rpc/rpc_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698