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

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

Issue 459903006: Setting OptInStateFilter for publishes and subscribes (b/16324352) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mem
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 2ca127ea7955fca154b1e9750389a24db0e5695b..1976ec6565ff936ae083399fbcb0099e752f7bc0 100644
--- a/components/copresence/rpc/rpc_handler.cc
+++ b/components/copresence/rpc/rpc_handler.cc
@@ -119,11 +119,11 @@ BroadcastScanConfiguration ExtractTokenExchangeStrategy(
// Strategies for subscriptions.
if (request.has_manage_subscriptions_request()) {
- const RepeatedPtrField<Subscription> messages =
+ const RepeatedPtrField<Subscription> subscriptions =
request.manage_subscriptions_request().subscription();
- for (int i = 0; i < messages.size(); ++i) {
+ for (int i = 0; i < subscriptions.size(); ++i) {
BroadcastScanConfiguration config =
- GetBroadcastScanConfig(messages.Get(i));
+ GetBroadcastScanConfig(subscriptions.Get(i));
broadcast_only = broadcast_only || config == BROADCAST_ONLY;
scan_only = scan_only || config == SCAN_ONLY;
if (config == BROADCAST_AND_SCAN || (broadcast_only && scan_only))
@@ -194,6 +194,33 @@ ClientVersion* CreateVersion(const std::string& client,
return version;
}
+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) {
rkc 2014/08/12 03:38:19 This anonymous namespace is getting huge. We shoul
Charlie 2014/08/12 04:36:14 Added a TODO. Keep in mind that ExtractTokenExchan
+ RepeatedPtrField<PublishedMessage>* messages =
rkc 2014/08/12 03:38:19 This is a pattern that we'll be following 3 places
Charlie 2014/08/12 04:36:14 Another TODO. I think Ben probably doesn't want to
+ 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());
+ }
+
+ 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
@@ -253,6 +280,7 @@ void RpcHandler::SendReportRequest(scoped_ptr<ReportRequest> request,
request->mutable_update_signals_request()->set_allocated_state(
GetDeviceCapabilities(*request).release());
+ AllowOptedOutMessages(request.get());
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