Replace scoped_ptr with unique_ptr in webrtc/api/

But keep #including scoped_ptr.h in .h files, so as not to break
WebRTC users who expect those .h files to give them rtc::scoped_ptr.

BUG=webrtc:5520

Review URL: https://codereview.webrtc.org/1930463002

Cr-Commit-Position: refs/heads/master@{#12530}
diff --git a/webrtc/api/java/jni/androidmediadecoder_jni.cc b/webrtc/api/java/jni/androidmediadecoder_jni.cc
index c83be18..a0e5579 100644
--- a/webrtc/api/java/jni/androidmediadecoder_jni.cc
+++ b/webrtc/api/java/jni/androidmediadecoder_jni.cc
@@ -9,6 +9,7 @@
  */
 
 #include <algorithm>
+#include <memory>
 #include <vector>
 
 // NOTICE: androidmediadecoder_jni.h must be included before
@@ -36,7 +37,6 @@
 using rtc::Bind;
 using rtc::Thread;
 using rtc::ThreadManager;
-using rtc::scoped_ptr;
 
 using webrtc::CodecSpecificInfo;
 using webrtc::DecodedImageCallback;
@@ -137,7 +137,8 @@
 
   // State that is constant for the lifetime of this object once the ctor
   // returns.
-  scoped_ptr<Thread> codec_thread_;  // Thread on which to operate MediaCodec.
+  std::unique_ptr<Thread>
+      codec_thread_;  // Thread on which to operate MediaCodec.
   ScopedGlobalRef<jclass> j_media_codec_video_decoder_class_;
   ScopedGlobalRef<jobject> j_media_codec_video_decoder_;
   jmethodID j_init_decode_method_;
diff --git a/webrtc/api/java/jni/androidmediaencoder_jni.cc b/webrtc/api/java/jni/androidmediaencoder_jni.cc
index e88a94c..b7f2da4 100644
--- a/webrtc/api/java/jni/androidmediaencoder_jni.cc
+++ b/webrtc/api/java/jni/androidmediaencoder_jni.cc
@@ -13,6 +13,7 @@
 #include "webrtc/api/java/jni/androidmediaencoder_jni.h"
 
 #include <algorithm>
+#include <memory>
 #include <list>
 
 #include "third_party/libyuv/include/libyuv/convert.h"
@@ -37,7 +38,6 @@
 using rtc::Bind;
 using rtc::Thread;
 using rtc::ThreadManager;
-using rtc::scoped_ptr;
 
 using webrtc::CodecSpecificInfo;
 using webrtc::EncodedImage;
@@ -182,7 +182,8 @@
 
   // State that is constant for the lifetime of this object once the ctor
   // returns.
-  scoped_ptr<Thread> codec_thread_;  // Thread on which to operate MediaCodec.
+  std::unique_ptr<Thread>
+      codec_thread_;  // Thread on which to operate MediaCodec.
   rtc::ThreadChecker codec_thread_checker_;
   ScopedGlobalRef<jclass> j_media_codec_video_encoder_class_;
   ScopedGlobalRef<jobject> j_media_codec_video_encoder_;
@@ -973,7 +974,7 @@
     // Callback - return encoded frame.
     int32_t callback_status = 0;
     if (callback_) {
-      scoped_ptr<webrtc::EncodedImage> image(
+      std::unique_ptr<webrtc::EncodedImage> image(
           new webrtc::EncodedImage(payload, payload_size, payload_size));
       image->_encodedWidth = width_;
       image->_encodedHeight = height_;
diff --git a/webrtc/api/java/jni/androidvideocapturer_jni.h b/webrtc/api/java/jni/androidvideocapturer_jni.h
index 53f1803..eea56ad 100644
--- a/webrtc/api/java/jni/androidvideocapturer_jni.h
+++ b/webrtc/api/java/jni/androidvideocapturer_jni.h
@@ -11,6 +11,7 @@
 #ifndef WEBRTC_API_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_
 #define WEBRTC_API_JAVA_JNI_ANDROIDVIDEOCAPTURER_JNI_H_
 
+#include <memory>
 #include <string>
 
 #include "webrtc/api/androidvideocapturer.h"
@@ -87,7 +88,7 @@
   webrtc::AndroidVideoCapturer* capturer_ GUARDED_BY(capturer_lock_);
   // |invoker_| is used to communicate with |capturer_| on the thread Start() is
   // called on.
-  rtc::scoped_ptr<rtc::GuardedAsyncInvoker> invoker_ GUARDED_BY(capturer_lock_);
+  std::unique_ptr<rtc::GuardedAsyncInvoker> invoker_ GUARDED_BY(capturer_lock_);
 
   static jobject application_context_;
 
diff --git a/webrtc/api/java/jni/native_handle_impl.cc b/webrtc/api/java/jni/native_handle_impl.cc
index d52584a..1990828 100644
--- a/webrtc/api/java/jni/native_handle_impl.cc
+++ b/webrtc/api/java/jni/native_handle_impl.cc
@@ -10,12 +10,13 @@
 
 #include "webrtc/api/java/jni/native_handle_impl.h"
 
+#include <memory>
+
 #include "webrtc/api/java/jni/jni_helpers.h"
 #include "webrtc/base/bind.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/keep_ref_until_done.h"
 #include "webrtc/base/logging.h"
-#include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/scoped_ref_ptr.h"
 
 using webrtc::NativeHandleBuffer;
@@ -104,7 +105,7 @@
   //
   // TODO(nisse): Use an I420BufferPool. We then need to extend that
   // class, and I420Buffer, to support our memory layout.
-  rtc::scoped_ptr<uint8_t, webrtc::AlignedFreeDeleter> yuv_data(
+  std::unique_ptr<uint8_t, webrtc::AlignedFreeDeleter> yuv_data(
       static_cast<uint8_t*>(webrtc::AlignedMalloc(size, kBufferAlignment)));
   // See SurfaceTextureHelper.java for the required layout.
   uint8_t* y_data = yuv_data.get();
diff --git a/webrtc/api/java/jni/peerconnection_jni.cc b/webrtc/api/java/jni/peerconnection_jni.cc
index b0757e2..228e5e1 100644
--- a/webrtc/api/java/jni/peerconnection_jni.cc
+++ b/webrtc/api/java/jni/peerconnection_jni.cc
@@ -80,7 +80,6 @@
 using rtc::Bind;
 using rtc::Thread;
 using rtc::ThreadManager;
-using rtc::scoped_ptr;
 using webrtc::AudioSourceInterface;
 using webrtc::AudioTrackInterface;
 using webrtc::AudioTrackVector;
@@ -427,7 +426,7 @@
   // C++ -> Java remote streams. The stored jobects are global refs and must be
   // manually deleted upon removal. Use DisposeRemoteStream().
   NativeToJavaStreamsMap remote_streams_;
-  scoped_ptr<ConstraintsWrapper> constraints_;
+  std::unique_ptr<ConstraintsWrapper> constraints_;
 };
 
 // Wrapper for a Java MediaConstraints object.  Copies all needed data so when
@@ -549,7 +548,7 @@
   }
 
  private:
-  scoped_ptr<ConstraintsWrapper> constraints_;
+  std::unique_ptr<ConstraintsWrapper> constraints_;
   const ScopedGlobalRef<jobject> j_observer_global_;
   const ScopedGlobalRef<jclass> j_observer_class_;
 };
@@ -822,7 +821,7 @@
 
 JOW(jlong, DataChannel_registerObserverNative)(
     JNIEnv* jni, jobject j_dc, jobject j_observer) {
-  scoped_ptr<DataChannelObserverWrapper> observer(
+  std::unique_ptr<DataChannelObserverWrapper> observer(
       new DataChannelObserverWrapper(jni, j_observer));
   ExtractNativeDC(jni, j_dc)->RegisterObserver(observer.get());
   return jlongFromPointer(observer.release());
@@ -1067,8 +1066,8 @@
  private:
   void JavaCallbackOnFactoryThreads();
 
-  const scoped_ptr<Thread> worker_thread_;
-  const scoped_ptr<Thread> signaling_thread_;
+  const std::unique_ptr<Thread> worker_thread_;
+  const std::unique_ptr<Thread> signaling_thread_;
   WebRtcVideoEncoderFactory* encoder_factory_;
   WebRtcVideoDecoderFactory* decoder_factory_;
   rtc::NetworkMonitorFactory* network_monitor_factory_;
@@ -1225,11 +1224,11 @@
   rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate =
       new rtc::RefCountedObject<AndroidVideoCapturerJni>(
           jni, j_video_capturer, j_egl_context);
-  rtc::scoped_ptr<cricket::VideoCapturer> capturer(
+  std::unique_ptr<cricket::VideoCapturer> capturer(
       new webrtc::AndroidVideoCapturer(delegate));
   // Create a webrtc::VideoTrackSourceInterface from the cricket::VideoCapturer,
   // native factory and constraints.
-  scoped_ptr<ConstraintsWrapper> constraints(
+  std::unique_ptr<ConstraintsWrapper> constraints(
       new ConstraintsWrapper(jni, j_constraints));
   rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
       factoryFromJava(native_factory));
@@ -1251,7 +1250,7 @@
 
 JOW(jlong, PeerConnectionFactory_nativeCreateAudioSource)(
     JNIEnv* jni, jclass, jlong native_factory, jobject j_constraints) {
-  scoped_ptr<ConstraintsWrapper> constraints(
+  std::unique_ptr<ConstraintsWrapper> constraints(
       new ConstraintsWrapper(jni, j_constraints));
   rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
       factoryFromJava(native_factory));
@@ -1706,7 +1705,7 @@
     jint j_sdp_mline_index, jstring j_candidate_sdp) {
   std::string sdp_mid = JavaToStdString(jni, j_sdp_mid);
   std::string sdp = JavaToStdString(jni, j_candidate_sdp);
-  scoped_ptr<IceCandidateInterface> candidate(
+  std::unique_ptr<IceCandidateInterface> candidate(
       webrtc::CreateIceCandidate(sdp_mid, j_sdp_mline_index, sdp, NULL));
   return ExtractNativePC(jni, j_pc)->AddIceCandidate(candidate.get());
 }
@@ -1871,7 +1870,7 @@
 
 JOW(jlong, VideoRenderer_nativeWrapVideoRenderer)(
     JNIEnv* jni, jclass, jobject j_callbacks) {
-  scoped_ptr<JavaVideoRendererWrapper> renderer(
+  std::unique_ptr<JavaVideoRendererWrapper> renderer(
       new JavaVideoRendererWrapper(jni, j_callbacks));
   return (jlong)renderer.release();
 }
@@ -1985,7 +1984,7 @@
 JOW(jbyteArray, CallSessionFileRotatingLogSink_nativeGetLogData)(
     JNIEnv* jni, jclass, jstring j_dirPath) {
   std::string dir_path = JavaToStdString(jni, j_dirPath);
-  rtc::scoped_ptr<rtc::CallSessionFileRotatingStream> stream(
+  std::unique_ptr<rtc::CallSessionFileRotatingStream> stream(
       new rtc::CallSessionFileRotatingStream(dir_path));
   if (!stream->Open()) {
     LOG_V(rtc::LoggingSeverity::LS_WARNING) <<
@@ -2000,7 +1999,7 @@
   }
 
   size_t read = 0;
-  rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size)));
+  std::unique_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size)));
   stream->ReadAll(buffer.get(), log_size, &read, nullptr);
 
   jbyteArray result = jni->NewByteArray(read);