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

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

Issue 514383002: Workaround until the server fully supports BroadcastScanConfiguration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2125
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | 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 72c4f906bc4a42d7789fbd9321a699c296a92278..0b60a77fa92fb53fe5e61287ec9bcd0c383d21f6 100644
--- a/components/copresence/rpc/rpc_handler.cc
+++ b/components/copresence/rpc/rpc_handler.cc
@@ -206,40 +206,6 @@ void AddTokenToRequest(ReportRequest* request, const AudioToken& token) {
signals->set_observed_time_millis(base::Time::Now().ToJsTime());
}
-OptInStateFilter* CreateOptedInOrOutFilter() {
- OptInStateFilter* filter = new OptInStateFilter;
- filter->add_allowed_opt_in_state(copresence::OPTED_IN);
- filter->add_allowed_opt_in_state(copresence::OPTED_OUT);
- return filter;
-}
-
-void AllowOptedOutMessages(ReportRequest* request) {
- // TODO(ckehoe): Collapse this pattern into ProcessPublish()
- // and ProcessSubscribe() methods.
-
- if (request->has_manage_messages_request()) {
- RepeatedPtrField<PublishedMessage>* messages = request
- ->mutable_manage_messages_request()->mutable_message_to_publish();
- for (int i = 0; i < messages->size(); ++i) {
- PublishedMessage* message = messages->Mutable(i);
- if (!message->has_opt_in_state_filter())
- message->set_allocated_opt_in_state_filter(CreateOptedInOrOutFilter());
- }
- }
-
- if (request->has_manage_subscriptions_request()) {
- RepeatedPtrField<Subscription>* subscriptions =
- request->mutable_manage_subscriptions_request()->mutable_subscription();
- for (int i = 0; i < subscriptions->size(); ++i) {
- Subscription* subscription = subscriptions->Mutable(i);
- if (!subscription->has_opt_in_state_filter()) {
- subscription->set_allocated_opt_in_state_filter(
- CreateOptedInOrOutFilter());
- }
- }
- }
-}
-
} // namespace
// Public methods
@@ -306,7 +272,25 @@ void RpcHandler::SendReportRequest(scoped_ptr<ReportRequest> request,
AddPlayingTokens(request.get());
- AllowOptedOutMessages(request.get());
+ // TODO(ckehoe): Currently the server supports only BROADCAST_AND_SCAN.
+ // Remove this once b/16715253 is fixed.
+ if (request->has_manage_messages_request()) {
+ RepeatedPtrField<PublishedMessage>* messages = request
+ ->mutable_manage_messages_request()->mutable_message_to_publish();
+ for (int i = 0; i < messages->size(); ++i) {
+ messages->Mutable(i)->mutable_token_exchange_strategy()
+ ->set_broadcast_scan_configuration(BROADCAST_AND_SCAN);
+ }
+ }
+ if (request->has_manage_subscriptions_request()) {
+ RepeatedPtrField<Subscription>* subscriptions =
+ request->mutable_manage_subscriptions_request()->mutable_subscription();
+ for (int i = 0; i < subscriptions->size(); ++i) {
+ subscriptions->Mutable(i)->mutable_token_exchange_strategy()
+ ->set_broadcast_scan_configuration(BROADCAST_AND_SCAN);
+ }
+ }
+
SendServerRequest(kReportRequestRpcName,
app_id,
request.Pass(),
« no previous file with comments | « no previous file | components/copresence/rpc/rpc_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698