diff options
Diffstat (limited to 'chrome/browser/extensions/api/copresence')
3 files changed, 31 insertions, 37 deletions
diff --git a/chrome/browser/extensions/api/copresence/copresence_api.cc b/chrome/browser/extensions/api/copresence/copresence_api.cc index e5e6e6d..44bfca7 100644 --- a/chrome/browser/extensions/api/copresence/copresence_api.cc +++ b/chrome/browser/extensions/api/copresence/copresence_api.cc @@ -7,7 +7,6 @@ #include <utility> #include "base/lazy_instance.h" -#include "base/memory/linked_ptr.h" #include "chrome/browser/copresence/chrome_whispernet_client.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" @@ -136,16 +135,16 @@ void CopresenceService::HandleMessages( } int message_count = messages.size(); - std::vector<linked_ptr<api::copresence::Message>> api_messages( - message_count); - - for (int m = 0; m < message_count; ++m) { - api_messages[m].reset(new api::copresence::Message); - api_messages[m]->type = messages[m].type().type(); - api_messages[m]->payload.assign(messages[m].payload().begin(), - messages[m].payload().end()); - DVLOG(2) << "Dispatching message of type " << api_messages[m]->type << ":\n" - << messages[m].payload(); + std::vector<api::copresence::Message> api_messages(message_count); + + for (const copresence::Message& message : messages) { + api::copresence::Message api_message; + api_message.type = message.type().type(); + api_message.payload.assign(message.payload().begin(), + message.payload().end()); + api_messages.push_back(std::move(api_message)); + DVLOG(2) << "Dispatching message of type " << api_message.type << ":\n" + << message.payload(); } // Send the messages to the client app. diff --git a/chrome/browser/extensions/api/copresence/copresence_translations.cc b/chrome/browser/extensions/api/copresence/copresence_translations.cc index 779040e..3537e2c 100644 --- a/chrome/browser/extensions/api/copresence/copresence_translations.cc +++ b/chrome/browser/extensions/api/copresence/copresence_translations.cc @@ -197,37 +197,33 @@ bool AddUnsubscribeToRequest(const std::string& app_id, return true; } -bool PrepareReportRequestProto( - const std::vector<linked_ptr<Operation>>& operations, - const std::string& app_id, - SubscriptionToAppMap* apps_by_subscription_id, - ReportRequest* request) { - for (const linked_ptr<Operation>& op : operations) { - DCHECK(op.get()); - +bool PrepareReportRequestProto(const std::vector<Operation>& operations, + const std::string& app_id, + SubscriptionToAppMap* apps_by_subscription_id, + ReportRequest* request) { + for (const Operation& op : operations) { // Verify our object has exactly one operation. - if (static_cast<int>(op->publish != nullptr) + - static_cast<int>(op->subscribe != nullptr) + - static_cast<int>(op->unpublish != nullptr) + - static_cast<int>(op->unsubscribe != nullptr) != 1) { + if (static_cast<int>(op.publish != nullptr) + + static_cast<int>(op.subscribe != nullptr) + + static_cast<int>(op.unpublish != nullptr) + + static_cast<int>(op.unsubscribe != nullptr) != + 1) { return false; } - if (op->publish) { - if (!AddPublishToRequest(app_id, *(op->publish), request)) + if (op.publish) { + if (!AddPublishToRequest(app_id, *(op.publish), request)) return false; - } else if (op->subscribe) { - if (!AddSubscribeToRequest( - app_id, *(op->subscribe), apps_by_subscription_id, request)) + } else if (op.subscribe) { + if (!AddSubscribeToRequest(app_id, *(op.subscribe), + apps_by_subscription_id, request)) return false; - } else if (op->unpublish) { - if (!AddUnpublishToRequest(op->unpublish->unpublish_id, request)) + } else if (op.unpublish) { + if (!AddUnpublishToRequest(op.unpublish->unpublish_id, request)) return false; - } else { // if (op->unsubscribe) - if (!AddUnsubscribeToRequest(app_id, - op->unsubscribe->unsubscribe_id, - apps_by_subscription_id, - request)) + } else { // if (op.unsubscribe) + if (!AddUnsubscribeToRequest(app_id, op.unsubscribe->unsubscribe_id, + apps_by_subscription_id, request)) return false; } } diff --git a/chrome/browser/extensions/api/copresence/copresence_translations.h b/chrome/browser/extensions/api/copresence/copresence_translations.h index a0f9fd9..4903c62 100644 --- a/chrome/browser/extensions/api/copresence/copresence_translations.h +++ b/chrome/browser/extensions/api/copresence/copresence_translations.h @@ -10,7 +10,6 @@ #include <vector> #include "base/macros.h" -#include "base/memory/linked_ptr.h" #include "components/copresence/proto/enums.pb.h" namespace copresence { @@ -34,7 +33,7 @@ typedef std::map<std::string, std::string> SubscriptionToAppMap; // Returns report request protocol buffer containing all the operations in the // given vector. If parsing any of the operations fails, we return false. bool PrepareReportRequestProto( - const std::vector<linked_ptr<api::copresence::Operation>>& operations, + const std::vector<api::copresence::Operation>& operations, const std::string& app_id, SubscriptionToAppMap* apps_by_subscription_id, copresence::ReportRequest* request); |
