Remove some small uses of linked_ptr from google_apis/.

BUG=556939

Change-Id: I20214613329c368ccc6756f28300421148653fe7
Reviewed-on: https://chromium-review.googlesource.com/c/1376811
Reviewed-by: Roger Tawa <rogerta@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616700}
diff --git a/google_apis/gaia/fake_oauth2_token_service_delegate.cc b/google_apis/gaia/fake_oauth2_token_service_delegate.cc
index 7fc9c28..1e165df 100644
--- a/google_apis/gaia/fake_oauth2_token_service_delegate.cc
+++ b/google_apis/gaia/fake_oauth2_token_service_delegate.cc
@@ -23,7 +23,7 @@
     const std::string& account_id,
     scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
     OAuth2AccessTokenConsumer* consumer) {
-  AccountInfoMap::const_iterator it = refresh_tokens_.find(account_id);
+  auto it = refresh_tokens_.find(account_id);
   DCHECK(it != refresh_tokens_.end());
   return new OAuth2AccessTokenFetcherImpl(consumer, url_loader_factory,
                                           it->second->refresh_token);
@@ -43,7 +43,7 @@
 
 std::string FakeOAuth2TokenServiceDelegate::GetRefreshToken(
     const std::string& account_id) const {
-  AccountInfoMap::const_iterator it = refresh_tokens_.find(account_id);
+  auto it = refresh_tokens_.find(account_id);
   if (it != refresh_tokens_.end())
     return it->second->refresh_token;
   return std::string();
@@ -51,19 +51,15 @@
 
 std::vector<std::string> FakeOAuth2TokenServiceDelegate::GetAccounts() {
   std::vector<std::string> account_ids;
-  for (AccountInfoMap::const_iterator iter = refresh_tokens_.begin();
-       iter != refresh_tokens_.end(); ++iter) {
-    account_ids.push_back(iter->first);
-  }
+  for (const auto& token : refresh_tokens_)
+    account_ids.push_back(token.first);
   return account_ids;
 }
 
 void FakeOAuth2TokenServiceDelegate::RevokeAllCredentials() {
   std::vector<std::string> account_ids = GetAccounts();
-  for (std::vector<std::string>::const_iterator it = account_ids.begin();
-       it != account_ids.end(); it++) {
-    RevokeCredentials(*it);
-  }
+  for (const auto& account : account_ids)
+    RevokeCredentials(account);
 }
 
 void FakeOAuth2TokenServiceDelegate::LoadCredentials(
diff --git a/google_apis/gaia/fake_oauth2_token_service_delegate.h b/google_apis/gaia/fake_oauth2_token_service_delegate.h
index e90d63c..513fca4 100644
--- a/google_apis/gaia/fake_oauth2_token_service_delegate.h
+++ b/google_apis/gaia/fake_oauth2_token_service_delegate.h
@@ -5,8 +5,9 @@
 #ifndef CHROME_BROWSER_SIGNIN_FAKE_OAUTH2_TOKEN_SERVICE_DELEGATE_H_
 #define CHROME_BROWSER_SIGNIN_FAKE_OAUTH2_TOKEN_SERVICE_DELEGATE_H_
 
+#include <memory>
+
 #include "base/macros.h"
-#include "base/memory/linked_ptr.h"
 #include "base/memory/ref_counted.h"
 #include "google_apis/gaia/google_service_auth_error.h"
 #include "google_apis/gaia/oauth2_token_service_delegate.h"
@@ -64,8 +65,7 @@
                                 const std::string& token);
 
   // Maps account ids to info.
-  typedef std::map<std::string, linked_ptr<AccountInfo>> AccountInfoMap;
-  AccountInfoMap refresh_tokens_;
+  std::map<std::string, std::unique_ptr<AccountInfo>> refresh_tokens_;
 
   network::TestURLLoaderFactory test_url_loader_factory_;
   scoped_refptr<network::SharedURLLoaderFactory> shared_factory_;
diff --git a/google_apis/gcm/engine/gcm_store.h b/google_apis/gcm/engine/gcm_store.h
index 828658b..d9d0595b 100644
--- a/google_apis/gcm/engine/gcm_store.h
+++ b/google_apis/gcm/engine/gcm_store.h
@@ -16,7 +16,6 @@
 
 #include "base/callback_forward.h"
 #include "base/macros.h"
-#include "base/memory/linked_ptr.h"
 #include "base/memory/ref_counted.h"
 #include "base/time/time.h"
 #include "google_apis/gcm/base/gcm_export.h"
@@ -36,11 +35,11 @@
   };
 
   // Map of message id to message data for outgoing messages.
-  typedef std::map<std::string, linked_ptr<google::protobuf::MessageLite> >
-      OutgoingMessageMap;
+  using OutgoingMessageMap =
+      std::map<std::string, std::unique_ptr<google::protobuf::MessageLite>>;
 
   // List of account mappings.
-  typedef std::vector<AccountMapping> AccountMappings;
+  using AccountMappings = std::vector<AccountMapping>;
 
   // Container for Load(..) results.
   struct GCM_EXPORT LoadResult {
@@ -66,9 +65,9 @@
     std::map<std::string, std::string> instance_id_data;
   };
 
-  typedef std::vector<std::string> PersistentIdList;
-  typedef base::Callback<void(std::unique_ptr<LoadResult> result)> LoadCallback;
-  typedef base::Callback<void(bool success)> UpdateCallback;
+  using PersistentIdList = std::vector<std::string>;
+  using LoadCallback = base::Callback<void(std::unique_ptr<LoadResult> result)>;
+  using UpdateCallback = base::Callback<void(bool success)>;
 
   GCMStore();
   virtual ~GCMStore();
diff --git a/google_apis/gcm/engine/gcm_store_impl.cc b/google_apis/gcm/engine/gcm_store_impl.cc
index 1bcea40..b29f31f 100644
--- a/google_apis/gcm/engine/gcm_store_impl.cc
+++ b/google_apis/gcm/engine/gcm_store_impl.cc
@@ -1002,7 +1002,7 @@
     }
     DVLOG(1) << "Found outgoing message with id " << id << " of type "
              << base::UintToString(tag);
-    (*outgoing_messages)[id] = make_linked_ptr(message.release());
+    (*outgoing_messages)[id] = std::move(message);
   }
 
   return true;
diff --git a/google_apis/gcm/engine/mcs_client.cc b/google_apis/gcm/engine/mcs_client.cc
index 7ee780f..47ba2023 100644
--- a/google_apis/gcm/engine/mcs_client.cc
+++ b/google_apis/gcm/engine/mcs_client.cc
@@ -263,19 +263,20 @@
   for (std::map<uint64_t, google::protobuf::MessageLite*>::iterator iter =
            ordered_messages.begin();
        iter != ordered_messages.end(); ++iter) {
-    ReliablePacketInfo* packet_info = new ReliablePacketInfo();
+    auto packet_info = std::make_unique<ReliablePacketInfo>();
+    auto* packet_info_ptr = packet_info.get();
     packet_info->protobuf.reset(iter->second);
     packet_info->tag = GetMCSProtoTag(*iter->second);
     packet_info->persistent_id = base::NumberToString(iter->first);
-    to_send_.push_back(make_linked_ptr(packet_info));
+    to_send_.push_back(std::move(packet_info));
 
-    if (packet_info->tag == kDataMessageStanzaTag) {
+    if (packet_info_ptr->tag == kDataMessageStanzaTag) {
       mcs_proto::DataMessageStanza* data_message =
           reinterpret_cast<mcs_proto::DataMessageStanza*>(
-              packet_info->protobuf.get());
+              packet_info_ptr->protobuf.get());
       CollapseKey collapse_key(*data_message);
       if (collapse_key.IsValid())
-        collapse_key_map_[collapse_key] = packet_info;
+        collapse_key_map_[collapse_key] = packet_info_ptr;
     }
   }
 
@@ -369,7 +370,7 @@
     return;
   }
 
-  to_send_.push_back(make_linked_ptr(packet_info.release()));
+  to_send_.push_back(std::move(packet_info));
 
   // Notify that the messages has been succsfully queued for sending.
   // TODO(jianli): We should report QUEUED after writing to GCM store succeeds.
@@ -478,7 +479,7 @@
   // to RMQ, as all messages that reach this point should already have been
   // saved as necessary.
   while (!to_resend_.empty()) {
-    to_send_.push_front(to_resend_.back());
+    to_send_.push_front(std::move(to_resend_.back()));
     to_resend_.pop_back();
   }
 
@@ -489,7 +490,7 @@
     MCSPacketInternal packet = PopMessageForSend();
     if (GetTTL(*packet->protobuf) > 0 &&
         !HasTTLExpired(*packet->protobuf, clock_)) {
-      new_to_send.push_back(packet);
+      new_to_send.push_back(std::move(packet));
     } else {
       // If the TTL was 0 there is no persistent id, so no need to remove the
       // message from the persistent store.
@@ -539,6 +540,7 @@
     return;
 
   MCSPacketInternal packet = PopMessageForSend();
+  ReliablePacketInfo* packet_ptr = packet.get();
   if (HasTTLExpired(*packet->protobuf, clock_)) {
     DCHECK(!packet->persistent_id.empty());
     DVLOG(1) << "Dropping expired message " << packet->persistent_id << ".";
@@ -555,8 +557,8 @@
   }
   DVLOG(1) << "Pending output message found, sending.";
   if (!packet->persistent_id.empty())
-    to_resend_.push_back(packet);
-  SendPacketToWire(packet.get());
+    to_resend_.push_back(std::move(packet));
+  SendPacketToWire(packet_ptr);
 }
 
 void MCSClient::SendPacketToWire(ReliablePacketInfo* packet_info) {
@@ -895,7 +897,7 @@
   // server.
   DVLOG(1) << "Resending " << to_resend_.size() << " messages.";
   while (!to_resend_.empty()) {
-    to_send_.push_front(to_resend_.back());
+    to_send_.push_front(std::move(to_resend_.back()));
     to_resend_.pop_back();
   }
   base::ThreadTaskRunnerHandle::Get()->PostTask(
@@ -956,7 +958,7 @@
 }
 
 MCSClient::MCSPacketInternal MCSClient::PopMessageForSend() {
-  MCSPacketInternal packet = to_send_.front();
+  MCSPacketInternal packet = std::move(to_send_.front());
   to_send_.pop_front();
 
   if (packet->tag == kDataMessageStanzaTag) {
diff --git a/google_apis/gcm/engine/mcs_client.h b/google_apis/gcm/engine/mcs_client.h
index 22cecae..1fecfa5 100644
--- a/google_apis/gcm/engine/mcs_client.h
+++ b/google_apis/gcm/engine/mcs_client.h
@@ -15,7 +15,6 @@
 #include "base/containers/circular_deque.h"
 #include "base/files/file_path.h"
 #include "base/macros.h"
-#include "base/memory/linked_ptr.h"
 #include "base/memory/weak_ptr.h"
 #include "google_apis/gcm/base/gcm_export.h"
 #include "google_apis/gcm/base/mcs_message.h"
@@ -167,12 +166,12 @@
   }
 
  private:
-  typedef uint32_t StreamId;
-  typedef std::string PersistentId;
-  typedef std::vector<StreamId> StreamIdList;
-  typedef std::vector<PersistentId> PersistentIdList;
-  typedef std::map<StreamId, PersistentId> StreamIdToPersistentIdMap;
-  typedef linked_ptr<ReliablePacketInfo> MCSPacketInternal;
+  using StreamId = uint32_t;
+  using PersistentId = std::string;
+  using StreamIdList = std::vector<StreamId>;
+  using PersistentIdList = std::vector<PersistentId>;
+  using StreamIdToPersistentIdMap = std::map<StreamId, PersistentId>;
+  using MCSPacketInternal = std::unique_ptr<ReliablePacketInfo>;
 
   // Resets the internal state and builds a new login request, acknowledging
   // any pending server-to-device messages and rebuilding the send queue