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

Side by Side Diff: chrome/browser/extensions/api/copresence/copresence_translations.cc

Issue 820673004: json_schema_compiler: Use std::vector<char> for binary values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify_json_schema
Patch Set: Fix merge error. Created 5 years, 11 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
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 "chrome/browser/extensions/api/copresence/copresence_translations.h" 5 #include "chrome/browser/extensions/api/copresence/copresence_translations.h"
6 6
7 #include "base/stl_util.h"
7 #include "chrome/common/extensions/api/copresence.h" 8 #include "chrome/common/extensions/api/copresence.h"
8 #include "components/copresence/proto/data.pb.h" 9 #include "components/copresence/proto/data.pb.h"
9 #include "components/copresence/proto/enums.pb.h" 10 #include "components/copresence/proto/enums.pb.h"
10 #include "components/copresence/proto/rpcs.pb.h" 11 #include "components/copresence/proto/rpcs.pb.h"
11 12
12 using copresence::AUDIO_CONFIGURATION_AUDIBLE; 13 using copresence::AUDIO_CONFIGURATION_AUDIBLE;
13 using copresence::AUDIO_CONFIGURATION_UNKNOWN; 14 using copresence::AUDIO_CONFIGURATION_UNKNOWN;
14 using copresence::BROADCAST_AND_SCAN; 15 using copresence::BROADCAST_AND_SCAN;
15 using copresence::BROADCAST_ONLY; 16 using copresence::BROADCAST_ONLY;
16 using copresence::BROADCAST_SCAN_CONFIGURATION_UNKNOWN; 17 using copresence::BROADCAST_SCAN_CONFIGURATION_UNKNOWN;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 bool AddPublishToRequest(const std::string& app_id, 83 bool AddPublishToRequest(const std::string& app_id,
83 const api::copresence::PublishOperation& publish, 84 const api::copresence::PublishOperation& publish,
84 ReportRequest* request) { 85 ReportRequest* request) {
85 copresence::PublishedMessage* publish_proto = 86 copresence::PublishedMessage* publish_proto =
86 request->mutable_manage_messages_request()->add_message_to_publish(); 87 request->mutable_manage_messages_request()->add_message_to_publish();
87 publish_proto->mutable_access_policy()->mutable_acl()->set_acl_type( 88 publish_proto->mutable_access_policy()->mutable_acl()->set_acl_type(
88 copresence::NO_ACL_CHECK); 89 copresence::NO_ACL_CHECK);
89 publish_proto->set_id(publish.id); 90 publish_proto->set_id(publish.id);
90 publish_proto->mutable_message()->mutable_type()->set_type( 91 publish_proto->mutable_message()->mutable_type()->set_type(
91 publish.message.type); 92 publish.message.type);
92 publish_proto->mutable_message()->set_payload(publish.message.payload); 93 publish_proto->mutable_message()->set_payload(
94 vector_as_array(&publish.message.payload),
95 publish.message.payload.size());
93 96
94 int ttl = SanitizeTtl(publish.time_to_live_millis.get()); 97 int ttl = SanitizeTtl(publish.time_to_live_millis.get());
95 if (ttl < 0) 98 if (ttl < 0)
96 return false; 99 return false;
97 publish_proto->mutable_access_policy()->set_ttl_millis(ttl); 100 publish_proto->mutable_access_policy()->set_ttl_millis(ttl);
98 101
99 SetTokenExchangeStrategy(publish.strategies.get(), 102 SetTokenExchangeStrategy(publish.strategies.get(),
100 BROADCAST_ONLY, 103 BROADCAST_ONLY,
101 publish_proto->mutable_token_exchange_strategy()); 104 publish_proto->mutable_token_exchange_strategy());
102 105
103 DVLOG(2) << "Publishing message of type " << publish.message.type << ":\n" 106 DVLOG(2) << "Publishing message of type " << publish.message.type << ":\n"
104 << publish.message.payload; 107 << std::string(publish.message.payload.begin(),
108 publish.message.payload.end());
105 // TODO(ckehoe): Validate that required fields are non-empty, etc. 109 // TODO(ckehoe): Validate that required fields are non-empty, etc.
106 return true; 110 return true;
107 } 111 }
108 112
109 // Adds an unpublish operation to the report request. Returns false if the 113 // Adds an unpublish operation to the report request. Returns false if the
110 // publish id was invalid. 114 // publish id was invalid.
111 bool AddUnpublishToRequest(const std::string& publish_id, 115 bool AddUnpublishToRequest(const std::string& publish_id,
112 ReportRequest* request) { 116 ReportRequest* request) {
113 if (publish_id.empty()) 117 if (publish_id.empty())
114 return false; 118 return false;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 apps_by_subscription_id, 231 apps_by_subscription_id,
228 request)) 232 request))
229 return false; 233 return false;
230 } 234 }
231 } 235 }
232 236
233 return true; 237 return true;
234 } 238 }
235 239
236 } // namespace extensions 240 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698