Merge media::ScreenCaptureDeviceCore into ScreenCaptureMachineAndroid.

With no other screen capture implementations dependent upon
media::ScreenCaptureDeviceCore, ThreadSafeCaptureOracle, etc.; this
change merges this code into ScreenCaptureMachineAndroid. Unused
functionality has been stripped-out, and minor callpoint- and lint-
related clean-ups were made. No behavior/functional changes.

Testing: Built monochrome_public_apk, installed it to my phone, and
confirmed Android screen capture from that Chromium build still works by
running a demo app: https://paulkinlan.github.io/screenrecord/.

Bug: 806366,487935
Change-Id: I3edb2603261b6ed60e31edf795ac8da9a2a8525c
Reviewed-on: https://chromium-review.googlesource.com/1137733
Commit-Queue: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Weiyong Yao <braveyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575864}
diff --git a/content/browser/media/capture/screen_capture_device_android.cc b/content/browser/media/capture/screen_capture_device_android.cc
index 1e93e1c..9d5cf89 100644
--- a/content/browser/media/capture/screen_capture_device_android.cc
+++ b/content/browser/media/capture/screen_capture_device_android.cc
@@ -4,36 +4,70 @@
 
 #include "content/browser/media/capture/screen_capture_device_android.h"
 
+#include <utility>
+
 #include "base/logging.h"
-#include "media/capture/content/android/screen_capture_machine_android.h"
+#include "media/capture/content/android/thread_safe_capture_oracle.h"
 
 namespace content {
 
-ScreenCaptureDeviceAndroid::ScreenCaptureDeviceAndroid()
-    : core_(std::make_unique<media::ScreenCaptureMachineAndroid>()) {}
+ScreenCaptureDeviceAndroid::ScreenCaptureDeviceAndroid() = default;
 
 ScreenCaptureDeviceAndroid::~ScreenCaptureDeviceAndroid() {
-  DVLOG(2) << "ScreenCaptureDeviceAndroid@" << this << " destroying.";
+  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+  DCHECK(!oracle_proxy_);
 }
 
 void ScreenCaptureDeviceAndroid::AllocateAndStart(
     const media::VideoCaptureParams& params,
     std::unique_ptr<Client> client) {
-  DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString();
-  core_.AllocateAndStart(params, std::move(client));
+  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+
+  if (params.requested_format.pixel_format != media::PIXEL_FORMAT_I420) {
+    client->OnError(
+        FROM_HERE, "unsupported format: " + media::VideoCaptureFormat::ToString(
+                                                params.requested_format));
+    return;
+  }
+
+  DCHECK(!oracle_proxy_);
+  oracle_proxy_ = new media::ThreadSafeCaptureOracle(std::move(client), params);
+
+  if (!capture_machine_.Start(oracle_proxy_, params)) {
+    oracle_proxy_->ReportError(FROM_HERE, "Failed to start capture machine.");
+    StopAndDeAllocate();
+  } else {
+    // The |capture_machine_| will later report to the |oracle_proxy_| whether
+    // the device started successfully.
+  }
 }
 
 void ScreenCaptureDeviceAndroid::StopAndDeAllocate() {
-  core_.StopAndDeAllocate();
+  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+
+  if (!oracle_proxy_) {
+    return;  // Device is already stopped.
+  }
+
+  oracle_proxy_->Stop();
+  oracle_proxy_ = nullptr;
+  capture_machine_.Stop();
 }
 
 void ScreenCaptureDeviceAndroid::RequestRefreshFrame() {
-  core_.RequestRefreshFrame();
+  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+
+  if (!oracle_proxy_) {
+    return;  // Device is stopped.
+  }
+  capture_machine_.MaybeCaptureForRefresh();
 }
 
 void ScreenCaptureDeviceAndroid::OnUtilizationReport(int frame_feedback_id,
                                                      double utilization) {
-  core_.OnConsumerReportingUtilization(frame_feedback_id, utilization);
+  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+  DCHECK(oracle_proxy_);
+  oracle_proxy_->OnConsumerReportingUtilization(frame_feedback_id, utilization);
 }
 
 }  // namespace content
diff --git a/content/browser/media/capture/screen_capture_device_android.h b/content/browser/media/capture/screen_capture_device_android.h
index 7d2d518..1411226 100644
--- a/content/browser/media/capture/screen_capture_device_android.h
+++ b/content/browser/media/capture/screen_capture_device_android.h
@@ -7,15 +7,17 @@
 
 #include <memory>
 
+#include "base/macros.h"
+#include "base/sequence_checker.h"
 #include "content/common/content_export.h"
-#include "media/capture/content/screen_capture_device_core.h"
+#include "media/capture/content/android/screen_capture_machine_android.h"
 #include "media/capture/video/video_capture_device.h"
 
 namespace content {
 
-// ScreenCaptureDeviceAndroid is a forwarder to media::ScreenCaptureDeviceCore
-// while keeping the Power Saving from kicking in between AllocateAndStart() and
-// StopAndDeAllocate().
+// ScreenCaptureDeviceAndroid is an adapter for using
+// media::ScreenCaptureMachineAndroid via the media::VideoCaptureDevice
+// interface.
 class CONTENT_EXPORT ScreenCaptureDeviceAndroid
     : public media::VideoCaptureDevice {
  public:
@@ -30,7 +32,10 @@
   void OnUtilizationReport(int frame_feedback_id, double utilization) override;
 
  private:
-  media::ScreenCaptureDeviceCore core_;
+  SEQUENCE_CHECKER(sequence_checker_);
+
+  media::ScreenCaptureMachineAndroid capture_machine_;
+  scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_;
 
   DISALLOW_COPY_AND_ASSIGN(ScreenCaptureDeviceAndroid);
 };
diff --git a/media/capture/BUILD.gn b/media/capture/BUILD.gn
index 6a9ce2b..3785346 100644
--- a/media/capture/BUILD.gn
+++ b/media/capture/BUILD.gn
@@ -53,12 +53,8 @@
     "content/animated_content_sampler.h",
     "content/capture_resolution_chooser.cc",
     "content/capture_resolution_chooser.h",
-    "content/screen_capture_device_core.cc",
-    "content/screen_capture_device_core.h",
     "content/smooth_event_sampler.cc",
     "content/smooth_event_sampler.h",
-    "content/thread_safe_capture_oracle.cc",
-    "content/thread_safe_capture_oracle.h",
     "content/video_capture_oracle.cc",
     "content/video_capture_oracle.h",
     "video/blob_utils.cc",
diff --git a/media/capture/content/android/BUILD.gn b/media/capture/content/android/BUILD.gn
index 92ff80e..521a0f0 100644
--- a/media/capture/content/android/BUILD.gn
+++ b/media/capture/content/android/BUILD.gn
@@ -14,14 +14,18 @@
   sources = [
     "screen_capture_machine_android.cc",
     "screen_capture_machine_android.h",
+    "thread_safe_capture_oracle.cc",
+    "thread_safe_capture_oracle.h",
   ]
   configs += [ "//media:media_config" ]
   deps = [
     ":screen_capture_jni_headers",
+    "//media",
     "//media/capture:capture_device_specific",
     "//media/capture/mojom:image_capture",
     "//third_party/libyuv",
     "//ui/gfx:color_space",
+    "//ui/gfx/geometry",
   ]
 }
 
diff --git a/media/capture/content/android/screen_capture_machine_android.cc b/media/capture/content/android/screen_capture_machine_android.cc
index 734048e..be83b13 100644
--- a/media/capture/content/android/screen_capture_machine_android.cc
+++ b/media/capture/content/android/screen_capture_machine_android.cc
@@ -4,10 +4,15 @@
 
 #include "media/capture/content/android/screen_capture_machine_android.h"
 
+#include <utility>
+
 #include "base/android/jni_android.h"
 #include "base/android/scoped_java_ref.h"
 #include "jni/ScreenCapture_jni.h"
+#include "media/base/video_frame.h"
+#include "media/capture/content/android/thread_safe_capture_oracle.h"
 #include "media/capture/content/video_capture_oracle.h"
+#include "media/capture/video_capture_types.h"
 #include "third_party/libyuv/include/libyuv.h"
 
 using base::android::AttachCurrentThread;
@@ -94,7 +99,7 @@
         frame->visible_rect().height(), libyuv::kFilterBilinear);
   }
 
-  capture_frame_cb.Run(frame, start_time, true);
+  std::move(capture_frame_cb).Run(frame, start_time, true);
 
   lastFrame_ = frame;
 }
@@ -177,7 +182,7 @@
         frame->visible_rect().height(), libyuv::kFilterBilinear);
   }
 
-  capture_frame_cb.Run(frame, start_time, true);
+  std::move(capture_frame_cb).Run(frame, start_time, true);
 
   lastFrame_ = frame;
 }
@@ -225,20 +230,18 @@
   }
 }
 
-void ScreenCaptureMachineAndroid::Start(
-    const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy,
-    const VideoCaptureParams& params,
-    const base::Callback<void(bool)> callback) {
+bool ScreenCaptureMachineAndroid::Start(
+    scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy,
+    const VideoCaptureParams& params) {
   DCHECK(oracle_proxy.get());
-  oracle_proxy_ = oracle_proxy;
+  oracle_proxy_ = std::move(oracle_proxy);
 
   j_capture_.Reset(
       createScreenCaptureMachineAndroid(reinterpret_cast<intptr_t>(this)));
 
   if (j_capture_.obj() == nullptr) {
     DLOG(ERROR) << "Failed to createScreenCaptureAndroid";
-    callback.Run(false);
-    return;
+    return false;
   }
 
   DCHECK(params.requested_format.frame_size.GetArea());
@@ -251,24 +254,19 @@
                                   params.requested_format.frame_size.height());
   if (!ret) {
     DLOG(ERROR) << "Failed to init ScreenCaptureAndroid";
-    callback.Run(ret);
-    return;
+    return false;
   }
 
   ret = Java_ScreenCapture_startPrompt(AttachCurrentThread(), j_capture_);
-  // Must wait for user input to start capturing before we can report back
-  // device started state. However, if the user-prompt failed to show, report
-  // a failed start immediately.
-  if (!ret)
-    callback.Run(ret);
+  // NOTE: Result of user prompt will be delivered to OnActivityResult(), and
+  // this will report the device started/error state via the |oracle_proxy_|.
+  return !!ret;
 }
 
-void ScreenCaptureMachineAndroid::Stop(const base::Closure& callback) {
+void ScreenCaptureMachineAndroid::Stop() {
   if (j_capture_.obj() != nullptr) {
     Java_ScreenCapture_stopCapture(AttachCurrentThread(), j_capture_);
   }
-
-  callback.Run();
 }
 
 // ScreenCapture on Android works in a passive way and there are no captured
@@ -306,7 +304,7 @@
       frame->stride(VideoFrame::kVPlane), frame->visible_rect().width(),
       frame->visible_rect().height(), libyuv::kFilterBilinear);
 
-  capture_frame_cb.Run(frame, start_time, true);
+  std::move(capture_frame_cb).Run(frame, start_time, true);
 }
 
 }  // namespace media
diff --git a/media/capture/content/android/screen_capture_machine_android.h b/media/capture/content/android/screen_capture_machine_android.h
index 775e6d6..4b11834 100644
--- a/media/capture/content/android/screen_capture_machine_android.h
+++ b/media/capture/content/android/screen_capture_machine_android.h
@@ -9,16 +9,20 @@
 #include <memory>
 
 #include "base/android/scoped_java_ref.h"
+#include "base/memory/scoped_refptr.h"
 #include "media/capture/capture_export.h"
-#include "media/capture/content/screen_capture_device_core.h"
 
 namespace media {
 
+class ThreadSafeCaptureOracle;
+struct VideoCaptureParams;
+class VideoFrame;
+
 // ScreenCaptureMachineAndroid captures 32bit RGB or YUV420 triplanar.
-class CAPTURE_EXPORT ScreenCaptureMachineAndroid : public VideoCaptureMachine {
+class CAPTURE_EXPORT ScreenCaptureMachineAndroid {
  public:
   ScreenCaptureMachineAndroid();
-  ~ScreenCaptureMachineAndroid() override;
+  virtual ~ScreenCaptureMachineAndroid();
 
   static base::android::ScopedJavaLocalRef<jobject>
   createScreenCaptureMachineAndroid(jlong nativeScreenCaptureMachineAndroid);
@@ -58,12 +62,14 @@
                            const base::android::JavaRef<jobject>& obj,
                            jint rotation);
 
-  // VideoCaptureMachine overrides.
-  void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy,
-             const media::VideoCaptureParams& params,
-             const base::Callback<void(bool)> callback) override;
-  void Stop(const base::Closure& callback) override;
-  void MaybeCaptureForRefresh() override;
+  // Starts/Stops capturing.
+  bool Start(scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy,
+             const VideoCaptureParams& params);
+  void Stop();
+
+  // If there is a cached frame, and the oracle allows sending another frame
+  // right now, the cached captured frame is redelivered.
+  void MaybeCaptureForRefresh();
 
  private:
   // Indicates the orientation of the device.
diff --git a/media/capture/content/thread_safe_capture_oracle.cc b/media/capture/content/android/thread_safe_capture_oracle.cc
similarity index 94%
rename from media/capture/content/thread_safe_capture_oracle.cc
rename to media/capture/content/android/thread_safe_capture_oracle.cc
index 4d07bb7..ef8732f 100644
--- a/media/capture/content/thread_safe_capture_oracle.cc
+++ b/media/capture/content/android/thread_safe_capture_oracle.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "media/capture/content/thread_safe_capture_oracle.h"
+#include "media/capture/content/android/thread_safe_capture_oracle.h"
 
 #include <stdint.h>
 
@@ -13,7 +13,6 @@
 #include "base/bits.h"
 #include "base/logging.h"
 #include "base/numerics/safe_conversions.h"
-#include "base/synchronization/lock.h"
 #include "base/time/time.h"
 #include "base/trace_event/trace_event.h"
 #include "media/base/video_frame.h"
@@ -44,11 +43,8 @@
 
 ThreadSafeCaptureOracle::ThreadSafeCaptureOracle(
     std::unique_ptr<VideoCaptureDevice::Client> client,
-    const VideoCaptureParams& params,
-    bool enable_auto_throttling)
-    : client_(std::move(client)),
-      oracle_(enable_auto_throttling),
-      params_(params) {
+    const VideoCaptureParams& params)
+    : client_(std::move(client)), oracle_(false), params_(params) {
   DCHECK_GE(params.requested_format.frame_rate, 1e-6f);
   oracle_.SetMinCapturePeriod(base::TimeDelta::FromMicroseconds(
       static_cast<int64_t>(1000000.0 / params.requested_format.frame_rate +
@@ -168,8 +164,8 @@
     return false;
   }
 
-  *callback = base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame, this,
-                         base::Passed(&capture));
+  *callback = base::BindOnce(&ThreadSafeCaptureOracle::DidCaptureFrame, this,
+                             base::Passed(&capture));
 
   return true;
 }
@@ -217,9 +213,6 @@
   const bool should_deliver_frame =
       oracle_.CompleteCapture(capture->frame_number, success, &reference_time);
 
-  // The following is used by
-  // chrome/browser/extension/api/cast_streaming/performance_test.cc, in
-  // addition to the usual runtime tracing.
   TRACE_EVENT_ASYNC_END2("gpu.capture", "Capture", capture->buffer.id,
                          "success", should_deliver_frame, "timestamp",
                          (reference_time - base::TimeTicks()).InMicroseconds());
diff --git a/media/capture/content/thread_safe_capture_oracle.h b/media/capture/content/android/thread_safe_capture_oracle.h
similarity index 83%
rename from media/capture/content/thread_safe_capture_oracle.h
rename to media/capture/content/android/thread_safe_capture_oracle.h
index cab7373..65e62f6 100644
--- a/media/capture/content/thread_safe_capture_oracle.h
+++ b/media/capture/content/android/thread_safe_capture_oracle.h
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef MEDIA_CAPTURE_CONTENT_THREAD_SAFE_CAPTURE_ORACLE_H_
-#define MEDIA_CAPTURE_CONTENT_THREAD_SAFE_CAPTURE_ORACLE_H_
+#ifndef MEDIA_CAPTURE_CONTENT_ANDROID_THREAD_SAFE_CAPTURE_ORACLE_H_
+#define MEDIA_CAPTURE_CONTENT_ANDROID_THREAD_SAFE_CAPTURE_ORACLE_H_
 
 #include <memory>
 #include <string>
 
 #include "base/memory/ref_counted.h"
-#include "media/base/video_frame.h"
+#include "base/synchronization/lock.h"
 #include "media/capture/capture_export.h"
 #include "media/capture/content/video_capture_oracle.h"
 #include "media/capture/video/video_capture_buffer_handle.h"
@@ -23,6 +23,7 @@
 
 struct VideoCaptureParams;
 class VideoFrame;
+class VideoFrameMetadata;
 
 // Thread-safe, refcounted proxy to the VideoCaptureOracle.  This proxy wraps
 // the VideoCaptureOracle, which decides which frames to capture, and a
@@ -32,16 +33,15 @@
     : public base::RefCountedThreadSafe<ThreadSafeCaptureOracle> {
  public:
   ThreadSafeCaptureOracle(std::unique_ptr<VideoCaptureDevice::Client> client,
-                          const VideoCaptureParams& params,
-                          bool enable_auto_throttling);
+                          const VideoCaptureParams& params);
 
   // Called when a captured frame is available or an error has occurred.
   // If |success| is true then |frame| is valid and |timestamp| indicates when
   // the frame was painted.
   // If |success| is false, all other parameters are invalid.
-  typedef base::Callback<void(scoped_refptr<VideoFrame> frame,
-                              base::TimeTicks timestamp,
-                              bool success)>
+  typedef base::OnceCallback<void(scoped_refptr<VideoFrame> frame,
+                                  base::TimeTicks timestamp,
+                                  bool success)>
       CaptureFrameCallback;
 
   // Record a change |event| along with its |damage_rect| and |event_time|, and
@@ -60,18 +60,6 @@
                                     scoped_refptr<VideoFrame>* storage,
                                     CaptureFrameCallback* callback);
 
-  base::TimeDelta min_capture_period() const {
-    return oracle_.min_capture_period();
-  }
-
-  base::TimeTicks last_time_animation_was_detected() const {
-    return oracle_.last_time_animation_was_detected();
-  }
-
-  gfx::Size max_frame_size() const {
-    return params_.requested_format.frame_size;
-  }
-
   // Returns the current capture resolution.
   gfx::Size GetCaptureSize() const;
 
@@ -125,4 +113,4 @@
 
 }  // namespace media
 
-#endif  // MEDIA_CAPTURE_CONTENT_THREAD_SAFE_CAPTURE_ORACLE_H_
+#endif  // MEDIA_CAPTURE_CONTENT_ANDROID_THREAD_SAFE_CAPTURE_ORACLE_H_
diff --git a/media/capture/content/screen_capture_device_core.cc b/media/capture/content/screen_capture_device_core.cc
deleted file mode 100644
index 5ae3939..0000000
--- a/media/capture/content/screen_capture_device_core.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "media/capture/content/screen_capture_device_core.h"
-
-#include <memory>
-#include <utility>
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/stringprintf.h"
-#include "base/threading/thread_checker.h"
-
-namespace media {
-
-namespace {
-
-void DeleteCaptureMachine(
-    std::unique_ptr<VideoCaptureMachine> capture_machine) {
-  capture_machine.reset();
-}
-
-}  // namespace
-
-VideoCaptureMachine::VideoCaptureMachine() = default;
-
-VideoCaptureMachine::~VideoCaptureMachine() = default;
-
-bool VideoCaptureMachine::IsAutoThrottlingEnabled() const {
-  return false;
-}
-
-void ScreenCaptureDeviceCore::AllocateAndStart(
-    const VideoCaptureParams& params,
-    std::unique_ptr<VideoCaptureDevice::Client> client) {
-  DCHECK(thread_checker_.CalledOnValidThread());
-
-  if (state_ != kIdle) {
-    DVLOG(1) << "Allocate() invoked when not in state Idle.";
-    return;
-  }
-
-  if (params.requested_format.pixel_format != PIXEL_FORMAT_I420) {
-    client->OnError(
-        FROM_HERE,
-        base::StringPrintf(
-            "unsupported format: %s",
-            VideoCaptureFormat::ToString(params.requested_format).c_str()));
-    return;
-  }
-
-  oracle_proxy_ = new ThreadSafeCaptureOracle(
-      std::move(client), params, capture_machine_->IsAutoThrottlingEnabled());
-
-  capture_machine_->Start(
-      oracle_proxy_, params,
-      base::Bind(&ScreenCaptureDeviceCore::CaptureStarted, AsWeakPtr()));
-
-  TransitionStateTo(kCapturing);
-}
-
-void ScreenCaptureDeviceCore::RequestRefreshFrame() {
-  DCHECK(thread_checker_.CalledOnValidThread());
-
-  if (state_ != kCapturing)
-    return;
-
-  capture_machine_->MaybeCaptureForRefresh();
-}
-
-void ScreenCaptureDeviceCore::Suspend() {
-  DCHECK(thread_checker_.CalledOnValidThread());
-
-  if (state_ != kCapturing)
-    return;
-
-  TransitionStateTo(kSuspended);
-
-  capture_machine_->Suspend();
-}
-
-void ScreenCaptureDeviceCore::Resume() {
-  DCHECK(thread_checker_.CalledOnValidThread());
-
-  if (state_ != kSuspended)
-    return;
-
-  TransitionStateTo(kCapturing);
-
-  capture_machine_->Resume();
-}
-
-void ScreenCaptureDeviceCore::StopAndDeAllocate() {
-  DCHECK(thread_checker_.CalledOnValidThread());
-
-  if (state_ != kCapturing && state_ != kSuspended)
-    return;
-
-  oracle_proxy_->Stop();
-  oracle_proxy_ = NULL;
-
-  TransitionStateTo(kIdle);
-
-  capture_machine_->Stop(base::DoNothing());
-}
-
-void ScreenCaptureDeviceCore::OnConsumerReportingUtilization(
-    int frame_feedback_id,
-    double utilization) {
-  DCHECK(thread_checker_.CalledOnValidThread());
-  DCHECK(oracle_proxy_);
-  oracle_proxy_->OnConsumerReportingUtilization(frame_feedback_id, utilization);
-}
-
-void ScreenCaptureDeviceCore::CaptureStarted(bool success) {
-  DCHECK(thread_checker_.CalledOnValidThread());
-  if (!success)
-    Error(FROM_HERE, "Failed to start capture machine.");
-  else if (oracle_proxy_)
-    oracle_proxy_->ReportStarted();
-}
-
-ScreenCaptureDeviceCore::ScreenCaptureDeviceCore(
-    std::unique_ptr<VideoCaptureMachine> capture_machine)
-    : state_(kIdle), capture_machine_(std::move(capture_machine)) {
-  DCHECK(capture_machine_.get());
-}
-
-ScreenCaptureDeviceCore::~ScreenCaptureDeviceCore() {
-  DCHECK(thread_checker_.CalledOnValidThread());
-  DCHECK(state_ != kCapturing && state_ != kSuspended);
-  if (capture_machine_) {
-    capture_machine_->Stop(
-        base::Bind(&DeleteCaptureMachine, base::Passed(&capture_machine_)));
-  }
-  DVLOG(1) << "ScreenCaptureDeviceCore@" << this << " destroying.";
-}
-
-void ScreenCaptureDeviceCore::TransitionStateTo(State next_state) {
-  DCHECK(thread_checker_.CalledOnValidThread());
-
-#ifndef NDEBUG
-  static const char* kStateNames[] = {"Idle", "Capturing", "Suspended",
-                                      "Error"};
-  static_assert(arraysize(kStateNames) == kLastCaptureState,
-                "Different number of states and textual descriptions");
-  DVLOG(1) << "State change: " << kStateNames[state_] << " --> "
-           << kStateNames[next_state];
-#endif
-
-  state_ = next_state;
-}
-
-void ScreenCaptureDeviceCore::Error(const base::Location& from_here,
-                                    const std::string& reason) {
-  DCHECK(thread_checker_.CalledOnValidThread());
-
-  if (state_ == kIdle)
-    return;
-
-  if (oracle_proxy_)
-    oracle_proxy_->ReportError(from_here, reason);
-
-  StopAndDeAllocate();
-  TransitionStateTo(kError);
-}
-
-}  // namespace media
diff --git a/media/capture/content/screen_capture_device_core.h b/media/capture/content/screen_capture_device_core.h
deleted file mode 100644
index 5f5bdcb..0000000
--- a/media/capture/content/screen_capture_device_core.h
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MEDIA_CAPTURE_CONTENT_SCREEN_CAPTURE_DEVICE_CORE_H_
-#define MEDIA_CAPTURE_CONTENT_SCREEN_CAPTURE_DEVICE_CORE_H_
-
-#include <memory>
-#include <string>
-
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/threading/thread_checker.h"
-#include "media/capture/capture_export.h"
-#include "media/capture/content/thread_safe_capture_oracle.h"
-#include "media/capture/video/video_capture_device.h"
-
-namespace base {
-class Location;
-}  // namespace base
-
-namespace media {
-
-struct VideoCaptureParams;
-
-class ThreadSafeCaptureOracle;
-
-// Keeps track of the video capture source frames and executes copying.
-class CAPTURE_EXPORT VideoCaptureMachine {
- public:
-  VideoCaptureMachine();
-  virtual ~VideoCaptureMachine();
-
-  // Starts capturing.
-  // |callback| is invoked with true if succeeded. Otherwise, with false.
-  virtual void Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy,
-                     const VideoCaptureParams& params,
-                     const base::Callback<void(bool)> callback) = 0;
-
-  // Suspend/Resume frame delivery. Implementations of these are optional.
-  virtual void Suspend() {}
-  virtual void Resume() {}
-
-  // Stops capturing.
-  // |callback| is invoked after the capturing has stopped.
-  virtual void Stop(const base::Closure& callback) = 0;
-
-  // Returns true if the video capture is configured to monitor end-to-end
-  // system utilization, and alter frame sizes and/or frame rates to mitigate
-  // overloading or under-utilization.
-  virtual bool IsAutoThrottlingEnabled() const;
-
-  // The implementation of this method should consult the oracle, using the
-  // kRefreshRequest event type, to decide whether to initiate a new frame
-  // capture, and then do so if the oracle agrees.
-  virtual void MaybeCaptureForRefresh() = 0;
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(VideoCaptureMachine);
-};
-
-// The "meat" of a content video capturer.
-//
-// Separating this from the "shell classes" WebContentsVideoCaptureDevice and
-// DesktopCaptureDeviceAura allows safe destruction without needing to block any
-// threads, as well as code sharing.
-//
-// ScreenCaptureDeviceCore manages a simple state machine and the pipeline
-// (see notes at top of this file).  It times the start of successive captures
-// and facilitates the processing of each through the stages of the
-// pipeline.
-class CAPTURE_EXPORT ScreenCaptureDeviceCore
-    : public base::SupportsWeakPtr<ScreenCaptureDeviceCore> {
- public:
-  ScreenCaptureDeviceCore(std::unique_ptr<VideoCaptureMachine> capture_machine);
-  virtual ~ScreenCaptureDeviceCore();
-
-  // Asynchronous requests to change ScreenCaptureDeviceCore state.
-  void AllocateAndStart(const VideoCaptureParams& params,
-                        std::unique_ptr<VideoCaptureDevice::Client> client);
-  void RequestRefreshFrame();
-  void Suspend();
-  void Resume();
-  void StopAndDeAllocate();
-  void OnConsumerReportingUtilization(int frame_feedback_id,
-                                      double utilization);
-
- private:
-  // Flag indicating current state.
-  enum State { kIdle, kCapturing, kSuspended, kError, kLastCaptureState };
-
-  void TransitionStateTo(State next_state);
-
-  // Called back in response to StartCaptureMachine().  |success| is true if
-  // capture machine succeeded to start.
-  void CaptureStarted(bool success);
-
-  // Stops capturing and notifies client_ of an error state.
-  void Error(const base::Location& from_here, const std::string& reason);
-
-  // Tracks that all activity occurs on the media stream manager's thread.
-  base::ThreadChecker thread_checker_;
-
-  // Current lifecycle state.
-  State state_;
-
-  // Tracks the CaptureMachine that's doing work on our behalf
-  // on the device thread or UI thread.
-  // This value should never be dereferenced by this class.
-  std::unique_ptr<VideoCaptureMachine> capture_machine_;
-
-  // Our thread-safe capture oracle which serves as the gateway to the video
-  // capture pipeline. Besides the VideoCaptureDevice itself, it is the only
-  // component of the system with direct access to |client_|.
-  scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_;
-
-  DISALLOW_COPY_AND_ASSIGN(ScreenCaptureDeviceCore);
-};
-
-}  // namespace media
-
-#endif  // MEDIA_CAPTURE_CONTENT_SCREEN_CAPTURE_DEVICE_CORE_H_