| 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 "chrome/browser/extensions/api/copresence/copresence_translations.h" | 5 #include "chrome/browser/extensions/api/copresence/copresence_translations.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/api/copresence.h" | 7 #include "chrome/common/extensions/api/copresence.h" |
| 8 #include "components/copresence/proto/data.pb.h" | 8 #include "components/copresence/proto/data.pb.h" |
| 9 #include "components/copresence/proto/enums.pb.h" | 9 #include "components/copresence/proto/enums.pb.h" |
| 10 #include "components/copresence/proto/rpcs.pb.h" | 10 #include "components/copresence/proto/rpcs.pb.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 apps_by_subscription_id->erase(subscription); | 190 apps_by_subscription_id->erase(subscription); |
| 191 } | 191 } |
| 192 | 192 |
| 193 request->mutable_manage_subscriptions_request()->add_id_to_unsubscribe( | 193 request->mutable_manage_subscriptions_request()->add_id_to_unsubscribe( |
| 194 subscription_id); | 194 subscription_id); |
| 195 DVLOG(2) << "Cancelling subscription \"" << subscription_id << "\" for app \"" | 195 DVLOG(2) << "Cancelling subscription \"" << subscription_id << "\" for app \"" |
| 196 << app_id << "\""; | 196 << app_id << "\""; |
| 197 return true; | 197 return true; |
| 198 } | 198 } |
| 199 | 199 |
| 200 bool PrepareReportRequestProto( | 200 bool PrepareReportRequestProto(const std::vector<Operation>& operations, |
| 201 const std::vector<linked_ptr<Operation>>& operations, | 201 const std::string& app_id, |
| 202 const std::string& app_id, | 202 SubscriptionToAppMap* apps_by_subscription_id, |
| 203 SubscriptionToAppMap* apps_by_subscription_id, | 203 ReportRequest* request) { |
| 204 ReportRequest* request) { | 204 for (const Operation& op : operations) { |
| 205 for (const linked_ptr<Operation>& op : operations) { | |
| 206 DCHECK(op.get()); | |
| 207 | |
| 208 // Verify our object has exactly one operation. | 205 // Verify our object has exactly one operation. |
| 209 if (static_cast<int>(op->publish != nullptr) + | 206 if (static_cast<int>(op.publish != nullptr) + |
| 210 static_cast<int>(op->subscribe != nullptr) + | 207 static_cast<int>(op.subscribe != nullptr) + |
| 211 static_cast<int>(op->unpublish != nullptr) + | 208 static_cast<int>(op.unpublish != nullptr) + |
| 212 static_cast<int>(op->unsubscribe != nullptr) != 1) { | 209 static_cast<int>(op.unsubscribe != nullptr) != |
| 210 1) { |
| 213 return false; | 211 return false; |
| 214 } | 212 } |
| 215 | 213 |
| 216 if (op->publish) { | 214 if (op.publish) { |
| 217 if (!AddPublishToRequest(app_id, *(op->publish), request)) | 215 if (!AddPublishToRequest(app_id, *(op.publish), request)) |
| 218 return false; | 216 return false; |
| 219 } else if (op->subscribe) { | 217 } else if (op.subscribe) { |
| 220 if (!AddSubscribeToRequest( | 218 if (!AddSubscribeToRequest(app_id, *(op.subscribe), |
| 221 app_id, *(op->subscribe), apps_by_subscription_id, request)) | 219 apps_by_subscription_id, request)) |
| 222 return false; | 220 return false; |
| 223 } else if (op->unpublish) { | 221 } else if (op.unpublish) { |
| 224 if (!AddUnpublishToRequest(op->unpublish->unpublish_id, request)) | 222 if (!AddUnpublishToRequest(op.unpublish->unpublish_id, request)) |
| 225 return false; | 223 return false; |
| 226 } else { // if (op->unsubscribe) | 224 } else { // if (op.unsubscribe) |
| 227 if (!AddUnsubscribeToRequest(app_id, | 225 if (!AddUnsubscribeToRequest(app_id, op.unsubscribe->unsubscribe_id, |
| 228 op->unsubscribe->unsubscribe_id, | 226 apps_by_subscription_id, request)) |
| 229 apps_by_subscription_id, | |
| 230 request)) | |
| 231 return false; | 227 return false; |
| 232 } | 228 } |
| 233 } | 229 } |
| 234 | 230 |
| 235 return true; | 231 return true; |
| 236 } | 232 } |
| 237 | 233 |
| 238 } // namespace extensions | 234 } // namespace extensions |
| OLD | NEW |