Some easy conversions of scoped_ptr -> std::unique_ptr in the EDK.

R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/1350503004 .
diff --git a/mojo/edk/system/core.cc b/mojo/edk/system/core.cc
index ff21f1c..e1a780b 100644
--- a/mojo/edk/system/core.cc
+++ b/mojo/edk/system/core.cc
@@ -4,6 +4,7 @@
 
 #include "mojo/edk/system/core.h"
 
+#include <memory>
 #include <vector>
 
 #include "base/logging.h"
@@ -76,7 +77,6 @@
 //    - Locks at the "INF" level may not have any locks taken while they are
 //      held.
 
-// TODO(vtl): This should take a |scoped_ptr<PlatformSupport>| as a parameter.
 Core::Core(embedder::PlatformSupport* platform_support)
     : platform_support_(platform_support) {
 }
@@ -112,7 +112,7 @@
   scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle);
   DCHECK(dispatcher);
 
-  scoped_ptr<AsyncWaiter> waiter = make_scoped_ptr(new AsyncWaiter(callback));
+  std::unique_ptr<AsyncWaiter> waiter(new AsyncWaiter(callback));
   MojoResult rv = dispatcher->AddAwakable(waiter.get(), signals, 0, nullptr);
   if (rv == MOJO_RESULT_OK)
     ignore_result(waiter.release());
diff --git a/mojo/edk/system/data_pipe.cc b/mojo/edk/system/data_pipe.cc
index 9782b71..ef87058 100644
--- a/mojo/edk/system/data_pipe.cc
+++ b/mojo/edk/system/data_pipe.cc
@@ -8,6 +8,8 @@
 
 #include <algorithm>
 #include <limits>
+#include <memory>
+#include <utility>
 
 #include "base/logging.h"
 #include "base/memory/aligned_memory.h"
@@ -102,7 +104,7 @@
     const MojoCreateDataPipeOptions& validated_options,
     MessageInTransitQueue* message_queue,
     ChannelEndpoint* channel_endpoint) {
-  scoped_ptr<char, base::AlignedFreeDeleter> buffer;
+  std::unique_ptr<char, base::AlignedFreeDeleter> buffer;
   size_t buffer_num_bytes = 0;
   if (!RemoteProducerDataPipeImpl::ProcessMessagesFromIncomingEndpoint(
           validated_options, message_queue, &buffer, &buffer_num_bytes))
@@ -115,10 +117,10 @@
   // ongoing call to |IncomingEndpoint::OnReadMessage()| return false. This will
   // make |ChannelEndpoint::OnReadMessage()| retry, until its |ReplaceClient()|
   // is called.
-  DataPipe* data_pipe =
-      new DataPipe(false, true, validated_options,
-                   make_scoped_ptr(new RemoteProducerDataPipeImpl(
-                       channel_endpoint, buffer.Pass(), 0, buffer_num_bytes)));
+  DataPipe* data_pipe = new DataPipe(
+      false, true, validated_options,
+      make_scoped_ptr(new RemoteProducerDataPipeImpl(
+          channel_endpoint, std::move(buffer), 0, buffer_num_bytes)));
   if (channel_endpoint) {
     if (!channel_endpoint->ReplaceClient(data_pipe, 0))
       data_pipe->OnDetachFromChannel(0);
diff --git a/mojo/edk/system/data_pipe.h b/mojo/edk/system/data_pipe.h
index bd20d63..79abbf5 100644
--- a/mojo/edk/system/data_pipe.h
+++ b/mojo/edk/system/data_pipe.h
@@ -7,6 +7,8 @@
 
 #include <stdint.h>
 
+#include <memory>
+
 #include "base/compiler_specific.h"
 #include "base/memory/scoped_ptr.h"
 #include "mojo/edk/embedder/platform_handle_vector.h"
@@ -270,8 +272,8 @@
   bool producer_open_ MOJO_GUARDED_BY(mutex_);
   bool consumer_open_ MOJO_GUARDED_BY(mutex_);
   // Non-null only if the producer or consumer, respectively, is local.
-  scoped_ptr<AwakableList> producer_awakable_list_ MOJO_GUARDED_BY(mutex_);
-  scoped_ptr<AwakableList> consumer_awakable_list_ MOJO_GUARDED_BY(mutex_);
+  std::unique_ptr<AwakableList> producer_awakable_list_ MOJO_GUARDED_BY(mutex_);
+  std::unique_ptr<AwakableList> consumer_awakable_list_ MOJO_GUARDED_BY(mutex_);
   // These are nonzero if and only if a two-phase write/read is in progress.
   uint32_t producer_two_phase_max_num_bytes_written_ MOJO_GUARDED_BY(mutex_);
   uint32_t consumer_two_phase_max_num_bytes_read_ MOJO_GUARDED_BY(mutex_);
diff --git a/mojo/edk/system/local_data_pipe_impl.cc b/mojo/edk/system/local_data_pipe_impl.cc
index 195e155..1af0f92 100644
--- a/mojo/edk/system/local_data_pipe_impl.cc
+++ b/mojo/edk/system/local_data_pipe_impl.cc
@@ -13,6 +13,7 @@
 #include <string.h>
 
 #include <algorithm>
+#include <utility>
 
 #include "base/logging.h"
 #include "base/memory/scoped_ptr.h"
@@ -193,7 +194,7 @@
   // Note: Keep |*this| alive until the end of this method, to make things
   // slightly easier on ourselves.
   scoped_ptr<DataPipeImpl> self(ReplaceImpl(make_scoped_ptr(
-      new RemoteProducerDataPipeImpl(channel_endpoint.get(), buffer_.Pass(),
+      new RemoteProducerDataPipeImpl(channel_endpoint.get(), std::move(buffer_),
                                      start_index_, current_num_bytes_))));
 
   *actual_size = sizeof(SerializedDataPipeProducerDispatcher) +
diff --git a/mojo/edk/system/local_data_pipe_impl.h b/mojo/edk/system/local_data_pipe_impl.h
index 07b4c1e..2564a01 100644
--- a/mojo/edk/system/local_data_pipe_impl.h
+++ b/mojo/edk/system/local_data_pipe_impl.h
@@ -5,8 +5,9 @@
 #ifndef MOJO_EDK_SYSTEM_LOCAL_DATA_PIPE_IMPL_H_
 #define MOJO_EDK_SYSTEM_LOCAL_DATA_PIPE_IMPL_H_
 
+#include <memory>
+
 #include "base/memory/aligned_memory.h"
-#include "base/memory/scoped_ptr.h"
 #include "mojo/edk/system/data_pipe_impl.h"
 #include "mojo/edk/system/system_impl_export.h"
 #include "mojo/public/cpp/system/macros.h"
@@ -82,7 +83,7 @@
   // no greater than |current_num_bytes_|.
   void MarkDataAsConsumed(size_t num_bytes);
 
-  scoped_ptr<char, base::AlignedFreeDeleter> buffer_;
+  std::unique_ptr<char, base::AlignedFreeDeleter> buffer_;
   // Circular buffer.
   size_t start_index_;
   size_t current_num_bytes_;
diff --git a/mojo/edk/system/memory.h b/mojo/edk/system/memory.h
index 31d67cc..41d3730 100644
--- a/mojo/edk/system/memory.h
+++ b/mojo/edk/system/memory.h
@@ -9,7 +9,8 @@
 #include <stdint.h>
 #include <string.h>  // For |memcpy()|.
 
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
 #include "mojo/edk/system/system_impl_export.h"
 #include "mojo/public/c/system/macros.h"
 #include "mojo/public/cpp/system/macros.h"
@@ -305,7 +306,7 @@
     memcpy(buffer_.get(), user_pointer, count * sizeof(Type));
   }
 
-  scoped_ptr<TypeNoConst[]> buffer_;
+  std::unique_ptr<TypeNoConst[]> buffer_;
 
   MOJO_DISALLOW_COPY_AND_ASSIGN(UserPointerReader);
 };
@@ -334,7 +335,7 @@
  private:
   UserPointer<Type> user_pointer_;
   size_t count_;
-  scoped_ptr<Type[]> buffer_;
+  std::unique_ptr<Type[]> buffer_;
 
   MOJO_DISALLOW_COPY_AND_ASSIGN(UserPointerWriter);
 };
@@ -366,7 +367,7 @@
  private:
   UserPointer<Type> user_pointer_;
   size_t count_;
-  scoped_ptr<Type[]> buffer_;
+  std::unique_ptr<Type[]> buffer_;
 
   MOJO_DISALLOW_COPY_AND_ASSIGN(UserPointerReaderWriter);
 };
diff --git a/mojo/edk/system/message_pipe_perftest.cc b/mojo/edk/system/message_pipe_perftest.cc
index 562acbd..6772b2e 100644
--- a/mojo/edk/system/message_pipe_perftest.cc
+++ b/mojo/edk/system/message_pipe_perftest.cc
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <memory>
 #include <string>
 #include <vector>
 
@@ -84,7 +85,7 @@
   size_t message_size_;
   std::string payload_;
   std::string read_buffer_;
-  scoped_ptr<base::PerfTimeLogger> perf_logger_;
+  std::unique_ptr<base::PerfTimeLogger> perf_logger_;
 };
 
 // For each message received, sends a reply message with the same contents
diff --git a/mojo/edk/system/raw_channel.cc b/mojo/edk/system/raw_channel.cc
index 20f74d2..0f89bc3 100644
--- a/mojo/edk/system/raw_channel.cc
+++ b/mojo/edk/system/raw_channel.cc
@@ -7,6 +7,7 @@
 #include <string.h>
 
 #include <algorithm>
+#include <utility>
 
 #include "base/bind.h"
 #include "base/location.h"
@@ -217,7 +218,7 @@
   write_stopped_ = true;
   weak_ptr_factory_.InvalidateWeakPtrs();
 
-  OnShutdownNoLock(read_buffer_.Pass(), write_buffer_.Pass());
+  OnShutdownNoLock(std::move(read_buffer_), std::move(write_buffer_));
 }
 
 // Reminder: This must be thread-safe.
diff --git a/mojo/edk/system/raw_channel.h b/mojo/edk/system/raw_channel.h
index abab3ec..9ccf280 100644
--- a/mojo/edk/system/raw_channel.h
+++ b/mojo/edk/system/raw_channel.h
@@ -5,6 +5,7 @@
 #ifndef MOJO_EDK_SYSTEM_RAW_CHANNEL_H_
 #define MOJO_EDK_SYSTEM_RAW_CHANNEL_H_
 
+#include <memory>
 #include <vector>
 
 #include "base/memory/scoped_ptr.h"
@@ -289,8 +290,8 @@
   // want to preserve them if there are pending read/writes. After this is
   // called, |OnReadCompleted()| must no longer be called. Must be called on the
   // I/O thread.
-  virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer,
-                                scoped_ptr<WriteBuffer> write_buffer)
+  virtual void OnShutdownNoLock(std::unique_ptr<ReadBuffer> read_buffer,
+                                std::unique_ptr<WriteBuffer> write_buffer)
       MOJO_EXCLUSIVE_LOCKS_REQUIRED(write_mutex_) = 0;
 
  private:
@@ -317,11 +318,11 @@
   // Only used on the I/O thread:
   Delegate* delegate_;
   bool* set_on_shutdown_;
-  scoped_ptr<ReadBuffer> read_buffer_;
+  std::unique_ptr<ReadBuffer> read_buffer_;
 
   Mutex write_mutex_;  // Protects the following members.
   bool write_stopped_ MOJO_GUARDED_BY(write_mutex_);
-  scoped_ptr<WriteBuffer> write_buffer_ MOJO_GUARDED_BY(write_mutex_);
+  std::unique_ptr<WriteBuffer> write_buffer_ MOJO_GUARDED_BY(write_mutex_);
 
   // This is used for posting tasks from write threads to the I/O thread. The
   // weak pointers it produces are only used/invalidated on the I/O thread.
diff --git a/mojo/edk/system/raw_channel_posix.cc b/mojo/edk/system/raw_channel_posix.cc
index 03b3d05..a40a5d5 100644
--- a/mojo/edk/system/raw_channel_posix.cc
+++ b/mojo/edk/system/raw_channel_posix.cc
@@ -10,6 +10,7 @@
 
 #include <algorithm>
 #include <deque>
+#include <memory>
 
 #include "base/bind.h"
 #include "base/location.h"
@@ -55,8 +56,8 @@
                        size_t* bytes_written) override;
   IOResult ScheduleWriteNoLock() override;
   void OnInit() override;
-  void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer,
-                        scoped_ptr<WriteBuffer> write_buffer) override;
+  void OnShutdownNoLock(std::unique_ptr<ReadBuffer> read_buffer,
+                        std::unique_ptr<WriteBuffer> write_buffer) override;
 
   // |base::MessageLoopForIO::Watcher| implementation:
   void OnFileCanReadWithoutBlocking(int fd) override;
@@ -71,8 +72,8 @@
   embedder::ScopedPlatformHandle fd_;
 
   // The following members are only used on the I/O thread:
-  scoped_ptr<base::MessageLoopForIO::FileDescriptorWatcher> read_watcher_;
-  scoped_ptr<base::MessageLoopForIO::FileDescriptorWatcher> write_watcher_;
+  std::unique_ptr<base::MessageLoopForIO::FileDescriptorWatcher> read_watcher_;
+  std::unique_ptr<base::MessageLoopForIO::FileDescriptorWatcher> write_watcher_;
 
   bool pending_read_;
 
@@ -327,8 +328,8 @@
 }
 
 void RawChannelPosix::OnShutdownNoLock(
-    scoped_ptr<ReadBuffer> /*read_buffer*/,
-    scoped_ptr<WriteBuffer> /*write_buffer*/) {
+    std::unique_ptr<ReadBuffer> /*read_buffer*/,
+    std::unique_ptr<WriteBuffer> /*write_buffer*/) {
   DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
   write_mutex().AssertHeld();
 
diff --git a/mojo/edk/system/remote_consumer_data_pipe_impl.h b/mojo/edk/system/remote_consumer_data_pipe_impl.h
index dbd1f7b..15da411 100644
--- a/mojo/edk/system/remote_consumer_data_pipe_impl.h
+++ b/mojo/edk/system/remote_consumer_data_pipe_impl.h
@@ -5,9 +5,10 @@
 #ifndef MOJO_EDK_SYSTEM_REMOTE_CONSUMER_DATA_PIPE_IMPL_H_
 #define MOJO_EDK_SYSTEM_REMOTE_CONSUMER_DATA_PIPE_IMPL_H_
 
+#include <memory>
+
 #include "base/memory/aligned_memory.h"
 #include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
 #include "mojo/edk/system/channel_endpoint.h"
 #include "mojo/edk/system/data_pipe_impl.h"
 #include "mojo/edk/system/system_impl_export.h"
@@ -97,7 +98,7 @@
   size_t consumer_num_bytes_;
 
   // Used for two-phase writes.
-  scoped_ptr<char, base::AlignedFreeDeleter> buffer_;
+  std::unique_ptr<char, base::AlignedFreeDeleter> buffer_;
 
   MOJO_DISALLOW_COPY_AND_ASSIGN(RemoteConsumerDataPipeImpl);
 };
diff --git a/mojo/edk/system/remote_message_pipe_unittest.cc b/mojo/edk/system/remote_message_pipe_unittest.cc
index 26c5bf8..6ab951f 100644
--- a/mojo/edk/system/remote_message_pipe_unittest.cc
+++ b/mojo/edk/system/remote_message_pipe_unittest.cc
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <memory>
 #include <vector>
 
 #include "base/bind.h"
@@ -335,7 +336,7 @@
                       &max_platform_handle_count);
   EXPECT_GT(max_endpoint_info_size, 0u);
   ASSERT_EQ(0u, max_platform_handle_count);
-  scoped_ptr<char[]> endpoint_info(new char[max_endpoint_info_size]);
+  std::unique_ptr<char[]> endpoint_info(new char[max_endpoint_info_size]);
   size_t endpoint_info_size;
   mp2->EndSerialize(1, channels(0), endpoint_info.get(), &endpoint_info_size,
                     nullptr);
@@ -360,7 +361,7 @@
   EXPECT_EQ(kAllSignals, hss.satisfiable_signals);
 
   EXPECT_EQ(endpoint_info_size, channels(1)->GetSerializedEndpointSize());
-  scoped_ptr<char[]> received_endpoint_info(new char[endpoint_info_size]);
+  std::unique_ptr<char[]> received_endpoint_info(new char[endpoint_info_size]);
   buffer_size = static_cast<uint32_t>(endpoint_info_size);
   EXPECT_EQ(MOJO_RESULT_OK,
             mp1->ReadMessage(1, UserPointer<void>(received_endpoint_info.get()),
diff --git a/mojo/edk/system/remote_producer_data_pipe_impl.cc b/mojo/edk/system/remote_producer_data_pipe_impl.cc
index 7529779..252e237 100644
--- a/mojo/edk/system/remote_producer_data_pipe_impl.cc
+++ b/mojo/edk/system/remote_producer_data_pipe_impl.cc
@@ -7,6 +7,7 @@
 #include <string.h>
 
 #include <algorithm>
+#include <utility>
 
 #include "base/logging.h"
 #include "base/memory/scoped_ptr.h"
@@ -68,11 +69,11 @@
 
 RemoteProducerDataPipeImpl::RemoteProducerDataPipeImpl(
     ChannelEndpoint* channel_endpoint,
-    scoped_ptr<char, base::AlignedFreeDeleter> buffer,
+    std::unique_ptr<char, base::AlignedFreeDeleter> buffer,
     size_t start_index,
     size_t current_num_bytes)
     : channel_endpoint_(channel_endpoint),
-      buffer_(buffer.Pass()),
+      buffer_(std::move(buffer)),
       start_index_(start_index),
       current_num_bytes_(current_num_bytes) {
   DCHECK(buffer_ || !current_num_bytes);
@@ -82,14 +83,14 @@
 bool RemoteProducerDataPipeImpl::ProcessMessagesFromIncomingEndpoint(
     const MojoCreateDataPipeOptions& validated_options,
     MessageInTransitQueue* messages,
-    scoped_ptr<char, base::AlignedFreeDeleter>* buffer,
+    std::unique_ptr<char, base::AlignedFreeDeleter>* buffer,
     size_t* buffer_num_bytes) {
   DCHECK(!*buffer);  // Not wrong, but unlikely.
 
   const size_t element_num_bytes = validated_options.element_num_bytes;
   const size_t capacity_num_bytes = validated_options.capacity_num_bytes;
 
-  scoped_ptr<char, base::AlignedFreeDeleter> new_buffer(static_cast<char*>(
+  std::unique_ptr<char, base::AlignedFreeDeleter> new_buffer(static_cast<char*>(
       base::AlignedAlloc(capacity_num_bytes,
                          GetConfiguration().data_pipe_buffer_alignment_bytes)));
 
@@ -109,7 +110,7 @@
     }
   }
 
-  *buffer = new_buffer.Pass();
+  *buffer = std::move(new_buffer);
   *buffer_num_bytes = current_num_bytes;
   return true;
 }
diff --git a/mojo/edk/system/remote_producer_data_pipe_impl.h b/mojo/edk/system/remote_producer_data_pipe_impl.h
index 49a1a34..1b72fc6 100644
--- a/mojo/edk/system/remote_producer_data_pipe_impl.h
+++ b/mojo/edk/system/remote_producer_data_pipe_impl.h
@@ -5,9 +5,10 @@
 #ifndef MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_
 #define MOJO_EDK_SYSTEM_REMOTE_PRODUCER_DATA_PIPE_IMPL_H_
 
+#include <memory>
+
 #include "base/memory/aligned_memory.h"
 #include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
 #include "mojo/edk/system/channel_endpoint.h"
 #include "mojo/edk/system/data_pipe_impl.h"
 #include "mojo/edk/system/system_impl_export.h"
@@ -25,10 +26,11 @@
     : public DataPipeImpl {
  public:
   explicit RemoteProducerDataPipeImpl(ChannelEndpoint* channel_endpoint);
-  RemoteProducerDataPipeImpl(ChannelEndpoint* channel_endpoint,
-                             scoped_ptr<char, base::AlignedFreeDeleter> buffer,
-                             size_t start_index,
-                             size_t current_num_bytes);
+  RemoteProducerDataPipeImpl(
+      ChannelEndpoint* channel_endpoint,
+      std::unique_ptr<char, base::AlignedFreeDeleter> buffer,
+      size_t start_index,
+      size_t current_num_bytes);
   ~RemoteProducerDataPipeImpl() override;
 
   // Processes messages that were received and queued by an |IncomingEndpoint|.
@@ -38,7 +40,7 @@
   static bool ProcessMessagesFromIncomingEndpoint(
       const MojoCreateDataPipeOptions& validated_options,
       MessageInTransitQueue* messages,
-      scoped_ptr<char, base::AlignedFreeDeleter>* buffer,
+      std::unique_ptr<char, base::AlignedFreeDeleter>* buffer,
       size_t* buffer_num_bytes);
 
  private:
@@ -107,7 +109,7 @@
   // Should be valid if and only if |producer_open()| returns true.
   scoped_refptr<ChannelEndpoint> channel_endpoint_;
 
-  scoped_ptr<char, base::AlignedFreeDeleter> buffer_;
+  std::unique_ptr<char, base::AlignedFreeDeleter> buffer_;
   // Circular buffer.
   size_t start_index_;
   size_t current_num_bytes_;
diff --git a/mojo/edk/system/transport_data.h b/mojo/edk/system/transport_data.h
index 20bb80f..cc140e7 100644
--- a/mojo/edk/system/transport_data.h
+++ b/mojo/edk/system/transport_data.h
@@ -7,6 +7,7 @@
 
 #include <stdint.h>
 
+#include <memory>
 #include <vector>
 
 #include "base/memory/aligned_memory.h"
@@ -174,7 +175,7 @@
   }
 
   size_t buffer_size_;
-  scoped_ptr<char, base::AlignedFreeDeleter> buffer_;  // Never null.
+  std::unique_ptr<char, base::AlignedFreeDeleter> buffer_;  // Never null.
 
   // Any platform-specific handles attached to this message (for inter-process
   // transport). The vector (if any) owns the handles that it contains (and is