Revert of Add CreateWindowCapturer() and CreateScreenCapturer() in DesktopCapturer (patchset #2 id:40001 of https://codereview.webrtc.org/2468753002/ )

Reason for revert:
Prevents WebRTC rolls into Chrome.

https://build.chromium.org/p/chromium.linux/builders/Blimp%20Linux%20%28dbg%29/builds/14848/steps/compile/logs/stdio

The reason for reverting is: Breaks
https://build.chromium.org/p/chromium.linux/builders/Blimp%20Linux%20%28dbg%2...
[881/894] SOLINK ./libcontent.so
FAILED: libcontent.so libcontent.so.TOC
../../third_party/webrtc/modules/desktop_capture/desktop_capturer.cc:45: error:
undefined reference to
'webrtc::DesktopCapturer::CreateRawWindowCapturer(webrtc::DesktopCaptureOptions
const&)'
../../third_party/webrtc/modules/desktop_capture/desktop_capturer.cc:56: error:
undefined reference to
'webrtc::DesktopCapturer::CreateRawScreenCapturer(webrtc::DesktopCaptureOptions
const&)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Original issue's description:
> Add CreateWindowCapturer() and CreateScreenCapturer() in DesktopCapturer
>
> This change copies ScreenCapturerDifferWrapper to a new
> DesktopCapturerDifferWrapper, and adds DesktopCapturer::CreateWindowCapturer and
> DesktopCapturer::CreateScreenCapturer functions to replace
> WindowCapturer::Create and ScreenCapturer::Create.
>
> BUG=webrtc:6513
>
> Committed: https://crrev.com/b763e39beba92b45baa09542f949daabbe6258a3
> Cr-Commit-Position: refs/heads/master@{#14880}

TBR=sergeyu@chromium.org,zijiehe@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6513

Review-Url: https://codereview.webrtc.org/2471773002
Cr-Commit-Position: refs/heads/master@{#14884}
diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn
index fa58999..6a1564b 100644
--- a/webrtc/modules/BUILD.gn
+++ b/webrtc/modules/BUILD.gn
@@ -8,11 +8,10 @@
 
 import("../build/webrtc.gni")
 import("audio_coding/audio_coding.gni")
-import("desktop_capture/desktop_capture.gni")
 
 declare_args() {
   # Desktop capturer is supported only on Windows, OSX and Linux.
-  rtc_desktop_capture_supported = rtc_desktop_capture_supported
+  rtc_desktop_capture_supported = is_win || is_mac || is_linux
 }
 
 group("modules") {
@@ -103,11 +102,8 @@
     ]
 
     if (rtc_desktop_capture_supported) {
-      deps += [ "desktop_capture:screen_drawer" ]
-      sources += [
-        "desktop_capture/screen_capturer_integration_test.cc",
-        "desktop_capture/screen_drawer_unittest.cc",
-      ]
+      deps += [ "desktop_capture:desktop_capture_test_tools" ]
+      sources += [ "desktop_capture/screen_capturer_integration_test.cc" ]
     }
 
     data = modules_tests_resources
@@ -549,10 +545,14 @@
     }
 
     if (rtc_desktop_capture_supported) {
-      deps += [ "desktop_capture:desktop_capture_mock" ]
+      deps += [ "desktop_capture:desktop_capture_test_tools" ]
       sources += [
         "desktop_capture/desktop_and_cursor_composer_unittest.cc",
-        "desktop_capture/desktop_capturer_differ_wrapper_unittest.cc",
+        "desktop_capture/desktop_frame_generator.cc",
+        "desktop_capture/desktop_frame_generator.h",
+        "desktop_capture/fake_desktop_capturer.h",
+        "desktop_capture/fake_screen_capturer.cc",
+        "desktop_capture/fake_screen_capturer.h",
         "desktop_capture/mouse_cursor_monitor_unittest.cc",
         "desktop_capture/rgba_color_unittest.cc",
         "desktop_capture/screen_capturer_differ_wrapper_unittest.cc",
@@ -560,6 +560,7 @@
         "desktop_capture/screen_capturer_mac_unittest.cc",
         "desktop_capture/screen_capturer_mock_objects.h",
         "desktop_capture/screen_capturer_unittest.cc",
+        "desktop_capture/screen_drawer_unittest.cc",
         "desktop_capture/win/cursor_unittest.cc",
         "desktop_capture/win/cursor_unittest_resources.h",
         "desktop_capture/win/cursor_unittest_resources.rc",
diff --git a/webrtc/modules/desktop_capture/BUILD.gn b/webrtc/modules/desktop_capture/BUILD.gn
index 1cb421e..5529537 100644
--- a/webrtc/modules/desktop_capture/BUILD.gn
+++ b/webrtc/modules/desktop_capture/BUILD.gn
@@ -8,7 +8,6 @@
 
 import("//build/config/ui.gni")
 import("../../build/webrtc.gni")
-import("desktop_capture.gni")
 
 use_desktop_capture_differ_sse2 =
     !is_ios && (current_cpu == "x86" || current_cpu == "x64")
@@ -32,7 +31,7 @@
 }
 
 if (rtc_include_tests) {
-  source_set("rgba_color") {
+  source_set("desktop_capture_test_tools") {
     testonly = true
 
     public_deps = [
@@ -42,17 +41,6 @@
     sources = [
       "rgba_color.cc",
       "rgba_color.h",
-    ]
-  }
-
-  source_set("screen_drawer") {
-    testonly = true
-
-    public_deps = [
-      ":rgba_color",
-    ]
-
-    sources = [
       "screen_drawer.cc",
       "screen_drawer.h",
       "screen_drawer_linux.cc",
@@ -60,25 +48,6 @@
       "screen_drawer_win.cc",
     ]
   }
-
-  source_set("desktop_capture_mock") {
-    testonly = true
-
-    public_deps = [
-      ":desktop_capture",
-      ":rgba_color",
-    ]
-
-    sources = [
-      "desktop_frame_generator.cc",
-      "desktop_frame_generator.h",
-      "fake_desktop_capturer.h",
-      "fake_screen_capturer.cc",
-      "fake_screen_capturer.h",
-      "mock_desktop_capturer_callback.h",
-      "screen_capturer_mock_objects.h",
-    ]
-  }
 }
 
 rtc_static_library("desktop_capture") {
@@ -182,8 +151,6 @@
 
   if (!is_ios) {
     sources += [
-      "desktop_capturer_differ_wrapper.cc",
-      "desktop_capturer_differ_wrapper.h",
       "differ_block.cc",
       "differ_block.h",
       "screen_capturer_differ_wrapper.cc",
@@ -215,10 +182,6 @@
   if (use_desktop_capture_differ_sse2) {
     deps += [ ":desktop_capture_differ_sse2" ]
   }
-
-  if (rtc_desktop_capture_supported) {
-    defines = [ "RTC_DESKTOP_CAPTURE_SUPPORTED" ]
-  }
 }
 
 if (use_desktop_capture_differ_sse2) {
diff --git a/webrtc/modules/desktop_capture/desktop_capture.gni b/webrtc/modules/desktop_capture/desktop_capture.gni
deleted file mode 100644
index 02ad814..0000000
--- a/webrtc/modules/desktop_capture/desktop_capture.gni
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
-#
-# Use of this source code is governed by a BSD-style license
-# that can be found in the LICENSE file in the root of the source
-# tree. An additional intellectual property rights grant can be found
-# in the file PATENTS.  All contributing project authors may
-# be found in the AUTHORS file in the root of the source tree.
-
-import("../../build/webrtc.gni")
-
-rtc_desktop_capture_supported = is_win || is_mac || is_linux
diff --git a/webrtc/modules/desktop_capture/desktop_capture.gypi b/webrtc/modules/desktop_capture/desktop_capture.gypi
index b6d6f99..ab1fd32 100644
--- a/webrtc/modules/desktop_capture/desktop_capture.gypi
+++ b/webrtc/modules/desktop_capture/desktop_capture.gypi
@@ -141,8 +141,6 @@
         }],
         ['OS!="ios" ', {
           'sources': [
-            'desktop_capturer_differ_wrapper.cc',
-            'desktop_capturer_differ_wrapper.h',
             'differ_block.cc',
             'differ_block.h',
             'screen_capturer_differ_wrapper.cc',
diff --git a/webrtc/modules/desktop_capture/desktop_capturer.cc b/webrtc/modules/desktop_capture/desktop_capturer.cc
index f28630e..a18976a 100644
--- a/webrtc/modules/desktop_capture/desktop_capturer.cc
+++ b/webrtc/modules/desktop_capture/desktop_capturer.cc
@@ -11,7 +11,7 @@
 #include "webrtc/modules/desktop_capture/desktop_capturer.h"
 
 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
-#include "webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.h"
+#include "webrtc/modules/desktop_capture/screen_capturer_differ_wrapper.h"
 
 namespace webrtc {
 
@@ -34,32 +34,4 @@
   return false;
 }
 
-// Some platforms, such as ChromeOS, have their DesktopCapturer implementations
-// in Chromium. So even we do not have CreateRawWindowCapturer() or
-// CreateRawScreenCapturer() implemented in WebRTC, we still need to build other
-// DesktopCapturer components when RTC_DESKTOP_CAPTURE_SUPPORTED is not defined.
-#if defined(RTC_DESKTOP_CAPTURE_SUPPORTED)
-// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateWindowCapturer(
-    const DesktopCaptureOptions& options) {
-  std::unique_ptr<DesktopCapturer> capturer = CreateRawWindowCapturer(options);
-  if (options.detect_updated_region()) {
-    capturer.reset(new DesktopCapturerDifferWrapper(std::move(capturer)));
-  }
-
-  return capturer;
-}
-
-// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateScreenCapturer(
-    const DesktopCaptureOptions& options) {
-  std::unique_ptr<DesktopCapturer> capturer = CreateRawScreenCapturer(options);
-  if (options.detect_updated_region()) {
-    capturer.reset(new DesktopCapturerDifferWrapper(std::move(capturer)));
-  }
-
-  return capturer;
-}
-#endif  // defined(RTC_DESKTOP_CAPTURE_SUPPORTED)
-
 }  // namespace webrtc
diff --git a/webrtc/modules/desktop_capture/desktop_capturer.h b/webrtc/modules/desktop_capture/desktop_capturer.h
index ecae4cb..6b9c820 100644
--- a/webrtc/modules/desktop_capture/desktop_capturer.h
+++ b/webrtc/modules/desktop_capture/desktop_capturer.h
@@ -110,28 +110,6 @@
   // Returns false in case of a failure or no source has been selected or the
   // implementation does not support this functionality.
   virtual bool FocusOnSelectedSource();
-
-  // Creates a DesktopCapturer instance which targets to capture windows.
-  static std::unique_ptr<DesktopCapturer> CreateWindowCapturer(
-      const DesktopCaptureOptions& options);
-
-  // Creates a DesktopCapturer instance which targets to capture screens.
-  static std::unique_ptr<DesktopCapturer> CreateScreenCapturer(
-      const DesktopCaptureOptions& options);
-
- protected:
-  // CroppingWindowCapturer needs to create raw capturers without wrappers, so
-  // the following two functions are protected.
-
-  // Creates a platform specific DesktopCapturer instance which targets to
-  // capture windows.
-  static std::unique_ptr<DesktopCapturer> CreateRawWindowCapturer(
-      const DesktopCaptureOptions& options);
-
-  // Creates a platform specific DesktopCapturer instance which targets to
-  // capture screens.
-  static std::unique_ptr<DesktopCapturer> CreateRawScreenCapturer(
-      const DesktopCaptureOptions& options);
 };
 
 }  // namespace webrtc
diff --git a/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.cc b/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.cc
deleted file mode 100644
index 1ad9ce4..0000000
--- a/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.cc
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.h"
-
-#include <string.h>
-
-#include <algorithm>
-#include <utility>
-
-#include "webrtc/base/checks.h"
-#include "webrtc/base/timeutils.h"
-#include "webrtc/modules/desktop_capture/desktop_geometry.h"
-#include "webrtc/modules/desktop_capture/differ_block.h"
-
-namespace webrtc {
-
-namespace {
-
-// Returns true if (0, 0) - (|width|, |height|) vector in |old_buffer| and
-// |new_buffer| are equal. |width| should be less than 32
-// (defined by kBlockSize), otherwise BlockDifference() should be used.
-bool PartialBlockDifference(const uint8_t* old_buffer,
-                            const uint8_t* new_buffer,
-                            int width,
-                            int height,
-                            int stride) {
-  RTC_DCHECK_LT(width, kBlockSize);
-  const int width_bytes = width * DesktopFrame::kBytesPerPixel;
-  for (int i = 0; i < height; i++) {
-    if (memcmp(old_buffer, new_buffer, width_bytes) != 0) {
-      return true;
-    }
-    old_buffer += stride;
-    new_buffer += stride;
-  }
-  return false;
-}
-
-// Compares columns in the range of [|left|, |right|), in a row in the
-// range of [|top|, |top| + |height|), starts from |old_buffer| and
-// |new_buffer|, and outputs updated regions into |output|. |stride| is the
-// DesktopFrame::stride().
-void CompareRow(const uint8_t* old_buffer,
-                const uint8_t* new_buffer,
-                const int left,
-                const int right,
-                const int top,
-                const int bottom,
-                const int stride,
-                DesktopRegion* const output) {
-  const int block_x_offset = kBlockSize * DesktopFrame::kBytesPerPixel;
-  const int width = right - left;
-  const int height = bottom - top;
-  const int block_count = (width - 1) / kBlockSize;
-  const int last_block_width = width - block_count * kBlockSize;
-  RTC_DCHECK(last_block_width <= kBlockSize && last_block_width > 0);
-
-  // The first block-column in a continuous dirty area in current block-row.
-  int first_dirty_x_block = -1;
-
-  // We always need to add dirty area into |output| in the last block, so handle
-  // it separatedly.
-  for (int x = 0; x < block_count; x++) {
-    if (BlockDifference(old_buffer, new_buffer, height, stride)) {
-      if (first_dirty_x_block == -1) {
-        // This is the first dirty block in a continuous dirty area.
-        first_dirty_x_block = x;
-      }
-    } else if (first_dirty_x_block != -1) {
-      // The block on the left is the last dirty block in a continuous
-      // dirty area.
-      output->AddRect(
-          DesktopRect::MakeLTRB(first_dirty_x_block * kBlockSize + left, top,
-                                x * kBlockSize + left, bottom));
-      first_dirty_x_block = -1;
-    }
-    old_buffer += block_x_offset;
-    new_buffer += block_x_offset;
-  }
-
-  bool last_block_diff;
-  if (last_block_width < kBlockSize) {
-    // The last one is a partial vector.
-    last_block_diff = PartialBlockDifference(old_buffer, new_buffer,
-                                             last_block_width, height, stride);
-  } else {
-    last_block_diff = BlockDifference(old_buffer, new_buffer, height, stride);
-  }
-  if (last_block_diff) {
-    if (first_dirty_x_block == -1) {
-      first_dirty_x_block = block_count;
-    }
-    output->AddRect(DesktopRect::MakeLTRB(
-        first_dirty_x_block * kBlockSize + left, top, right, bottom));
-  } else if (first_dirty_x_block != -1) {
-    output->AddRect(
-        DesktopRect::MakeLTRB(first_dirty_x_block * kBlockSize + left, top,
-                              block_count * kBlockSize + left, bottom));
-  }
-}
-
-// Compares |rect| area in |old_frame| and |new_frame|, and outputs dirty
-// regions into |output|.
-void CompareFrames(const DesktopFrame& old_frame,
-                   const DesktopFrame& new_frame,
-                   DesktopRect rect,
-                   DesktopRegion* const output) {
-  RTC_DCHECK(old_frame.size().equals(new_frame.size()));
-  RTC_DCHECK_EQ(old_frame.stride(), new_frame.stride());
-  rect.IntersectWith(DesktopRect::MakeSize(old_frame.size()));
-
-  const int y_block_count = (rect.height() - 1) / kBlockSize;
-  const int last_y_block_height = rect.height() - y_block_count * kBlockSize;
-  // Offset from the start of one block-row to the next.
-  const int block_y_stride = old_frame.stride() * kBlockSize;
-  const uint8_t* prev_block_row_start =
-      old_frame.GetFrameDataAtPos(rect.top_left());
-  const uint8_t* curr_block_row_start =
-      new_frame.GetFrameDataAtPos(rect.top_left());
-
-  int top = rect.top();
-  // The last row may have a different height, so we handle it separately.
-  for (int y = 0; y < y_block_count; y++) {
-    CompareRow(prev_block_row_start, curr_block_row_start, rect.left(),
-               rect.right(), top, top + kBlockSize, old_frame.stride(), output);
-    top += kBlockSize;
-    prev_block_row_start += block_y_stride;
-    curr_block_row_start += block_y_stride;
-  }
-  CompareRow(prev_block_row_start, curr_block_row_start, rect.left(),
-             rect.right(), top, top + last_y_block_height, old_frame.stride(),
-             output);
-}
-
-}  // namespace
-
-DesktopCapturerDifferWrapper::DesktopCapturerDifferWrapper(
-    std::unique_ptr<DesktopCapturer> base_capturer)
-    : base_capturer_(std::move(base_capturer)) {
-  RTC_DCHECK(base_capturer_);
-}
-
-DesktopCapturerDifferWrapper::~DesktopCapturerDifferWrapper() {}
-
-void DesktopCapturerDifferWrapper::Start(DesktopCapturer::Callback* callback) {
-  callback_ = callback;
-  base_capturer_->Start(this);
-}
-
-void DesktopCapturerDifferWrapper::SetSharedMemoryFactory(
-    std::unique_ptr<SharedMemoryFactory> shared_memory_factory) {
-  base_capturer_->SetSharedMemoryFactory(std::move(shared_memory_factory));
-}
-
-void DesktopCapturerDifferWrapper::CaptureFrame() {
-  base_capturer_->CaptureFrame();
-}
-
-void DesktopCapturerDifferWrapper::SetExcludedWindow(WindowId window) {
-  base_capturer_->SetExcludedWindow(window);
-}
-
-bool DesktopCapturerDifferWrapper::GetSourceList(SourceList* sources) {
-  return base_capturer_->GetSourceList(sources);
-}
-
-bool DesktopCapturerDifferWrapper::SelectSource(SourceId id) {
-  return base_capturer_->SelectSource(id);
-}
-
-bool DesktopCapturerDifferWrapper::FocusOnSelectedSource() {
-  return base_capturer_->FocusOnSelectedSource();
-}
-
-void DesktopCapturerDifferWrapper::OnCaptureResult(
-    Result result,
-    std::unique_ptr<DesktopFrame> input_frame) {
-  int64_t start_time_nanos = rtc::TimeNanos();
-  if (!input_frame) {
-    callback_->OnCaptureResult(result, nullptr);
-    return;
-  }
-  RTC_DCHECK(result == Result::SUCCESS);
-
-  std::unique_ptr<SharedDesktopFrame> frame =
-      SharedDesktopFrame::Wrap(std::move(input_frame));
-  if (last_frame_ && (last_frame_->size().width() != frame->size().width() ||
-                      last_frame_->size().height() != frame->size().height() ||
-                      last_frame_->stride() != frame->stride())) {
-    last_frame_.reset();
-  }
-
-  if (last_frame_) {
-    DesktopRegion hints;
-    hints.Swap(frame->GetUnderlyingFrame()->mutable_updated_region());
-    for (DesktopRegion::Iterator it(hints); !it.IsAtEnd(); it.Advance()) {
-      CompareFrames(*last_frame_, *frame, it.rect(),
-                    frame->mutable_updated_region());
-    }
-  } else {
-    frame->mutable_updated_region()->SetRect(
-        DesktopRect::MakeSize(frame->size()));
-  }
-  last_frame_ = frame->Share();
-
-  frame->set_capture_time_ms(frame->GetUnderlyingFrame()->capture_time_ms() +
-                             (rtc::TimeNanos() - start_time_nanos) /
-                                 rtc::kNumNanosecsPerMillisec);
-  callback_->OnCaptureResult(result, std::move(frame));
-}
-
-}  // namespace webrtc
diff --git a/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.h b/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.h
deleted file mode 100644
index 0747a4e..0000000
--- a/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_
-#define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_
-
-#include <memory>
-
-#include "webrtc/modules/desktop_capture/desktop_capturer.h"
-#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
-
-namespace webrtc {
-
-// DesktopCapturer wrapper that calculates updated_region() by comparing frames
-// content. This class always expects the underlying DesktopCapturer
-// implementation returns a superset of updated regions in DestkopFrame. If a
-// DesktopCapturer implementation does not know the updated region, it should
-// set updated_region() to full frame.
-//
-// This class marks entire frame as updated if the frame size or frame stride
-// has been changed.
-class DesktopCapturerDifferWrapper : public DesktopCapturer,
-                                     public DesktopCapturer::Callback {
- public:
-  // Creates a DesktopCapturerDifferWrapper with a DesktopCapturer
-  // implementation, and takes its ownership.
-  explicit DesktopCapturerDifferWrapper(
-      std::unique_ptr<DesktopCapturer> base_capturer);
-
-  ~DesktopCapturerDifferWrapper() override;
-
-  // DesktopCapturer interface.
-  void Start(DesktopCapturer::Callback* callback) override;
-  void SetSharedMemoryFactory(
-      std::unique_ptr<SharedMemoryFactory> shared_memory_factory) override;
-  void CaptureFrame() override;
-  void SetExcludedWindow(WindowId window) override;
-  bool GetSourceList(SourceList* screens) override;
-  bool SelectSource(SourceId id) override;
-  bool FocusOnSelectedSource() override;
-
- private:
-  // DesktopCapturer::Callback interface.
-  void OnCaptureResult(Result result,
-                       std::unique_ptr<DesktopFrame> frame) override;
-
-  const std::unique_ptr<DesktopCapturer> base_capturer_;
-  DesktopCapturer::Callback* callback_;
-  std::unique_ptr<SharedDesktopFrame> last_frame_;
-};
-
-}  // namespace webrtc
-
-#endif  // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_
diff --git a/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc b/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc
deleted file mode 100644
index 594ad13..0000000
--- a/webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper_unittest.cc
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "webrtc/modules/desktop_capture/desktop_capturer_differ_wrapper.h"
-
-#include <initializer_list>
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "webrtc/base/random.h"
-#include "webrtc/base/timeutils.h"
-#include "webrtc/modules/desktop_capture/desktop_geometry.h"
-#include "webrtc/modules/desktop_capture/desktop_region.h"
-#include "webrtc/modules/desktop_capture/differ_block.h"
-#include "webrtc/modules/desktop_capture/fake_screen_capturer.h"
-#include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h"
-#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
-#include "webrtc/test/gtest.h"
-#include "webrtc/typedefs.h"
-
-namespace webrtc {
-
-namespace {
-
-// Compares and asserts |frame|.updated_region() equals to |rects|. This
-// function does not care about the order of the |rects| and it does not expect
-// DesktopRegion to return an exact area for each rectangle in |rects|.
-template <template <typename, typename...> class T = std::initializer_list,
-          typename... Rect>
-void AssertUpdatedRegionIs(const DesktopFrame& frame,
-                           const T<DesktopRect, Rect...>& rects) {
-  DesktopRegion region;
-  for (const auto& rect : rects) {
-    region.AddRect(rect);
-  }
-  ASSERT_TRUE(frame.updated_region().Equals(region));
-}
-
-// Compares and asserts |frame|.updated_region() covers all rectangles in
-// |rects|, but does not cover areas other than a kBlockSize expansion. This
-// function does not care about the order of the |rects|, and it does not expect
-// DesktopRegion to return an exact area of each rectangle in |rects|.
-template <template <typename, typename...> class T = std::initializer_list,
-          typename... Rect>
-void AssertUpdatedRegionCovers(const DesktopFrame& frame,
-                               const T<DesktopRect, Rect...>& rects) {
-  DesktopRegion region;
-  for (const auto& rect : rects) {
-    region.AddRect(rect);
-  }
-
-  // Intersect of |rects| and |frame|.updated_region() should be |rects|. i.e.
-  // |frame|.updated_region() should be a superset of |rects|.
-  DesktopRegion intersect(region);
-  intersect.IntersectWith(frame.updated_region());
-  ASSERT_TRUE(region.Equals(intersect));
-
-  // Difference between |rects| and |frame|.updated_region() should not cover
-  // areas which have larger than twice of kBlockSize width and height.
-  //
-  // Explanation of the 'twice' of kBlockSize (indeed kBlockSize * 2 - 2) is
-  // following,
-  // (Each block in the following grid is a 8 x 8 pixels area. X means the real
-  // updated area, m means the updated area marked by
-  // DesktopCapturerDifferWrapper.)
-  // +---+---+---+---+---+---+---+---+
-  // | X | m | m | m | m | m | m | m |
-  // +---+---+---+---+---+---+---+---+
-  // | m | m | m | m | m | m | m | m |
-  // +---+---+---+---+---+---+---+---+
-  // | m | m | m | m | m | m | m | m |
-  // +---+---+---+---+---+---+---+---+
-  // | m | m | m | m | m | m | m | X |
-  // +---+---+---+---+---+---+---+---+
-  // The top left [0, 0] - [8, 8] and right bottom [56, 24] - [64, 32] blocks of
-  // this area are updated. But since DesktopCapturerDifferWrapper compares
-  // 32 x 32 blocks by default, this entire area is marked as updated. So the
-  // [8, 8] - [56, 32] is expected to be covered in the difference.
-  //
-  // But if [0, 0] - [8, 8] and [64, 24] - [72, 32] blocks are updated,
-  // +---+---+---+---+---+---+---+---+---+---+---+---+
-  // | X | m | m | m |   |   |   |   | m | m | m | m |
-  // +---+---+---+---+---+---+---+---+---+---+---+---+
-  // | m | m | m | m |   |   |   |   | m | m | m | m |
-  // +---+---+---+---+---+---+---+---+---+---+---+---+
-  // | m | m | m | m |   |   |   |   | m | m | m | m |
-  // +---+---+---+---+---+---+---+---+---+---+---+---+
-  // | m | m | m | m |   |   |   |   | X | m | m | m |
-  // +---+---+---+---+---+---+---+---+---+---+---+---+
-  // the [8, 8] - [64, 32] is not expected to be covered in the difference. As
-  // DesktopCapturerDifferWrapper should only mark [0, 0] - [32, 32] and
-  // [64, 0] - [96, 32] as updated.
-  DesktopRegion differ(frame.updated_region());
-  differ.Subtract(region);
-  for (DesktopRegion::Iterator it(differ); !it.IsAtEnd(); it.Advance()) {
-    ASSERT_TRUE(it.rect().width() <= kBlockSize * 2 - 2 ||
-                it.rect().height() <= kBlockSize * 2 - 2);
-  }
-}
-
-// Executes a DesktopCapturerDifferWrapper::Capture() and compares its output
-// DesktopFrame::updated_region() with |updated_region| if |check_result| is
-// true. If |exactly_match| is true, AssertUpdatedRegionIs() will be used,
-// otherwise AssertUpdatedRegionCovers() will be used.
-template <template <typename, typename...> class T = std::initializer_list,
-          typename... Rect>
-void ExecuteDifferWrapperCase(BlackWhiteDesktopFramePainter* frame_painter,
-                              DesktopCapturerDifferWrapper* capturer,
-                              MockDesktopCapturerCallback* callback,
-                              const T<DesktopRect, Rect...>& updated_region,
-                              bool check_result,
-                              bool exactly_match) {
-  EXPECT_CALL(*callback,
-              OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, testing::_))
-      .Times(1)
-      .WillOnce(testing::Invoke([&updated_region, check_result, exactly_match](
-          DesktopCapturer::Result result,
-          std::unique_ptr<DesktopFrame>* frame) {
-        ASSERT_EQ(result, DesktopCapturer::Result::SUCCESS);
-        if (check_result) {
-          if (exactly_match) {
-            AssertUpdatedRegionIs(**frame, updated_region);
-          } else {
-            AssertUpdatedRegionCovers(**frame, updated_region);
-          }
-        }
-      }));
-  for (const auto& rect : updated_region) {
-    frame_painter->updated_region()->AddRect(rect);
-  }
-  capturer->CaptureFrame();
-}
-
-// Executes a DesktopCapturerDifferWrapper::Capture(), if updated_region() is
-// not set, this function will reset DesktopCapturerDifferWrapper internal
-// DesktopFrame into black.
-void ExecuteCapturer(DesktopCapturerDifferWrapper* capturer,
-                     MockDesktopCapturerCallback* callback) {
-  EXPECT_CALL(*callback,
-              OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, testing::_))
-      .Times(1);
-  capturer->CaptureFrame();
-}
-
-void ExecuteDifferWrapperTest(bool with_hints,
-                              bool enlarge_updated_region,
-                              bool random_updated_region,
-                              bool check_result) {
-  const bool updated_region_should_exactly_match =
-      with_hints && !enlarge_updated_region && !random_updated_region;
-  BlackWhiteDesktopFramePainter frame_painter;
-  PainterDesktopFrameGenerator frame_generator;
-  frame_generator.set_desktop_frame_painter(&frame_painter);
-  std::unique_ptr<FakeDesktopCapturer<>> fake(new FakeDesktopCapturer<>());
-  fake->set_frame_generator(&frame_generator);
-  DesktopCapturerDifferWrapper capturer(std::move(fake));
-  MockDesktopCapturerCallback callback;
-  frame_generator.set_provide_updated_region_hints(with_hints);
-  frame_generator.set_enlarge_updated_region(enlarge_updated_region);
-  frame_generator.set_add_random_updated_region(random_updated_region);
-
-  capturer.Start(&callback);
-
-  EXPECT_CALL(callback,
-              OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, testing::_))
-      .Times(1)
-      .WillOnce(testing::Invoke([](DesktopCapturer::Result result,
-                                   std::unique_ptr<DesktopFrame>* frame) {
-        ASSERT_EQ(result, DesktopCapturer::Result::SUCCESS);
-        AssertUpdatedRegionIs(**frame,
-                              {DesktopRect::MakeSize((*frame)->size())});
-      }));
-  capturer.CaptureFrame();
-
-  ExecuteDifferWrapperCase(&frame_painter, &capturer, &callback,
-                           {DesktopRect::MakeLTRB(100, 100, 200, 200),
-                            DesktopRect::MakeLTRB(300, 300, 400, 400)},
-                           check_result, updated_region_should_exactly_match);
-  ExecuteCapturer(&capturer, &callback);
-
-  ExecuteDifferWrapperCase(
-      &frame_painter, &capturer, &callback,
-      {DesktopRect::MakeLTRB(0, 0, 40, 40),
-       DesktopRect::MakeLTRB(0, frame_generator.size()->height() - 40, 40,
-                             frame_generator.size()->height()),
-       DesktopRect::MakeLTRB(frame_generator.size()->width() - 40, 0,
-                             frame_generator.size()->width(), 40),
-       DesktopRect::MakeLTRB(frame_generator.size()->width() - 40,
-                             frame_generator.size()->height() - 40,
-                             frame_generator.size()->width(),
-                             frame_generator.size()->height())},
-      check_result, updated_region_should_exactly_match);
-
-  Random random(rtc::TimeMillis());
-  // Fuzzing tests.
-  for (int i = 0; i < 1000; i++) {
-    if (enlarge_updated_region) {
-      frame_generator.set_enlarge_range(random.Rand(1, 50));
-    }
-    frame_generator.size()->set(random.Rand(500, 2000), random.Rand(500, 2000));
-    ExecuteCapturer(&capturer, &callback);
-    std::vector<DesktopRect> updated_region;
-    for (int j = random.Rand(50); j >= 0; j--) {
-      // At least a 1 x 1 updated region.
-      const int left = random.Rand(0, frame_generator.size()->width() - 2);
-      const int top = random.Rand(0, frame_generator.size()->height() - 2);
-      const int right = random.Rand(left + 1, frame_generator.size()->width());
-      const int bottom = random.Rand(top + 1, frame_generator.size()->height());
-      updated_region.push_back(DesktopRect::MakeLTRB(left, top, right, bottom));
-    }
-    ExecuteDifferWrapperCase(&frame_painter, &capturer, &callback,
-                             updated_region, check_result,
-                             updated_region_should_exactly_match);
-  }
-}
-
-}  // namespace
-
-TEST(DesktopCapturerDifferWrapperTest, CaptureWithoutHints) {
-  ExecuteDifferWrapperTest(false, false, false, true);
-}
-
-TEST(DesktopCapturerDifferWrapperTest, CaptureWithHints) {
-  ExecuteDifferWrapperTest(true, false, false, true);
-}
-
-TEST(DesktopCapturerDifferWrapperTest, CaptureWithEnlargedHints) {
-  ExecuteDifferWrapperTest(true, true, false, true);
-}
-
-TEST(DesktopCapturerDifferWrapperTest, CaptureWithRandomHints) {
-  ExecuteDifferWrapperTest(true, false, true, true);
-}
-
-TEST(DesktopCapturerDifferWrapperTest, CaptureWithEnlargedAndRandomHints) {
-  ExecuteDifferWrapperTest(true, true, true, true);
-}
-
-// When hints are provided, DesktopCapturerDifferWrapper has a slightly better
-// performance in current configuration, but not so significant. Following is
-// one run result.
-// [ RUN      ] DISABLED_CaptureWithoutHintsPerf
-// [       OK ] DISABLED_CaptureWithoutHintsPerf (7118 ms)
-// [ RUN      ] DISABLED_CaptureWithHintsPerf
-// [       OK ] DISABLED_CaptureWithHintsPerf (5580 ms)
-// [ RUN      ] DISABLED_CaptureWithEnlargedHintsPerf
-// [       OK ] DISABLED_CaptureWithEnlargedHintsPerf (5974 ms)
-// [ RUN      ] DISABLED_CaptureWithRandomHintsPerf
-// [       OK ] DISABLED_CaptureWithRandomHintsPerf (6184 ms)
-// [ RUN      ] DISABLED_CaptureWithEnlargedAndRandomHintsPerf
-// [       OK ] DISABLED_CaptureWithEnlargedAndRandomHintsPerf (6347 ms)
-TEST(DesktopCapturerDifferWrapperTest, DISABLED_CaptureWithoutHintsPerf) {
-  int64_t started = rtc::TimeMillis();
-  ExecuteDifferWrapperTest(false, false, false, false);
-  ASSERT_LE(rtc::TimeMillis() - started, 15000);
-}
-
-TEST(DesktopCapturerDifferWrapperTest, DISABLED_CaptureWithHintsPerf) {
-  int64_t started = rtc::TimeMillis();
-  ExecuteDifferWrapperTest(true, false, false, false);
-  ASSERT_LE(rtc::TimeMillis() - started, 15000);
-}
-
-TEST(DesktopCapturerDifferWrapperTest, DISABLED_CaptureWithEnlargedHintsPerf) {
-  int64_t started = rtc::TimeMillis();
-  ExecuteDifferWrapperTest(true, true, false, false);
-  ASSERT_LE(rtc::TimeMillis() - started, 15000);
-}
-
-TEST(DesktopCapturerDifferWrapperTest, DISABLED_CaptureWithRandomHintsPerf) {
-  int64_t started = rtc::TimeMillis();
-  ExecuteDifferWrapperTest(true, false, true, false);
-  ASSERT_LE(rtc::TimeMillis() - started, 15000);
-}
-
-TEST(DesktopCapturerDifferWrapperTest,
-     DISABLED_CaptureWithEnlargedAndRandomHintsPerf) {
-  int64_t started = rtc::TimeMillis();
-  ExecuteDifferWrapperTest(true, true, true, false);
-  ASSERT_LE(rtc::TimeMillis() - started, 15000);
-}
-
-}  // namespace webrtc
diff --git a/webrtc/modules/desktop_capture/fake_desktop_capturer.h b/webrtc/modules/desktop_capture/fake_desktop_capturer.h
index 3018777..fa5ccba 100644
--- a/webrtc/modules/desktop_capture/fake_desktop_capturer.h
+++ b/webrtc/modules/desktop_capture/fake_desktop_capturer.h
@@ -15,7 +15,6 @@
 #include <utility>
 
 #include "webrtc/modules/desktop_capture/desktop_capturer.h"
-#include "webrtc/modules/desktop_capture/desktop_capture_types.h"
 #include "webrtc/modules/desktop_capture/desktop_frame_generator.h"
 #include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
 #include "webrtc/modules/desktop_capture/shared_memory.h"
@@ -38,7 +37,7 @@
 //
 // TODO(zijiehe): Remove template T once we merge ScreenCapturer and
 // WindowCapturer.
-template <typename T = DesktopCapturer>
+template <typename T>
 class FakeDesktopCapturer : public T {
  public:
   FakeDesktopCapturer()
@@ -84,20 +83,7 @@
     shared_memory_factory_ = std::move(shared_memory_factory);
   }
 
-  bool GetSourceList(DesktopCapturer::SourceList* sources) override {
-    sources->push_back({kWindowId, "A-Fake-DesktopCapturer-Window"});
-    sources->push_back({kScreenId});
-    return true;
-  }
-
-  bool SelectSource(DesktopCapturer::SourceId id) override {
-    return id == kWindowId || id == kScreenId || id == kFullDesktopScreenId;
-  }
-
  private:
-  static constexpr DesktopCapturer::SourceId kWindowId = 1378277495;
-  static constexpr DesktopCapturer::SourceId kScreenId = 1378277496;
-
   DesktopCapturer::Callback* callback_;
   std::unique_ptr<SharedMemoryFactory> shared_memory_factory_;
   DesktopCapturer::Result result_;
diff --git a/webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h b/webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h
deleted file mode 100644
index 3f67a9e..0000000
--- a/webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_MOCK_DESKTOP_CAPTURER_CALLBACK_H_
-#define WEBRTC_MODULES_DESKTOP_CAPTURE_MOCK_DESKTOP_CAPTURER_CALLBACK_H_
-
-#include "webrtc/modules/desktop_capture/screen_capturer_mock_objects.h"
-
-namespace webrtc {
-// TODO(zijiehe): Remove MockScreenCapturerCallback.
-class MockDesktopCapturerCallback : public MockScreenCapturerCallback {};
-}  // namespace webrtc
-
-#endif  // WEBRTC_MODULES_DESKTOP_CAPTURE_MOCK_DESKTOP_CAPTURER_CALLBACK_H_
diff --git a/webrtc/modules/desktop_capture/screen_capturer_differ_wrapper.h b/webrtc/modules/desktop_capture/screen_capturer_differ_wrapper.h
index 9b430a9..6ae3a1b 100644
--- a/webrtc/modules/desktop_capture/screen_capturer_differ_wrapper.h
+++ b/webrtc/modules/desktop_capture/screen_capturer_differ_wrapper.h
@@ -18,7 +18,6 @@
 
 namespace webrtc {
 
-// TODO(zijiehe): Remove, use DesktopCapturerDifferWrapper.
 // ScreenCapturer wrapper that calculates updated_region() by comparing frames
 // content. This class always expects the underlying ScreenCapturer
 // implementation returns a superset of updated regions in DestkopFrame. If a
diff --git a/webrtc/modules/desktop_capture/screen_capturer_integration_test.cc b/webrtc/modules/desktop_capture/screen_capturer_integration_test.cc
index 5aa1f12..f208f14 100644
--- a/webrtc/modules/desktop_capture/screen_capturer_integration_test.cc
+++ b/webrtc/modules/desktop_capture/screen_capturer_integration_test.cc
@@ -26,7 +26,7 @@
 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
 #include "webrtc/modules/desktop_capture/desktop_frame.h"
 #include "webrtc/modules/desktop_capture/desktop_region.h"
-#include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h"
+#include "webrtc/modules/desktop_capture/screen_capturer_mock_objects.h"
 #include "webrtc/modules/desktop_capture/screen_drawer.h"
 
 #if defined(WEBRTC_WIN)
@@ -77,16 +77,16 @@
 class ScreenCapturerIntegrationTest : public testing::Test {
  public:
   void SetUp() override {
-    capturer_ = DesktopCapturer::CreateScreenCapturer(
-        DesktopCaptureOptions::CreateDefault());
+    capturer_.reset(
+        ScreenCapturer::Create(DesktopCaptureOptions::CreateDefault()));
   }
 
  protected:
   void TestCaptureUpdatedRegion(
-      std::initializer_list<DesktopCapturer*> capturers) {
+      std::initializer_list<ScreenCapturer*> capturers) {
     RTC_DCHECK(capturers.size() > 0);
-    // A large enough area for the tests, which should be able to be fulfilled
-    // by most systems.
+    // A large enough area for the tests, which should be able to fulfill by
+    // most of systems.
     const int kTestArea = 512;
     const int kRectSize = 32;
     std::unique_ptr<ScreenDrawer> drawer = ScreenDrawer::Create();
@@ -101,7 +101,7 @@
       return;
     }
 
-    for (DesktopCapturer* capturer : capturers) {
+    for (ScreenCapturer* capturer : capturers) {
       capturer->Start(&callback_);
     }
 
@@ -138,12 +138,11 @@
 
 #if defined(WEBRTC_WIN)
   // Enable allow_directx_capturer in DesktopCaptureOptions, but let
-  // DesktopCapturer::CreateScreenCapturer() to decide whether a DirectX
-  // capturer should be used.
+  // ScreenCapturer::Create to decide whether a DirectX capturer should be used.
   void MaybeCreateDirectxCapturer() {
     DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault());
     options.set_allow_directx_capturer(true);
-    capturer_ = DesktopCapturer::CreateScreenCapturer(options);
+    capturer_.reset(ScreenCapturer::Create(options));
   }
 
   bool CreateDirectxCapturer() {
@@ -159,19 +158,19 @@
   void CreateMagnifierCapturer() {
     DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault());
     options.set_allow_use_magnification_api(true);
-    capturer_ = DesktopCapturer::CreateScreenCapturer(options);
+    capturer_.reset(ScreenCapturer::Create(options));
   }
 #endif  // defined(WEBRTC_WIN)
 
-  std::unique_ptr<DesktopCapturer> capturer_;
-  MockDesktopCapturerCallback callback_;
+  std::unique_ptr<ScreenCapturer> capturer_;
+  MockScreenCapturerCallback callback_;
 
  private:
   // Repeats capturing the frame by using |capturers| one-by-one for 600 times,
   // typically 30 seconds, until they succeeded captured a |color| rectangle at
   // |rect|. This function uses |drawer|->WaitForPendingDraws() between two
   // attempts to wait for the screen to update.
-  void TestCaptureOneFrame(std::vector<DesktopCapturer*> capturers,
+  void TestCaptureOneFrame(std::vector<ScreenCapturer*> capturers,
                            ScreenDrawer* drawer,
                            DesktopRect rect,
                            RgbaColor color) {
@@ -183,7 +182,7 @@
       drawer->WaitForPendingDraws();
       for (size_t j = 0; j < capturers.size(); j++) {
         if (capturers[j] == nullptr) {
-          // DesktopCapturer should return an empty updated_region() if no
+          // ScreenCapturer should return an empty updated_region() if no
           // update detected. So we won't test it again if it has captured
           // the rectangle we drew.
           continue;
@@ -211,7 +210,7 @@
   }
 
   // Expects |capturer| to successfully capture a frame, and returns it.
-  std::unique_ptr<DesktopFrame> CaptureFrame(DesktopCapturer* capturer) {
+  std::unique_ptr<DesktopFrame> CaptureFrame(ScreenCapturer* capturer) {
     std::unique_ptr<DesktopFrame> frame;
     EXPECT_CALL(callback_,
                 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
@@ -227,7 +226,7 @@
 }
 
 TEST_F(ScreenCapturerIntegrationTest, TwoCapturers) {
-  std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_);
+  std::unique_ptr<ScreenCapturer> capturer2 = std::move(capturer_);
   SetUp();
   TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
 }
@@ -247,7 +246,7 @@
     return;
   }
 
-  std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_);
+  std::unique_ptr<ScreenCapturer> capturer2 = std::move(capturer_);
   RTC_CHECK(CreateDirectxCapturer());
   TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
 }
@@ -260,7 +259,7 @@
 
 TEST_F(ScreenCapturerIntegrationTest, TwoMagnifierCapturers) {
   CreateMagnifierCapturer();
-  std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_);
+  std::unique_ptr<ScreenCapturer> capturer2 = std::move(capturer_);
   CreateMagnifierCapturer();
   TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
 }
diff --git a/webrtc/modules/desktop_capture/screen_capturer_mac.mm b/webrtc/modules/desktop_capture/screen_capturer_mac.mm
index f8d8eb7..49910d6 100644
--- a/webrtc/modules/desktop_capture/screen_capturer_mac.mm
+++ b/webrtc/modules/desktop_capture/screen_capturer_mac.mm
@@ -1037,19 +1037,4 @@
   return capturer.release();
 }
 
-// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
-    const DesktopCaptureOptions& options) {
-  if (!options.configuration_monitor())
-    return nullptr;
-
-  std::unique_ptr<ScreenCapturer> capturer(
-      new ScreenCapturerMac(options.configuration_monitor()));
-  if (!static_cast<ScreenCapturerMac*>(capturer.get())->Init()) {
-    return nullptr;
-  }
-
-  return capturer;
-}
-
 }  // namespace webrtc
diff --git a/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h b/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h
index cae8db5..74bf7fc 100644
--- a/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h
+++ b/webrtc/modules/desktop_capture/screen_capturer_mock_objects.h
@@ -17,8 +17,20 @@
 
 namespace webrtc {
 
-// Deprecated.
-// Use webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h.
+class MockScreenCapturer : public ScreenCapturer {
+ public:
+  MockScreenCapturer() {}
+  virtual ~MockScreenCapturer() {}
+
+  MOCK_METHOD1(Start, void(Callback* callback));
+  MOCK_METHOD0(CaptureFrame, void(void));
+  MOCK_METHOD1(GetScreenList, bool(ScreenList* screens));
+  MOCK_METHOD1(SelectScreen, bool(ScreenId id));
+
+ private:
+  RTC_DISALLOW_COPY_AND_ASSIGN(MockScreenCapturer);
+};
+
 class MockScreenCapturerCallback : public ScreenCapturer::Callback {
  public:
   MockScreenCapturerCallback() {}
diff --git a/webrtc/modules/desktop_capture/screen_capturer_win.cc b/webrtc/modules/desktop_capture/screen_capturer_win.cc
index 00a512b..1d05961 100644
--- a/webrtc/modules/desktop_capture/screen_capturer_win.cc
+++ b/webrtc/modules/desktop_capture/screen_capturer_win.cc
@@ -42,22 +42,4 @@
   return capturer.release();
 }
 
-// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
-    const DesktopCaptureOptions& options) {
-  std::unique_ptr<DesktopCapturer> capturer;
-  if (options.allow_directx_capturer() &&
-      ScreenCapturerWinDirectx::IsSupported()) {
-    capturer.reset(new ScreenCapturerWinDirectx(options));
-  } else {
-    capturer.reset(new ScreenCapturerWinGdi(options));
-  }
-
-  if (options.allow_use_magnification_api()) {
-    capturer.reset(new ScreenCapturerWinMagnifier(std::move(capturer)));
-  }
-
-  return capturer;
-}
-
 }  // namespace webrtc
diff --git a/webrtc/modules/desktop_capture/screen_capturer_x11.cc b/webrtc/modules/desktop_capture/screen_capturer_x11.cc
index fb8446e..34653ec 100644
--- a/webrtc/modules/desktop_capture/screen_capturer_x11.cc
+++ b/webrtc/modules/desktop_capture/screen_capturer_x11.cc
@@ -424,18 +424,4 @@
   return capturer.release();
 }
 
-// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
-    const DesktopCaptureOptions& options) {
-  if (!options.x_display())
-    return nullptr;
-
-  std::unique_ptr<ScreenCapturer> capturer(new ScreenCapturerLinux());
-  if (!static_cast<ScreenCapturerLinux*>(capturer.get())->Init(options)) {
-    return nullptr;
-  }
-
-  return capturer;
-}
-
 }  // namespace webrtc
diff --git a/webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.cc b/webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.cc
index b425681..5ffd1f9 100644
--- a/webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.cc
+++ b/webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.cc
@@ -36,7 +36,7 @@
 Atomic32 ScreenCapturerWinMagnifier::tls_index_(TLS_OUT_OF_INDEXES);
 
 ScreenCapturerWinMagnifier::ScreenCapturerWinMagnifier(
-    std::unique_ptr<DesktopCapturer> fallback_capturer)
+    std::unique_ptr<ScreenCapturer> fallback_capturer)
     : fallback_capturer_(std::move(fallback_capturer)) {}
 
 ScreenCapturerWinMagnifier::~ScreenCapturerWinMagnifier() {
@@ -139,7 +139,7 @@
     current_screen_id_ = id;
 
   if (fallback_capturer_started_)
-    fallback_capturer_->SelectSource(id);
+    fallback_capturer_->SelectScreen(id);
 
   return valid;
 }
@@ -382,7 +382,7 @@
     fallback_capturer_started_ = true;
 
     fallback_capturer_->Start(callback_);
-    fallback_capturer_->SelectSource(current_screen_id_);
+    fallback_capturer_->SelectScreen(current_screen_id_);
   }
 }
 
diff --git a/webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h b/webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h
index 06b4ec6..b298149 100644
--- a/webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h
+++ b/webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h
@@ -44,7 +44,7 @@
   // screen is being captured, or the OS does not support Magnification API, or
   // the magnifier capturer fails (e.g. in Windows8 Metro mode).
   explicit ScreenCapturerWinMagnifier(
-      std::unique_ptr<DesktopCapturer> fallback_capturer);
+      std::unique_ptr<ScreenCapturer> fallback_capturer);
   ~ScreenCapturerWinMagnifier() override;
 
   // Overridden from ScreenCapturer:
@@ -108,7 +108,7 @@
 
   static Atomic32 tls_index_;
 
-  std::unique_ptr<DesktopCapturer> fallback_capturer_;
+  std::unique_ptr<ScreenCapturer> fallback_capturer_;
   bool fallback_capturer_started_ = false;
   Callback* callback_ = nullptr;
   std::unique_ptr<SharedMemoryFactory> shared_memory_factory_;
diff --git a/webrtc/modules/desktop_capture/window_capturer_mac.mm b/webrtc/modules/desktop_capture/window_capturer_mac.mm
index 72b20f3..2272b3f 100644
--- a/webrtc/modules/desktop_capture/window_capturer_mac.mm
+++ b/webrtc/modules/desktop_capture/window_capturer_mac.mm
@@ -241,11 +241,4 @@
   return new WindowCapturerMac(options.full_screen_chrome_window_detector());
 }
 
-// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
-    const DesktopCaptureOptions& options) {
-  return std::unique_ptr<DesktopCapturer>(
-      new WindowCapturerMac(options.full_screen_chrome_window_detector()));
-}
-
 }  // namespace webrtc
diff --git a/webrtc/modules/desktop_capture/window_capturer_win.cc b/webrtc/modules/desktop_capture/window_capturer_win.cc
index 101b17a..c43db7e 100644
--- a/webrtc/modules/desktop_capture/window_capturer_win.cc
+++ b/webrtc/modules/desktop_capture/window_capturer_win.cc
@@ -270,10 +270,4 @@
   return new WindowCapturerWin();
 }
 
-// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
-    const DesktopCaptureOptions& options) {
-  return std::unique_ptr<DesktopCapturer>(new WindowCapturerWin());
-}
-
 }  // namespace webrtc
diff --git a/webrtc/modules/desktop_capture/window_capturer_x11.cc b/webrtc/modules/desktop_capture/window_capturer_x11.cc
index 11a27d5..2e2ce9b 100644
--- a/webrtc/modules/desktop_capture/window_capturer_x11.cc
+++ b/webrtc/modules/desktop_capture/window_capturer_x11.cc
@@ -430,12 +430,4 @@
   return new WindowCapturerLinux(options);
 }
 
-// static
-std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
-    const DesktopCaptureOptions& options) {
-  if (!options.x_display())
-    return nullptr;
-  return std::unique_ptr<DesktopCapturer>(new WindowCapturerLinux(options));
-}
-
 }  // namespace webrtc