Replace scoped_ptr with unique_ptr in webrtc/modules/

Except in places where this would break out-of-tree code,
such as Chromium.

BUG=webrtc:5520

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

Cr-Commit-Position: refs/heads/master@{#12037}
diff --git a/webrtc/modules/audio_coding/acm2/rent_a_codec_unittest.cc b/webrtc/modules/audio_coding/acm2/rent_a_codec_unittest.cc
index cbdd5e9..d0a94cf 100644
--- a/webrtc/modules/audio_coding/acm2/rent_a_codec_unittest.cc
+++ b/webrtc/modules/audio_coding/acm2/rent_a_codec_unittest.cc
@@ -8,6 +8,8 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include <memory>
+
 #include "testing/gtest/include/gtest/gtest.h"
 #include "webrtc/base/arraysize.h"
 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h"
diff --git a/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h b/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h
index 13d30c3..22c6a23 100644
--- a/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h
+++ b/webrtc/modules/audio_conference_mixer/source/audio_conference_mixer_impl.h
@@ -13,8 +13,8 @@
 
 #include <list>
 #include <map>
+#include <memory>
 
-#include "webrtc/base/scoped_ptr.h"
 #include "webrtc/engine_configurations.h"
 #include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer.h"
 #include "webrtc/modules/audio_conference_mixer/source/memory_pool.h"
@@ -142,8 +142,8 @@
 
     bool LimitMixedAudio(AudioFrame* mixedAudio) const;
 
-    rtc::scoped_ptr<CriticalSectionWrapper> _crit;
-    rtc::scoped_ptr<CriticalSectionWrapper> _cbCrit;
+    std::unique_ptr<CriticalSectionWrapper> _crit;
+    std::unique_ptr<CriticalSectionWrapper> _cbCrit;
 
     int32_t _id;
 
@@ -179,7 +179,7 @@
     int16_t _processCalls;
 
     // Used for inhibiting saturation in mixing.
-    rtc::scoped_ptr<AudioProcessing> _limiter;
+    std::unique_ptr<AudioProcessing> _limiter;
 };
 }  // namespace webrtc
 
diff --git a/webrtc/modules/audio_conference_mixer/test/audio_conference_mixer_unittest.cc b/webrtc/modules/audio_conference_mixer/test/audio_conference_mixer_unittest.cc
index f393e0f..e553e45 100644
--- a/webrtc/modules/audio_conference_mixer/test/audio_conference_mixer_unittest.cc
+++ b/webrtc/modules/audio_conference_mixer/test/audio_conference_mixer_unittest.cc
@@ -8,8 +8,9 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include <memory>
+
 #include "testing/gmock/include/gmock/gmock.h"
-#include "webrtc/base/scoped_ptr.h"
 #include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer.h"
 #include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer_defines.h"
 
@@ -56,7 +57,7 @@
   const int kAnonymous =
       AudioConferenceMixer::kMaximumAmountOfMixedParticipants + 1;
 
-  rtc::scoped_ptr<AudioConferenceMixer> mixer(
+  std::unique_ptr<AudioConferenceMixer> mixer(
       AudioConferenceMixer::Create(kId));
 
   MockMixerParticipant named[kNamed];
@@ -108,7 +109,7 @@
       AudioConferenceMixer::kMaximumAmountOfMixedParticipants + 3;
   const int kSampleRateHz = 32000;
 
-  rtc::scoped_ptr<AudioConferenceMixer> mixer(
+  std::unique_ptr<AudioConferenceMixer> mixer(
       AudioConferenceMixer::Create(kId));
 
   MockAudioMixerOutputReceiver output_receiver;
diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_impl.h b/webrtc/modules/bitrate_controller/bitrate_controller_impl.h
index da42b4c..6f776d7 100644
--- a/webrtc/modules/bitrate_controller/bitrate_controller_impl.h
+++ b/webrtc/modules/bitrate_controller/bitrate_controller_impl.h
@@ -21,7 +21,6 @@
 #include <utility>
 
 #include "webrtc/base/criticalsection.h"
-#include "webrtc/base/scoped_ptr.h"
 #include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h"
 
 namespace webrtc {
diff --git a/webrtc/modules/congestion_controller/congestion_controller.cc b/webrtc/modules/congestion_controller/congestion_controller.cc
index aafab66..11ce46a 100644
--- a/webrtc/modules/congestion_controller/congestion_controller.cc
+++ b/webrtc/modules/congestion_controller/congestion_controller.cc
@@ -11,6 +11,7 @@
 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
 
 #include <algorithm>
+#include <memory>
 #include <vector>
 
 #include "webrtc/base/checks.h"
@@ -123,8 +124,8 @@
 
   RemoteBitrateObserver* observer_;
   Clock* const clock_;
-  rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_;
-  rtc::scoped_ptr<RemoteBitrateEstimator> rbe_;
+  std::unique_ptr<CriticalSectionWrapper> crit_sect_;
+  std::unique_ptr<RemoteBitrateEstimator> rbe_;
   bool using_absolute_send_time_;
   uint32_t packets_since_absolute_send_time_;
   int min_bitrate_bps_;
diff --git a/webrtc/modules/pacing/paced_sender.h b/webrtc/modules/pacing/paced_sender.h
index e2c757d..16569b0 100644
--- a/webrtc/modules/pacing/paced_sender.h
+++ b/webrtc/modules/pacing/paced_sender.h
@@ -12,9 +12,9 @@
 #define WEBRTC_MODULES_PACING_PACED_SENDER_H_
 
 #include <list>
+#include <memory>
 #include <set>
 
-#include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/thread_annotations.h"
 #include "webrtc/modules/include/module.h"
 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
@@ -136,20 +136,20 @@
   Clock* const clock_;
   Callback* const callback_;
 
-  rtc::scoped_ptr<CriticalSectionWrapper> critsect_;
+  std::unique_ptr<CriticalSectionWrapper> critsect_;
   bool paused_ GUARDED_BY(critsect_);
   bool probing_enabled_;
   // This is the media budget, keeping track of how many bits of media
   // we can pace out during the current interval.
-  rtc::scoped_ptr<paced_sender::IntervalBudget> media_budget_
+  std::unique_ptr<paced_sender::IntervalBudget> media_budget_
       GUARDED_BY(critsect_);
   // This is the padding budget, keeping track of how many bits of padding we're
   // allowed to send out during the current interval. This budget will be
   // utilized when there's no media to send.
-  rtc::scoped_ptr<paced_sender::IntervalBudget> padding_budget_
+  std::unique_ptr<paced_sender::IntervalBudget> padding_budget_
       GUARDED_BY(critsect_);
 
-  rtc::scoped_ptr<BitrateProber> prober_ GUARDED_BY(critsect_);
+  std::unique_ptr<BitrateProber> prober_ GUARDED_BY(critsect_);
   // Actual configured bitrates (media_budget_ may temporarily be higher in
   // order to meet pace time constraint).
   int bitrate_bps_ GUARDED_BY(critsect_);
@@ -157,7 +157,7 @@
 
   int64_t time_last_update_us_ GUARDED_BY(critsect_);
 
-  rtc::scoped_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_);
+  std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_);
   uint64_t packet_counter_;
 };
 }  // namespace webrtc
diff --git a/webrtc/modules/pacing/paced_sender_unittest.cc b/webrtc/modules/pacing/paced_sender_unittest.cc
index 2c13833..941c813 100644
--- a/webrtc/modules/pacing/paced_sender_unittest.cc
+++ b/webrtc/modules/pacing/paced_sender_unittest.cc
@@ -9,6 +9,7 @@
  */
 
 #include <list>
+#include <memory>
 
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -134,7 +135,7 @@
 
   SimulatedClock clock_;
   MockPacedSenderCallback callback_;
-  rtc::scoped_ptr<PacedSender> send_bucket_;
+  std::unique_ptr<PacedSender> send_bucket_;
 };
 
 TEST_F(PacedSenderTest, QueuePacket) {
diff --git a/webrtc/modules/pacing/packet_router.h b/webrtc/modules/pacing/packet_router.h
index 12f0a90..635b931 100644
--- a/webrtc/modules/pacing/packet_router.h
+++ b/webrtc/modules/pacing/packet_router.h
@@ -15,7 +15,6 @@
 
 #include "webrtc/base/constructormagic.h"
 #include "webrtc/base/criticalsection.h"
-#include "webrtc/base/scoped_ptr.h"
 #include "webrtc/base/thread_annotations.h"
 #include "webrtc/base/thread_checker.h"
 #include "webrtc/common_types.h"
diff --git a/webrtc/modules/pacing/packet_router_unittest.cc b/webrtc/modules/pacing/packet_router_unittest.cc
index 4649358..faf270c 100644
--- a/webrtc/modules/pacing/packet_router_unittest.cc
+++ b/webrtc/modules/pacing/packet_router_unittest.cc
@@ -9,6 +9,7 @@
  */
 
 #include <list>
+#include <memory>
 
 #include "webrtc/base/checks.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -17,7 +18,6 @@
 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
 #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h"
 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
-#include "webrtc/base/scoped_ptr.h"
 
 using ::testing::_;
 using ::testing::AnyNumber;
@@ -30,7 +30,7 @@
  public:
   PacketRouterTest() : packet_router_(new PacketRouter()) {}
  protected:
-  const rtc::scoped_ptr<PacketRouter> packet_router_;
+  const std::unique_ptr<PacketRouter> packet_router_;
 };
 
 TEST_F(PacketRouterTest, TimeToSendPacket) {
diff --git a/webrtc/modules/utility/include/mock/mock_process_thread.h b/webrtc/modules/utility/include/mock/mock_process_thread.h
index 56d92f4..9560e40 100644
--- a/webrtc/modules/utility/include/mock/mock_process_thread.h
+++ b/webrtc/modules/utility/include/mock/mock_process_thread.h
@@ -11,6 +11,8 @@
 #ifndef WEBRTC_MODULES_UTILITY_INCLUDE_MOCK_MOCK_PROCESS_THREAD_H_
 #define WEBRTC_MODULES_UTILITY_INCLUDE_MOCK_MOCK_PROCESS_THREAD_H_
 
+#include <memory>
+
 #include "webrtc/modules/utility/include/process_thread.h"
 
 #include "testing/gmock/include/gmock/gmock.h"
diff --git a/webrtc/modules/utility/source/coder.h b/webrtc/modules/utility/source/coder.h
index abfa87e..399edbd 100644
--- a/webrtc/modules/utility/source/coder.h
+++ b/webrtc/modules/utility/source/coder.h
@@ -11,7 +11,8 @@
 #ifndef WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_
 #define WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_
 
-#include "webrtc/base/scoped_ptr.h"
+#include <memory>
+
 #include "webrtc/common_types.h"
 #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
 #include "webrtc/typedefs.h"
@@ -46,7 +47,7 @@
                   const RTPFragmentationHeader* fragmentation) override;
 
 private:
- rtc::scoped_ptr<AudioCodingModule> _acm;
+ std::unique_ptr<AudioCodingModule> _acm;
 
     CodecInst _receiveCodec;
 
diff --git a/webrtc/modules/utility/source/helpers_ios.mm b/webrtc/modules/utility/source/helpers_ios.mm
index 3d7567b..2afcb29 100644
--- a/webrtc/modules/utility/source/helpers_ios.mm
+++ b/webrtc/modules/utility/source/helpers_ios.mm
@@ -15,9 +15,10 @@
 #import <sys/sysctl.h>
 #import <UIKit/UIKit.h>
 
+#include <memory>
+
 #include "webrtc/base/checks.h"
 #include "webrtc/base/logging.h"
-#include "webrtc/base/scoped_ptr.h"
 #include "webrtc/modules/utility/include/helpers_ios.h"
 
 namespace webrtc {
@@ -152,7 +153,7 @@
 std::string GetDeviceName() {
   size_t size;
   sysctlbyname("hw.machine", NULL, &size, NULL, 0);
-  rtc::scoped_ptr<char[]> machine;
+  std::unique_ptr<char[]> machine;
   machine.reset(new char[size]);
   sysctlbyname("hw.machine", machine.get(), &size, NULL, 0);
   return std::string(LookUpRealName(machine.get()));
diff --git a/webrtc/modules/utility/source/process_thread_impl.h b/webrtc/modules/utility/source/process_thread_impl.h
index 1c0a0cd..2855ed9 100644
--- a/webrtc/modules/utility/source/process_thread_impl.h
+++ b/webrtc/modules/utility/source/process_thread_impl.h
@@ -12,6 +12,7 @@
 #define WEBRTC_MODULES_UTILITY_SOURCE_PROCESS_THREAD_IMPL_H_
 
 #include <list>
+#include <memory>
 #include <queue>
 
 #include "webrtc/base/criticalsection.h"
@@ -69,9 +70,9 @@
   rtc::CriticalSection lock_;  // Used to guard modules_, tasks_ and stop_.
 
   rtc::ThreadChecker thread_checker_;
-  const rtc::scoped_ptr<EventWrapper> wake_up_;
-  // TODO(pbos): Remove scoped_ptr and stop recreating the thread.
-  rtc::scoped_ptr<rtc::PlatformThread> thread_;
+  const std::unique_ptr<EventWrapper> wake_up_;
+  // TODO(pbos): Remove unique_ptr and stop recreating the thread.
+  std::unique_ptr<rtc::PlatformThread> thread_;
 
   ModuleList modules_;
   // TODO(tommi): Support delayed tasks.
diff --git a/webrtc/modules/utility/source/process_thread_impl_unittest.cc b/webrtc/modules/utility/source/process_thread_impl_unittest.cc
index 4f70e8a..9fa9edf 100644
--- a/webrtc/modules/utility/source/process_thread_impl_unittest.cc
+++ b/webrtc/modules/utility/source/process_thread_impl_unittest.cc
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include <memory>
 #include <utility>
 
 #include "testing/gmock/include/gmock/gmock.h"
@@ -72,7 +73,7 @@
   ProcessThreadImpl thread("ProcessThread");
   thread.Start();
 
-  rtc::scoped_ptr<EventWrapper> event(EventWrapper::Create());
+  std::unique_ptr<EventWrapper> event(EventWrapper::Create());
 
   MockModule module;
   EXPECT_CALL(module, TimeUntilNextProcess()).WillRepeatedly(Return(0));
@@ -92,7 +93,7 @@
 // call to Start().
 TEST(ProcessThreadImpl, ProcessCall2) {
   ProcessThreadImpl thread("ProcessThread");
-  rtc::scoped_ptr<EventWrapper> event(EventWrapper::Create());
+  std::unique_ptr<EventWrapper> event(EventWrapper::Create());
 
   MockModule module;
   EXPECT_CALL(module, TimeUntilNextProcess()).WillRepeatedly(Return(0));
@@ -114,7 +115,7 @@
 // After unregistration, we should not receive any further callbacks.
 TEST(ProcessThreadImpl, Deregister) {
   ProcessThreadImpl thread("ProcessThread");
-  rtc::scoped_ptr<EventWrapper> event(EventWrapper::Create());
+  std::unique_ptr<EventWrapper> event(EventWrapper::Create());
 
   int process_count = 0;
   MockModule module;
@@ -151,7 +152,7 @@
   ProcessThreadImpl thread("ProcessThread");
   thread.Start();
 
-  rtc::scoped_ptr<EventWrapper> event(EventWrapper::Create());
+  std::unique_ptr<EventWrapper> event(EventWrapper::Create());
 
   MockModule module;
   int64_t start_time = 0;
@@ -216,7 +217,7 @@
   ProcessThreadImpl thread("ProcessThread");
   thread.Start();
 
-  rtc::scoped_ptr<EventWrapper> event(EventWrapper::Create());
+  std::unique_ptr<EventWrapper> event(EventWrapper::Create());
 
   MockModule module;
   int callback_count = 0;
@@ -249,8 +250,8 @@
   ProcessThreadImpl thread("ProcessThread");
   thread.Start();
 
-  rtc::scoped_ptr<EventWrapper> started(EventWrapper::Create());
-  rtc::scoped_ptr<EventWrapper> called(EventWrapper::Create());
+  std::unique_ptr<EventWrapper> started(EventWrapper::Create());
+  std::unique_ptr<EventWrapper> called(EventWrapper::Create());
 
   MockModule module;
   int64_t start_time;
@@ -293,10 +294,10 @@
 // thread.
 TEST(ProcessThreadImpl, PostTask) {
   ProcessThreadImpl thread("ProcessThread");
-  rtc::scoped_ptr<EventWrapper> task_ran(EventWrapper::Create());
-  rtc::scoped_ptr<RaiseEventTask> task(new RaiseEventTask(task_ran.get()));
+  std::unique_ptr<EventWrapper> task_ran(EventWrapper::Create());
+  std::unique_ptr<RaiseEventTask> task(new RaiseEventTask(task_ran.get()));
   thread.Start();
-  thread.PostTask(std::move(task));
+  thread.PostTask(rtc::UniqueToScoped(std::move(task)));
   EXPECT_EQ(kEventSignaled, task_ran->Wait(100));
   thread.Stop();
 }
diff --git a/webrtc/modules/video_coding/nack_module_unittest.cc b/webrtc/modules/video_coding/nack_module_unittest.cc
index 189a1be..fab03ce 100644
--- a/webrtc/modules/video_coding/nack_module_unittest.cc
+++ b/webrtc/modules/video_coding/nack_module_unittest.cc
@@ -9,6 +9,8 @@
  */
 
 #include <cstring>
+#include <memory>
+
 #include "testing/gtest/include/gtest/gtest.h"
 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
 #include "webrtc/modules/video_coding/nack_module.h"