Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / render_widget_host_view_aura.cc
index f8602f2..116a6f4 100644 (file)
@@ -8,14 +8,10 @@
 #include "base/basictypes.h"
 #include "base/bind.h"
 #include "base/callback_helpers.h"
-#include "base/command_line.h"
 #include "base/debug/trace_event.h"
 #include "base/logging.h"
 #include "base/message_loop/message_loop.h"
 #include "base/strings/string_number_conversions.h"
-#include "cc/layers/delegated_frame_provider.h"
-#include "cc/output/compositor_frame.h"
-#include "cc/output/compositor_frame_ack.h"
 #include "cc/output/copy_output_request.h"
 #include "cc/output/copy_output_result.h"
 #include "cc/resources/texture_mailbox.h"
@@ -26,7 +22,6 @@
 #include "content/browser/frame_host/frame_tree_node.h"
 #include "content/browser/frame_host/render_frame_host_impl.h"
 #include "content/browser/gpu/compositor_util.h"
-#include "content/browser/renderer_host/backing_store_aura.h"
 #include "content/browser/renderer_host/compositor_resize_lock_aura.h"
 #include "content/browser/renderer_host/dip_util.h"
 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h"
 #include "content/common/gpu/client/gl_helper.h"
 #include "content/common/gpu/gpu_messages.h"
 #include "content/common/view_messages.h"
-#include "content/port/browser/render_widget_host_view_frame_subscriber.h"
-#include "content/port/browser/render_widget_host_view_port.h"
 #include "content/public/browser/content_browser_client.h"
-#include "content/public/browser/render_process_host.h"
 #include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
 #include "content/public/browser/user_metrics.h"
-#include "content/public/common/content_switches.h"
-#include "media/base/video_util.h"
-#include "skia/ext/image_operations.h"
 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
 #include "third_party/WebKit/public/web/WebInputEvent.h"
@@ -68,7 +58,6 @@
 #include "ui/base/ime/input_method.h"
 #include "ui/base/ui_base_types.h"
 #include "ui/compositor/compositor_vsync_manager.h"
-#include "ui/compositor/layer.h"
 #include "ui/events/event.h"
 #include "ui/events/event_utils.h"
 #include "ui/events/gestures/gesture_recognizer.h"
@@ -110,12 +99,6 @@ namespace content {
 
 namespace {
 
-void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory,
-                            uint32 sync_point,
-                            bool lost_resource) {
-  // NOTE: shared_memory will get released when we go out of scope.
-}
-
 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting
 // the border of the view, in order to get valid movement information. However,
 // forcing the cursor back to the center of the view after each mouse move
@@ -317,6 +300,7 @@ void GetScreenInfoForWindow(WebScreenInfo* results, aura::Window* window) {
   results->depth = 24;
   results->depthPerComponent = 8;
   results->deviceScaleFactor = display.device_scale_factor();
+  results->orientationAngle = display.RotationAsDegree();
 }
 
 bool PointerEventActivates(const ui::Event& event) {
@@ -332,58 +316,6 @@ bool PointerEventActivates(const ui::Event& event) {
   return false;
 }
 
-// Swap ack for the renderer when kCompositeToMailbox is enabled.
-void SendCompositorFrameAck(
-    int32 route_id,
-    uint32 output_surface_id,
-    int renderer_host_id,
-    const gpu::Mailbox& received_mailbox,
-    const gfx::Size& received_size,
-    bool skip_frame,
-    const scoped_refptr<ui::Texture>& texture_to_produce) {
-  cc::CompositorFrameAck ack;
-  ack.gl_frame_data.reset(new cc::GLFrameData());
-  DCHECK(!texture_to_produce.get() || !skip_frame);
-  if (texture_to_produce.get()) {
-    GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
-    ack.gl_frame_data->mailbox = texture_to_produce->Produce();
-    ack.gl_frame_data->size = texture_to_produce->size();
-    ack.gl_frame_data->sync_point =
-        gl_helper ? gl_helper->InsertSyncPoint() : 0;
-  } else if (skip_frame) {
-    // Skip the frame, i.e. tell the producer to reuse the same buffer that
-    // we just received.
-    ack.gl_frame_data->size = received_size;
-    ack.gl_frame_data->mailbox = received_mailbox;
-  }
-
-  RenderWidgetHostImpl::SendSwapCompositorFrameAck(
-      route_id, output_surface_id, renderer_host_id, ack);
-}
-
-void AcknowledgeBufferForGpu(
-    int32 route_id,
-    int gpu_host_id,
-    const gpu::Mailbox& received_mailbox,
-    bool skip_frame,
-    const scoped_refptr<ui::Texture>& texture_to_produce) {
-  AcceleratedSurfaceMsg_BufferPresented_Params ack;
-  uint32 sync_point = 0;
-  DCHECK(!texture_to_produce.get() || !skip_frame);
-  if (texture_to_produce.get()) {
-    GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
-    ack.mailbox = texture_to_produce->Produce();
-    sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0;
-  } else if (skip_frame) {
-    ack.mailbox = received_mailbox;
-    ack.sync_point = 0;
-  }
-
-  ack.sync_point = sync_point;
-  RenderWidgetHostImpl::AcknowledgeBufferPresent(
-      route_id, gpu_host_id, ack);
-}
-
 }  // namespace
 
 // We need to watch for mouse events outside a Web Popup or its parent
@@ -476,6 +408,7 @@ class RenderWidgetHostViewAura::WindowObserver : public aura::WindowObserver {
 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host)
     : host_(RenderWidgetHostImpl::From(host)),
       window_(new aura::Window(this)),
+      delegated_frame_host_(new DelegatedFrameHost(this)),
       in_shutdown_(false),
       in_bounds_changed_(false),
       is_fullscreen_(false),
@@ -487,17 +420,11 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host)
       can_compose_inline_(true),
       has_composition_text_(false),
       accept_return_character_(false),
-      last_output_surface_id_(0),
-      pending_delegated_ack_count_(0),
-      skipped_frames_(false),
-      last_swapped_surface_scale_factor_(1.f),
+      last_swapped_software_frame_scale_factor_(1.f),
       paint_canvas_(NULL),
       synthetic_move_sent_(false),
-      accelerated_compositing_state_changed_(false),
-      can_lock_compositor_(YES),
       cursor_visibility_state_in_renderer_(UNKNOWN),
       touch_editing_client_(NULL),
-      delegated_frame_evictor_(new DelegatedFrameEvictor(this)),
       weak_ptr_factory_(this) {
   host_->SetView(this);
   window_observer_.reset(new WindowObserver(this));
@@ -505,11 +432,8 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host)
   aura::client::SetActivationDelegate(window_, this);
   aura::client::SetActivationChangeObserver(window_, this);
   aura::client::SetFocusChangeObserver(window_, this);
-  window_->set_layer_owner_delegate(this);
+  window_->set_layer_owner_delegate(delegated_frame_host_.get());
   gfx::Screen::GetScreenFor(window_)->AddObserver(this);
-  software_frame_manager_.reset(new SoftwareFrameManager(
-      weak_ptr_factory_.GetWeakPtr()));
-  ImageTransportFactory::GetInstance()->AddObserver(this);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -619,8 +543,6 @@ void RenderWidgetHostViewAura::WasShown() {
   if (!host_->is_hidden())
     return;
   host_->WasShown();
-  software_frame_manager_->SetVisibility(true);
-  delegated_frame_evictor_->SetVisible(true);
 
   aura::Window* root = window_->GetRootWindow();
   if (root) {
@@ -630,12 +552,7 @@ void RenderWidgetHostViewAura::WasShown() {
       NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
   }
 
-  if (!current_surface_.get() && host_->is_accelerated_compositing_active() &&
-      !released_front_lock_.get()) {
-    ui::Compositor* compositor = GetCompositor();
-    if (compositor)
-      released_front_lock_ = compositor->GetCompositorLock();
-  }
+  delegated_frame_host_->WasShown();
 
 #if defined(OS_WIN)
   if (legacy_render_widget_host_HWND_) {
@@ -657,9 +574,7 @@ void RenderWidgetHostViewAura::WasHidden() {
   if (!host_ || host_->is_hidden())
     return;
   host_->WasHidden();
-  software_frame_manager_->SetVisibility(false);
-  delegated_frame_evictor_->SetVisible(false);
-  released_front_lock_ = NULL;
+  delegated_frame_host_->WasHidden();
 
 #if defined(OS_WIN)
   constrained_rects_.clear();
@@ -701,77 +616,6 @@ void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
   InternalSetBounds(gfx::Rect(relative_origin, rect.size()));
 }
 
-void RenderWidgetHostViewAura::MaybeCreateResizeLock() {
-  if (!ShouldCreateResizeLock())
-    return;
-  DCHECK(window_->GetHost());
-  DCHECK(window_->GetHost()->compositor());
-
-  // Listen to changes in the compositor lock state.
-  ui::Compositor* compositor = window_->GetHost()->compositor();
-  if (!compositor->HasObserver(this))
-    compositor->AddObserver(this);
-
-  bool defer_compositor_lock =
-      can_lock_compositor_ == NO_PENDING_RENDERER_FRAME ||
-      can_lock_compositor_ == NO_PENDING_COMMIT;
-
-  if (can_lock_compositor_ == YES)
-    can_lock_compositor_ = YES_DID_LOCK;
-
-  resize_lock_ = CreateResizeLock(defer_compositor_lock);
-}
-
-bool RenderWidgetHostViewAura::ShouldCreateResizeLock() {
-  // On Windows while resizing, the the resize locks makes us mis-paint a white
-  // vertical strip (including the non-client area) if the content composition
-  // is lagging the UI composition. So here we disable the throttling so that
-  // the UI bits can draw ahead of the content thereby reducing the amount of
-  // whiteout. Because this causes the content to be drawn at wrong sizes while
-  // resizing we compensate by blocking the UI thread in Compositor::Draw() by
-  // issuing a FinishAllRendering() if we are resizing.
-#if defined(OS_WIN)
-  return false;
-#else
-  if (resize_lock_)
-    return false;
-
-  if (host_->should_auto_resize())
-    return false;
-  if (!host_->is_accelerated_compositing_active())
-    return false;
-
-  gfx::Size desired_size = window_->bounds().size();
-  if (desired_size == current_frame_size_)
-    return false;
-
-  aura::WindowTreeHost* host = window_->GetHost();
-  if (!host)
-    return false;
-
-  ui::Compositor* compositor = host->compositor();
-  if (!compositor)
-    return false;
-
-  return true;
-#endif
-}
-
-scoped_ptr<ResizeLock> RenderWidgetHostViewAura::CreateResizeLock(
-    bool defer_compositor_lock) {
-  gfx::Size desired_size = window_->bounds().size();
-  return scoped_ptr<ResizeLock>(new CompositorResizeLock(
-      window_->GetHost(),
-      desired_size,
-      defer_compositor_lock,
-      base::TimeDelta::FromMilliseconds(kResizeLockTimeoutMs)));
-}
-
-void RenderWidgetHostViewAura::RequestCopyOfOutput(
-    scoped_ptr<cc::CopyOutputRequest> request) {
-  window_->layer()->RequestCopyOfOutput(request.Pass());
-}
-
 gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const {
   return window_;
 }
@@ -802,6 +646,10 @@ gfx::NativeViewAccessible RenderWidgetHostViewAura::GetNativeViewAccessible() {
   return static_cast<gfx::NativeViewAccessible>(NULL);
 }
 
+ui::TextInputClient* RenderWidgetHostViewAura::GetTextInputClient() {
+  return this;
+}
+
 void RenderWidgetHostViewAura::SetKeyboardFocus() {
 #if defined(OS_WIN)
   if (CanFocus()) {
@@ -825,7 +673,6 @@ RenderFrameHostImpl* RenderWidgetHostViewAura::GetFocusedFrame() {
 }
 
 void RenderWidgetHostViewAura::MovePluginWindows(
-    const gfx::Vector2d& scroll_offset,
     const std::vector<WebPluginGeometry>& plugin_window_moves) {
 #if defined(OS_WIN)
   // We need to clip the rectangle to the tab's viewport, otherwise we will draw
@@ -838,13 +685,12 @@ void RenderWidgetHostViewAura::MovePluginWindows(
   gfx::Rect view_bounds = window_->GetBoundsInRootWindow();
   std::vector<WebPluginGeometry> moves = plugin_window_moves;
 
-  gfx::Rect view_port(scroll_offset.x(), scroll_offset.y(), view_bounds.width(),
-                      view_bounds.height());
+  gfx::Rect view_port(view_bounds.size());
 
   for (size_t i = 0; i < moves.size(); ++i) {
     gfx::Rect clip(moves[i].clip_rect);
     gfx::Vector2d view_port_offset(
-        moves[i].window_rect.OffsetFromOrigin() + scroll_offset);
+        moves[i].window_rect.OffsetFromOrigin());
     clip.Offset(view_port_offset);
     clip.Intersect(view_port);
     clip.Offset(-view_port_offset);
@@ -896,7 +742,7 @@ bool RenderWidgetHostViewAura::HasFocus() const {
 }
 
 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const {
-  return CanCopyToBitmap() || !!host_->GetBackingStore(false);
+  return delegated_frame_host_->CanCopyToBitmap();
 }
 
 void RenderWidgetHostViewAura::Show() {
@@ -926,10 +772,7 @@ gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const {
   // for the correct frame (i.e. during a resize), don't change the size so that
   // we don't pipeline more resizes than we can handle.
   gfx::Rect bounds(window_->GetBoundsInScreen());
-  if (resize_lock_.get())
-    return gfx::Rect(bounds.origin(), resize_lock_->expected_size());
-  else
-    return bounds;
+  return delegated_frame_host_->GetViewBoundsWithResizeLock(bounds);
 }
 
 void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) {
@@ -938,6 +781,22 @@ void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) {
   window_->layer()->SetFillsBoundsOpaquely(background.isOpaque());
 }
 
+gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const {
+  gfx::Rect window_bounds = window_->bounds();
+  int viewport_width = std::max(
+      0, window_bounds.width() - insets_.left() - insets_.right());
+  int viewport_height = std::max(
+      0, window_bounds.height() - insets_.top() - insets_.bottom());
+  return gfx::Size(viewport_width, viewport_height);
+}
+
+void RenderWidgetHostViewAura::SetInsets(const gfx::Insets& insets) {
+  if (insets != insets_) {
+    insets_ = insets;
+    host_->WasResized();
+  }
+}
+
 void RenderWidgetHostViewAura::UpdateCursor(const WebCursor& cursor) {
   current_cursor_ = cursor;
   const gfx::Display display = gfx::Screen::GetScreenFor(window_)->
@@ -988,59 +847,6 @@ void RenderWidgetHostViewAura::ImeCompositionRangeChanged(
   composition_character_bounds_ = character_bounds;
 }
 
-void RenderWidgetHostViewAura::DidUpdateBackingStore(
-    const gfx::Rect& scroll_rect,
-    const gfx::Vector2d& scroll_delta,
-    const std::vector<gfx::Rect>& copy_rects,
-    const std::vector<ui::LatencyInfo>& latency_info) {
-  if (accelerated_compositing_state_changed_)
-    UpdateExternalTexture();
-
-  for (size_t i = 0; i < latency_info.size(); i++)
-    software_latency_info_.push_back(latency_info[i]);
-
-  // Use the state of the RenderWidgetHost and not the window as the two may
-  // differ. In particular if the window is hidden but the renderer isn't and we
-  // ignore the update and the window is made visible again the layer isn't
-  // marked as dirty and we show the wrong thing.
-  // We do this after UpdateExternalTexture() so that when we become visible
-  // we're not drawing a stale texture.
-  if (host_->is_hidden())
-    return;
-
-  gfx::Rect clip_rect;
-  if (paint_canvas_) {
-    SkRect sk_clip_rect;
-    if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect))
-      clip_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(sk_clip_rect));
-  }
-
-  if (!scroll_rect.IsEmpty())
-    SchedulePaintIfNotInClip(scroll_rect, clip_rect);
-
-#if defined(OS_WIN)
-  aura::WindowTreeHost* host = window_->GetHost();
-#endif
-  for (size_t i = 0; i < copy_rects.size(); ++i) {
-    gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect);
-    if (rect.IsEmpty())
-      continue;
-
-    SchedulePaintIfNotInClip(rect, clip_rect);
-
-#if defined(OS_WIN)
-    if (host) {
-      // Send the invalid rect in screen coordinates.
-      gfx::Rect screen_rect = GetViewBounds();
-      gfx::Rect invalid_screen_rect(rect);
-      invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y());
-      HWND hwnd = host->GetAcceleratedWidget();
-      PaintPluginWindowsHelper(hwnd, invalid_screen_rect);
-    }
-#endif  // defined(OS_WIN)
-  }
-}
-
 void RenderWidgetHostViewAura::RenderProcessGone(base::TerminationStatus status,
                                                  int error_code) {
   UpdateCursorIfOverSelf();
@@ -1121,134 +927,47 @@ void RenderWidgetHostViewAura::ScrollOffsetChanged() {
     cursor_client->DisableMouseEvents();
 }
 
-BackingStore* RenderWidgetHostViewAura::AllocBackingStore(
-    const gfx::Size& size) {
-  return new BackingStoreAura(host_, size);
-}
-
 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
     const gfx::Rect& src_subrect,
     const gfx::Size& dst_size,
     const base::Callback<void(bool, const SkBitmap&)>& callback,
     const SkBitmap::Config config) {
-  // Only ARGB888 and RGB565 supported as of now.
-  bool format_support = ((config == SkBitmap::kRGB_565_Config) ||
-                         (config == SkBitmap::kARGB_8888_Config));
-  if (!format_support) {
-    DCHECK(format_support);
-    callback.Run(false, SkBitmap());
-    return;
-  }
-  if (!CanCopyToBitmap()) {
-    callback.Run(false, SkBitmap());
-    return;
-  }
-
-  const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size);
-  scoped_ptr<cc::CopyOutputRequest> request =
-      cc::CopyOutputRequest::CreateRequest(base::Bind(
-          &RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult,
-          dst_size_in_pixel,
-          config,
-          callback));
-  gfx::Rect src_subrect_in_pixel =
-      ConvertRectToPixel(current_device_scale_factor_, src_subrect);
-  request->set_area(src_subrect_in_pixel);
-  RequestCopyOfOutput(request.Pass());
+  delegated_frame_host_->CopyFromCompositingSurface(
+      src_subrect, dst_size, callback, config);
 }
 
 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame(
       const gfx::Rect& src_subrect,
       const scoped_refptr<media::VideoFrame>& target,
       const base::Callback<void(bool)>& callback) {
-  if (!CanCopyToVideoFrame()) {
-    callback.Run(false);
-    return;
-  }
-
-  // Try get a texture to reuse.
-  scoped_refptr<OwnedMailbox> subscriber_texture;
-  if (frame_subscriber_) {
-    if (!idle_frame_subscriber_textures_.empty()) {
-      subscriber_texture = idle_frame_subscriber_textures_.back();
-      idle_frame_subscriber_textures_.pop_back();
-    } else if (GLHelper* helper =
-                   ImageTransportFactory::GetInstance()->GetGLHelper()) {
-      subscriber_texture = new OwnedMailbox(helper);
-    }
-    if (subscriber_texture.get())
-      active_frame_subscriber_textures_.insert(subscriber_texture.get());
-  }
-
-  scoped_ptr<cc::CopyOutputRequest> request =
-      cc::CopyOutputRequest::CreateRequest(base::Bind(
-          &RenderWidgetHostViewAura::
-               CopyFromCompositingSurfaceHasResultForVideo,
-          AsWeakPtr(),  // For caching the ReadbackYUVInterface on this class.
-          subscriber_texture,
-          target,
-          callback));
-  gfx::Rect src_subrect_in_pixel =
-      ConvertRectToPixel(current_device_scale_factor_, src_subrect);
-  request->set_area(src_subrect_in_pixel);
-  if (subscriber_texture.get()) {
-    request->SetTextureMailbox(
-        cc::TextureMailbox(subscriber_texture->mailbox(),
-                           subscriber_texture->target(),
-                           subscriber_texture->sync_point()));
-  }
-  RequestCopyOfOutput(request.Pass());
-}
-
-bool RenderWidgetHostViewAura::CanCopyToBitmap() const {
-  return GetCompositor() && window_->layer()->has_external_content();
+  delegated_frame_host_->CopyFromCompositingSurfaceToVideoFrame(
+      src_subrect, target, callback);
 }
 
 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const {
-  return GetCompositor() &&
-         window_->layer()->has_external_content() &&
-         host_->is_accelerated_compositing_active();
+  return delegated_frame_host_->CanCopyToVideoFrame();
 }
 
 bool RenderWidgetHostViewAura::CanSubscribeFrame() const {
-  return true;
+  return delegated_frame_host_->CanSubscribeFrame();
 }
 
 void RenderWidgetHostViewAura::BeginFrameSubscription(
     scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) {
-  frame_subscriber_ = subscriber.Pass();
+  delegated_frame_host_->BeginFrameSubscription(subscriber.Pass());
 }
 
 void RenderWidgetHostViewAura::EndFrameSubscription() {
-  idle_frame_subscriber_textures_.clear();
-  frame_subscriber_.reset();
+  delegated_frame_host_->EndFrameSubscription();
 }
 
 void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() {
-  // Delay processing the state change until we either get a software frame if
-  // switching to software mode or receive a buffers swapped notification
-  // if switching to accelerated mode.
-  // Sometimes (e.g. on a page load) the renderer will spuriously disable then
-  // re-enable accelerated compositing, causing us to flash.
-  // TODO(piman): factor the enable/disable accelerated compositing message into
-  // the UpdateRect/AcceleratedSurfaceBuffersSwapped messages so that we have
-  // fewer inconsistent temporary states.
-  accelerated_compositing_state_changed_ = true;
 }
 
 void RenderWidgetHostViewAura::AcceleratedSurfaceInitialized(int host_id,
                                                              int route_id) {
 }
 
-bool RenderWidgetHostViewAura::ShouldSkipFrame(gfx::Size size_in_dip) const {
-  if (can_lock_compositor_ == NO_PENDING_RENDERER_FRAME ||
-      can_lock_compositor_ == NO_PENDING_COMMIT ||
-      !resize_lock_.get())
-    return false;
-
-  return size_in_dip != resize_lock_->expected_size();
-}
-
 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
   if (HasDisplayPropertyChanged(window_))
     host_->InvalidateScreenInfo();
@@ -1258,7 +977,7 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
   if (!in_bounds_changed_)
     window_->SetBounds(rect);
   host_->WasResized();
-  MaybeCreateResizeLock();
+  delegated_frame_host_->WasResized();
   if (touch_editing_client_) {
     touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_,
       selection_focus_rect_);
@@ -1290,123 +1009,11 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
 #endif
 }
 
-void RenderWidgetHostViewAura::CheckResizeLock() {
-  if (!resize_lock_ || resize_lock_->expected_size() != current_frame_size_)
-    return;
-
-  // Since we got the size we were looking for, unlock the compositor. But delay
-  // the release of the lock until we've kicked a frame with the new texture, to
-  // avoid resizing the UI before we have a chance to draw a "good" frame.
-  resize_lock_->UnlockCompositor();
-  ui::Compositor* compositor = GetCompositor();
-  if (compositor) {
-    if (!compositor->HasObserver(this))
-      compositor->AddObserver(this);
-  }
-}
-
-void RenderWidgetHostViewAura::UpdateExternalTexture() {
-  // Delay processing accelerated compositing state change till here where we
-  // act upon the state change. (Clear the external texture if switching to
-  // software mode or set the external texture if going to accelerated mode).
-  if (accelerated_compositing_state_changed_)
-    accelerated_compositing_state_changed_ = false;
-
-  bool is_compositing_active = host_->is_accelerated_compositing_active();
-  if (is_compositing_active && current_surface_.get()) {
-    window_->layer()->SetExternalTexture(current_surface_.get());
-    current_frame_size_ = ConvertSizeToDIP(
-        current_surface_->device_scale_factor(), current_surface_->size());
-    CheckResizeLock();
-    software_frame_manager_->DiscardCurrentFrame();
-  } else if (is_compositing_active &&
-             software_frame_manager_->HasCurrentFrame()) {
-    cc::TextureMailbox mailbox;
-    scoped_ptr<cc::SingleReleaseCallback> callback;
-    software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback);
-    window_->layer()->SetTextureMailbox(mailbox,
-                                        callback.Pass(),
-                                        last_swapped_surface_scale_factor_);
-    current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_,
-                                           mailbox.shared_memory_size());
-    CheckResizeLock();
-  } else {
-    window_->layer()->SetShowPaintedContent();
-    resize_lock_.reset();
-    host_->WasResized();
-    software_frame_manager_->DiscardCurrentFrame();
-  }
-}
-
-bool RenderWidgetHostViewAura::SwapBuffersPrepare(
-    const gfx::Rect& surface_rect,
-    float surface_scale_factor,
-    const gfx::Rect& damage_rect,
-    const gpu::Mailbox& mailbox,
-    const BufferPresentedCallback& ack_callback) {
-  if (last_swapped_surface_size_ != surface_rect.size()) {
-    // The surface could have shrunk since we skipped an update, in which
-    // case we can expect a full update.
-    DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect";
-    skipped_damage_.setEmpty();
-    last_swapped_surface_size_ = surface_rect.size();
-    last_swapped_surface_scale_factor_ = surface_scale_factor;
-  }
-
-  if (ShouldSkipFrame(ConvertSizeToDIP(surface_scale_factor,
-                                       surface_rect.size())) ||
-      mailbox.IsZero()) {
-    skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op);
-    ack_callback.Run(true, scoped_refptr<ui::Texture>());
-    return false;
-  }
-
-  ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
-  current_surface_ =
-      factory->CreateTransportClient(surface_scale_factor);
-  if (!current_surface_.get()) {
-    LOG(ERROR) << "Failed to create ImageTransport texture";
-    ack_callback.Run(true, scoped_refptr<ui::Texture>());
-    return false;
-  }
-
-  current_surface_->Consume(mailbox, surface_rect.size());
-  released_front_lock_ = NULL;
-  UpdateExternalTexture();
-
-  return true;
-}
-
-void RenderWidgetHostViewAura::SwapBuffersCompleted(
-    const BufferPresentedCallback& ack_callback,
-    const scoped_refptr<ui::Texture>& texture_to_return) {
-  ui::Compositor* compositor = GetCompositor();
-  if (!compositor) {
-    ack_callback.Run(false, texture_to_return);
-  } else {
-    AddOnCommitCallbackAndDisableLocks(
-        base::Bind(ack_callback, false, texture_to_return));
-  }
-
-  DidReceiveFrameFromRenderer();
-}
-
-void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() {
-  if (frame_subscriber() && CanCopyToVideoFrame()) {
-    const base::TimeTicks present_time = base::TimeTicks::Now();
-    scoped_refptr<media::VideoFrame> frame;
-    RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback;
-    if (frame_subscriber()->ShouldCaptureFrame(present_time,
-                                               &frame, &callback)) {
-      CopyFromCompositingSurfaceToVideoFrame(
-          gfx::Rect(current_frame_size_),
-          frame,
-          base::Bind(callback, present_time));
-    }
-  }
+#if defined(OS_WIN)
+bool RenderWidgetHostViewAura::UsesNativeWindowFrame() const {
+  return (legacy_render_widget_host_HWND_ != NULL);
 }
 
-#if defined(OS_WIN)
 void RenderWidgetHostViewAura::UpdateConstrainedWindowRects(
     const std::vector<gfx::Rect>& rects) {
   // Check this before setting constrained_rects_, so that next time they're set
@@ -1440,268 +1047,7 @@ void RenderWidgetHostViewAura::UpdateMouseLockRegion() {
 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
     const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
     int gpu_host_id) {
-  BufferPresentedCallback ack_callback = base::Bind(
-      &AcknowledgeBufferForGpu,
-      params_in_pixel.route_id,
-      gpu_host_id,
-      params_in_pixel.mailbox);
-  BuffersSwapped(params_in_pixel.size,
-                 gfx::Rect(params_in_pixel.size),
-                 params_in_pixel.scale_factor,
-                 params_in_pixel.mailbox,
-                 params_in_pixel.latency_info,
-                 ack_callback);
-}
-
-void RenderWidgetHostViewAura::SwapDelegatedFrame(
-    uint32 output_surface_id,
-    scoped_ptr<cc::DelegatedFrameData> frame_data,
-    float frame_device_scale_factor,
-    const std::vector<ui::LatencyInfo>& latency_info) {
-  DCHECK_NE(0u, frame_data->render_pass_list.size());
-
-  cc::RenderPass* root_pass = frame_data->render_pass_list.back();
-
-  gfx::Size frame_size = root_pass->output_rect.size();
-  gfx::Size frame_size_in_dip =
-      ConvertSizeToDIP(frame_device_scale_factor, frame_size);
-
-  gfx::Rect damage_rect = gfx::ToEnclosingRect(root_pass->damage_rect);
-  damage_rect.Intersect(gfx::Rect(frame_size));
-  gfx::Rect damage_rect_in_dip =
-      ConvertRectToDIP(frame_device_scale_factor, damage_rect);
-
-  software_frame_manager_->DiscardCurrentFrame();
-
-  if (ShouldSkipFrame(frame_size_in_dip)) {
-    cc::CompositorFrameAck ack;
-    cc::TransferableResource::ReturnResources(frame_data->resource_list,
-                                              &ack.resources);
-    RenderWidgetHostImpl::SendSwapCompositorFrameAck(
-        host_->GetRoutingID(), output_surface_id,
-        host_->GetProcess()->GetID(), ack);
-    skipped_frames_ = true;
-    return;
-  }
-
-  if (skipped_frames_) {
-    skipped_frames_ = false;
-    damage_rect = gfx::Rect(frame_size);
-    damage_rect_in_dip = gfx::Rect(frame_size_in_dip);
-
-    // Give the same damage rect to the compositor.
-    cc::RenderPass* root_pass = frame_data->render_pass_list.back();
-    root_pass->damage_rect = damage_rect;
-  }
-
-  if (output_surface_id != last_output_surface_id_) {
-    // Resource ids are scoped by the output surface.
-    // If the originating output surface doesn't match the last one, it
-    // indicates the renderer's output surface may have been recreated, in which
-    // case we should recreate the DelegatedRendererLayer, to avoid matching
-    // resources from the old one with resources from the new one which would
-    // have the same id. Changing the layer to showing painted content destroys
-    // the DelegatedRendererLayer.
-    EvictDelegatedFrame();
-
-    // Drop the cc::DelegatedFrameResourceCollection so that we will not return
-    // any resources from the old output surface with the new output surface id.
-    if (resource_collection_.get()) {
-      resource_collection_->SetClient(NULL);
-
-      if (resource_collection_->LoseAllResources())
-        SendReturnedDelegatedResources(last_output_surface_id_);
-
-      resource_collection_ = NULL;
-    }
-    last_output_surface_id_ = output_surface_id;
-  }
-  if (frame_size.IsEmpty()) {
-    DCHECK_EQ(0u, frame_data->resource_list.size());
-    EvictDelegatedFrame();
-  } else {
-    if (!resource_collection_) {
-      resource_collection_ = new cc::DelegatedFrameResourceCollection;
-      resource_collection_->SetClient(this);
-    }
-    // If the physical frame size changes, we need a new |frame_provider_|. If
-    // the physical frame size is the same, but the size in DIP changed, we
-    // need to adjust the scale at which the frames will be drawn, and we do
-    // this by making a new |frame_provider_| also to ensure the scale change
-    // is presented in sync with the new frame content.
-    if (!frame_provider_.get() || frame_size != frame_provider_->frame_size() ||
-        frame_size_in_dip != current_frame_size_) {
-      frame_provider_ = new cc::DelegatedFrameProvider(
-          resource_collection_.get(), frame_data.Pass());
-      window_->layer()->SetShowDelegatedContent(frame_provider_.get(),
-                                                frame_size_in_dip);
-    } else {
-      frame_provider_->SetFrameData(frame_data.Pass());
-    }
-  }
-  released_front_lock_ = NULL;
-  current_frame_size_ = frame_size_in_dip;
-  CheckResizeLock();
-
-  window_->SchedulePaintInRect(damage_rect_in_dip);
-
-  pending_delegated_ack_count_++;
-
-  ui::Compositor* compositor = GetCompositor();
-  if (!compositor) {
-    SendDelegatedFrameAck(output_surface_id);
-  } else {
-    for (size_t i = 0; i < latency_info.size(); i++)
-      compositor->SetLatencyInfo(latency_info[i]);
-    AddOnCommitCallbackAndDisableLocks(
-        base::Bind(&RenderWidgetHostViewAura::SendDelegatedFrameAck,
-                   AsWeakPtr(),
-                   output_surface_id));
-  }
-  DidReceiveFrameFromRenderer();
-  if (frame_provider_.get())
-    delegated_frame_evictor_->SwappedFrame(!host_->is_hidden());
-  // Note: the frame may have been evicted immediately.
-}
-
-void RenderWidgetHostViewAura::SendDelegatedFrameAck(uint32 output_surface_id) {
-  cc::CompositorFrameAck ack;
-  if (resource_collection_)
-    resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources);
-  RenderWidgetHostImpl::SendSwapCompositorFrameAck(host_->GetRoutingID(),
-                                                   output_surface_id,
-                                                   host_->GetProcess()->GetID(),
-                                                   ack);
-  DCHECK_GT(pending_delegated_ack_count_, 0);
-  pending_delegated_ack_count_--;
-}
-
-void RenderWidgetHostViewAura::UnusedResourcesAreAvailable() {
-  if (pending_delegated_ack_count_)
-    return;
-
-  SendReturnedDelegatedResources(last_output_surface_id_);
-}
-
-void RenderWidgetHostViewAura::SendReturnedDelegatedResources(
-    uint32 output_surface_id) {
-  DCHECK(resource_collection_);
-
-  cc::CompositorFrameAck ack;
-  resource_collection_->TakeUnusedResourcesForChildCompositor(&ack.resources);
-  DCHECK(!ack.resources.empty());
-
-  RenderWidgetHostImpl::SendReclaimCompositorResources(
-      host_->GetRoutingID(),
-      output_surface_id,
-      host_->GetProcess()->GetID(),
-      ack);
-}
-
-void RenderWidgetHostViewAura::EvictDelegatedFrame() {
-  window_->layer()->SetShowPaintedContent();
-  frame_provider_ = NULL;
-  delegated_frame_evictor_->DiscardedFrame();
-}
-
-void RenderWidgetHostViewAura::SwapSoftwareFrame(
-    uint32 output_surface_id,
-    scoped_ptr<cc::SoftwareFrameData> frame_data,
-    float frame_device_scale_factor,
-    const std::vector<ui::LatencyInfo>& latency_info) {
-  const gfx::Size& frame_size = frame_data->size;
-  const gfx::Rect& damage_rect = frame_data->damage_rect;
-  gfx::Size frame_size_in_dip =
-      ConvertSizeToDIP(frame_device_scale_factor, frame_size);
-  if (ShouldSkipFrame(frame_size_in_dip)) {
-    ReleaseSoftwareFrame(output_surface_id, frame_data->id);
-    SendSoftwareFrameAck(output_surface_id);
-    return;
-  }
-
-  if (!software_frame_manager_->SwapToNewFrame(
-          output_surface_id,
-          frame_data.get(),
-          frame_device_scale_factor,
-          host_->GetProcess()->GetHandle())) {
-    ReleaseSoftwareFrame(output_surface_id, frame_data->id);
-    SendSoftwareFrameAck(output_surface_id);
-    return;
-  }
-
-  if (last_swapped_surface_size_ != frame_size) {
-    DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size))
-        << "Expected full damage rect";
-  }
-  last_swapped_surface_size_ = frame_size;
-  last_swapped_surface_scale_factor_ = frame_device_scale_factor;
-
-  cc::TextureMailbox mailbox;
-  scoped_ptr<cc::SingleReleaseCallback> callback;
-  software_frame_manager_->GetCurrentFrameMailbox(&mailbox, &callback);
-  DCHECK(mailbox.IsSharedMemory());
-  current_frame_size_ = frame_size_in_dip;
-
-  released_front_lock_ = NULL;
-  CheckResizeLock();
-  window_->layer()->SetTextureMailbox(mailbox,
-                                      callback.Pass(),
-                                      frame_device_scale_factor);
-  window_->SchedulePaintInRect(
-      ConvertRectToDIP(frame_device_scale_factor, damage_rect));
-
-  ui::Compositor* compositor = GetCompositor();
-  if (compositor) {
-    for (size_t i = 0; i < latency_info.size(); i++)
-      compositor->SetLatencyInfo(latency_info[i]);
-    AddOnCommitCallbackAndDisableLocks(
-        base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck,
-                   AsWeakPtr(),
-                   output_surface_id));
-  } else {
-    SendSoftwareFrameAck(output_surface_id);
-  }
-  DidReceiveFrameFromRenderer();
-
-  software_frame_manager_->SwapToNewFrameComplete(!host_->is_hidden());
-}
-
-void RenderWidgetHostViewAura::SendSoftwareFrameAck(uint32 output_surface_id) {
-  unsigned software_frame_id = 0;
-  if (released_software_frame_ &&
-      released_software_frame_->output_surface_id == output_surface_id) {
-    software_frame_id = released_software_frame_->frame_id;
-    released_software_frame_.reset();
-  }
-
-  cc::CompositorFrameAck ack;
-  ack.last_software_frame_id = software_frame_id;
-  RenderWidgetHostImpl::SendSwapCompositorFrameAck(
-      host_->GetRoutingID(), output_surface_id,
-      host_->GetProcess()->GetID(), ack);
-  SendReclaimSoftwareFrames();
-}
-
-void RenderWidgetHostViewAura::SendReclaimSoftwareFrames() {
-  if (!released_software_frame_)
-    return;
-  cc::CompositorFrameAck ack;
-  ack.last_software_frame_id = released_software_frame_->frame_id;
-  RenderWidgetHostImpl::SendReclaimCompositorResources(
-      host_->GetRoutingID(),
-      released_software_frame_->output_surface_id,
-      host_->GetProcess()->GetID(),
-      ack);
-  released_software_frame_.reset();
-}
-
-void RenderWidgetHostViewAura::ReleaseSoftwareFrame(
-    uint32 output_surface_id,
-    unsigned software_frame_id) {
-  SendReclaimSoftwareFrames();
-  DCHECK(!released_software_frame_);
-  released_software_frame_.reset(new ReleasedFrameInfo(
-      output_surface_id, software_frame_id));
+  // Oldschool composited mode is no longer supported.
 }
 
 void RenderWidgetHostViewAura::OnSwapCompositorFrame(
@@ -1709,44 +1055,21 @@ void RenderWidgetHostViewAura::OnSwapCompositorFrame(
     scoped_ptr<cc::CompositorFrame> frame) {
   TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame");
   if (frame->delegated_frame_data) {
-    SwapDelegatedFrame(output_surface_id,
-                       frame->delegated_frame_data.Pass(),
-                       frame->metadata.device_scale_factor,
-                       frame->metadata.latency_info);
+    delegated_frame_host_->SwapDelegatedFrame(
+        output_surface_id,
+        frame->delegated_frame_data.Pass(),
+        frame->metadata.device_scale_factor,
+        frame->metadata.latency_info);
     return;
   }
 
   if (frame->software_frame_data) {
-    SwapSoftwareFrame(output_surface_id,
-                      frame->software_frame_data.Pass(),
-                      frame->metadata.device_scale_factor,
-                      frame->metadata.latency_info);
+    DLOG(ERROR) << "Unable to use software frame in aura";
+    RecordAction(
+        base::UserMetricsAction("BadMessageTerminate_SharedMemoryAura"));
+    host_->GetProcess()->ReceivedBadMessage();
     return;
   }
-
-  if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero())
-    return;
-
-  BufferPresentedCallback ack_callback = base::Bind(
-      &SendCompositorFrameAck,
-      host_->GetRoutingID(), output_surface_id, host_->GetProcess()->GetID(),
-      frame->gl_frame_data->mailbox, frame->gl_frame_data->size);
-
-  if (!frame->gl_frame_data->sync_point) {
-    LOG(ERROR) << "CompositorFrame without sync point. Skipping frame...";
-    ack_callback.Run(true, scoped_refptr<ui::Texture>());
-    return;
-  }
-
-  GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
-  gl_helper->WaitSyncPoint(frame->gl_frame_data->sync_point);
-
-  BuffersSwapped(frame->gl_frame_data->size,
-                 frame->gl_frame_data->sub_buffer_rect,
-                 frame->metadata.device_scale_factor,
-                 frame->gl_frame_data->mailbox,
-                 frame->metadata.latency_info,
-                 ack_callback);
 }
 
 #if defined(OS_WIN)
@@ -1768,115 +1091,16 @@ gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
 }
 #endif
 
-void RenderWidgetHostViewAura::BuffersSwapped(
-    const gfx::Size& surface_size,
-    const gfx::Rect& damage_rect,
-    float surface_scale_factor,
-    const gpu::Mailbox& mailbox,
-    const std::vector<ui::LatencyInfo>& latency_info,
-    const BufferPresentedCallback& ack_callback) {
-  scoped_refptr<ui::Texture> previous_texture(current_surface_);
-  const gfx::Rect surface_rect = gfx::Rect(surface_size);
-  software_frame_manager_->DiscardCurrentFrame();
-
-  if (!SwapBuffersPrepare(surface_rect,
-                          surface_scale_factor,
-                          damage_rect,
-                          mailbox,
-                          ack_callback)) {
-    return;
-  }
-
-  SkRegion damage(RectToSkIRect(damage_rect));
-  if (!skipped_damage_.isEmpty()) {
-    damage.op(skipped_damage_, SkRegion::kUnion_Op);
-    skipped_damage_.setEmpty();
-  }
-
-  DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds())));
-  ui::Texture* current_texture = current_surface_.get();
-
-  const gfx::Size surface_size_in_pixel = surface_size;
-  DLOG_IF(ERROR, previous_texture.get() &&
-      previous_texture->size() != current_texture->size() &&
-      SkIRectToRect(damage.getBounds()) != surface_rect) <<
-      "Expected full damage rect after size change";
-  if (previous_texture.get() && !previous_damage_.isEmpty() &&
-      previous_texture->size() == current_texture->size()) {
-    ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
-    GLHelper* gl_helper = factory->GetGLHelper();
-    gl_helper->CopySubBufferDamage(
-        current_texture->PrepareTexture(),
-        previous_texture->PrepareTexture(),
-        damage,
-        previous_damage_);
-  }
-  previous_damage_ = damage;
-
-  ui::Compositor* compositor = GetCompositor();
-  if (compositor) {
-    // Co-ordinates come in OpenGL co-ordinate space.
-    // We need to convert to layer space.
-    gfx::Rect rect_to_paint =
-        ConvertRectToDIP(surface_scale_factor,
-                         gfx::Rect(damage_rect.x(),
-                                   surface_size_in_pixel.height() -
-                                       damage_rect.y() - damage_rect.height(),
-                                   damage_rect.width(),
-                                   damage_rect.height()));
-
-    // Damage may not have been DIP aligned, so inflate damage to compensate
-    // for any round-off error.
-    rect_to_paint.Inset(-1, -1);
-    rect_to_paint.Intersect(window_->bounds());
-
-    window_->SchedulePaintInRect(rect_to_paint);
-    for (size_t i = 0; i < latency_info.size(); i++)
-      compositor->SetLatencyInfo(latency_info[i]);
-  }
-
-  SwapBuffersCompleted(ack_callback, previous_texture);
-}
-
 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
     const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
     int gpu_host_id) {
-  gfx::Rect damage_rect(params_in_pixel.x,
-                        params_in_pixel.y,
-                        params_in_pixel.width,
-                        params_in_pixel.height);
-  BufferPresentedCallback ack_callback =
-      base::Bind(&AcknowledgeBufferForGpu,
-                 params_in_pixel.route_id,
-                 gpu_host_id,
-                 params_in_pixel.mailbox);
-  BuffersSwapped(params_in_pixel.surface_size,
-                 damage_rect,
-                 params_in_pixel.surface_scale_factor,
-                 params_in_pixel.mailbox,
-                 params_in_pixel.latency_info,
-                 ack_callback);
+  // Oldschool composited mode is no longer supported.
 }
 
 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() {
 }
 
 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() {
-  // This really tells us to release the frontbuffer.
-  if (current_surface_.get()) {
-    ui::Compositor* compositor = GetCompositor();
-    if (compositor) {
-      // We need to wait for a commit to clear to guarantee that all we
-      // will not issue any more GL referencing the previous surface.
-      AddOnCommitCallbackAndDisableLocks(
-          base::Bind(&RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor,
-                     AsWeakPtr(),
-                     current_surface_));  // Hold a ref so the texture will not
-                                          // get deleted until after commit.
-    }
-    current_surface_ = NULL;
-    UpdateExternalTexture();
-  }
 }
 
 bool RenderWidgetHostViewAura::HasAcceleratedSurface(
@@ -1887,333 +1111,46 @@ bool RenderWidgetHostViewAura::HasAcceleratedSurface(
   return false;
 }
 
-void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor(
-    scoped_refptr<ui::Texture>) {
-}
-
-// static
-void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult(
-    const gfx::Size& dst_size_in_pixel,
-    const SkBitmap::Config config,
-    const base::Callback<void(bool, const SkBitmap&)>& callback,
-    scoped_ptr<cc::CopyOutputResult> result) {
-  if (result->IsEmpty() || result->size().IsEmpty()) {
-    callback.Run(false, SkBitmap());
-    return;
-  }
-
-  if (result->HasTexture()) {
-    PrepareTextureCopyOutputResult(dst_size_in_pixel, config,
-                                   callback,
-                                   result.Pass());
-    return;
-  }
-
-  DCHECK(result->HasBitmap());
-  PrepareBitmapCopyOutputResult(dst_size_in_pixel, config, callback,
-                                result.Pass());
-}
-
-static void CopyFromCompositingSurfaceFinished(
-    const base::Callback<void(bool, const SkBitmap&)>& callback,
-    scoped_ptr<cc::SingleReleaseCallback> release_callback,
-    scoped_ptr<SkBitmap> bitmap,
-    scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
-    bool result) {
-  bitmap_pixels_lock.reset();
-
-  uint32 sync_point = 0;
-  if (result) {
-    GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
-    sync_point = gl_helper->InsertSyncPoint();
-  }
-  bool lost_resource = sync_point == 0;
-  release_callback->Run(sync_point, lost_resource);
-
-  callback.Run(result, *bitmap);
-}
-
-// static
-void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult(
-    const gfx::Size& dst_size_in_pixel,
-    const SkBitmap::Config config,
-    const base::Callback<void(bool, const SkBitmap&)>& callback,
-    scoped_ptr<cc::CopyOutputResult> result) {
-  DCHECK(result->HasTexture());
-  base::ScopedClosureRunner scoped_callback_runner(
-      base::Bind(callback, false, SkBitmap()));
-
-  scoped_ptr<SkBitmap> bitmap(new SkBitmap);
-  bitmap->setConfig(config,
-                    dst_size_in_pixel.width(), dst_size_in_pixel.height(),
-                    0, kOpaque_SkAlphaType);
-  if (!bitmap->allocPixels())
-    return;
-
-  ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
-  GLHelper* gl_helper = factory->GetGLHelper();
-  if (!gl_helper)
-    return;
-
-  scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock(
-      new SkAutoLockPixels(*bitmap));
-  uint8* pixels = static_cast<uint8*>(bitmap->getPixels());
-
-  cc::TextureMailbox texture_mailbox;
-  scoped_ptr<cc::SingleReleaseCallback> release_callback;
-  result->TakeTexture(&texture_mailbox, &release_callback);
-  DCHECK(texture_mailbox.IsTexture());
-  if (!texture_mailbox.IsTexture())
-    return;
-
-  ignore_result(scoped_callback_runner.Release());
-
-  gl_helper->CropScaleReadbackAndCleanMailbox(
-      texture_mailbox.mailbox(),
-      texture_mailbox.sync_point(),
-      result->size(),
-      gfx::Rect(result->size()),
-      dst_size_in_pixel,
-      pixels,
-      config,
-      base::Bind(&CopyFromCompositingSurfaceFinished,
-                 callback,
-                 base::Passed(&release_callback),
-                 base::Passed(&bitmap),
-                 base::Passed(&bitmap_pixels_lock)));
-}
-
-// static
-void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult(
-    const gfx::Size& dst_size_in_pixel,
-    const SkBitmap::Config config,
-    const base::Callback<void(bool, const SkBitmap&)>& callback,
-    scoped_ptr<cc::CopyOutputResult> result) {
-  if (config != SkBitmap::kARGB_8888_Config) {
-    NOTIMPLEMENTED();
-    callback.Run(false, SkBitmap());
-    return;
-  }
-  DCHECK(result->HasBitmap());
-  base::ScopedClosureRunner scoped_callback_runner(
-      base::Bind(callback, false, SkBitmap()));
-
-  scoped_ptr<SkBitmap> source = result->TakeBitmap();
-  DCHECK(source);
-  if (!source)
-    return;
-
-  ignore_result(scoped_callback_runner.Release());
-
-  SkBitmap bitmap = skia::ImageOperations::Resize(
-      *source,
-      skia::ImageOperations::RESIZE_BEST,
-      dst_size_in_pixel.width(),
-      dst_size_in_pixel.height());
-  callback.Run(true, bitmap);
-}
-
-// static
-void RenderWidgetHostViewAura::ReturnSubscriberTexture(
-    base::WeakPtr<RenderWidgetHostViewAura> rwhva,
-    scoped_refptr<OwnedMailbox> subscriber_texture,
-    uint32 sync_point) {
-  if (!subscriber_texture.get())
-    return;
-  if (!rwhva)
-    return;
-  DCHECK_NE(
-      rwhva->active_frame_subscriber_textures_.count(subscriber_texture.get()),
-      0u);
-
-  subscriber_texture->UpdateSyncPoint(sync_point);
-
-  rwhva->active_frame_subscriber_textures_.erase(subscriber_texture.get());
-  if (rwhva->frame_subscriber_ && subscriber_texture->texture_id())
-    rwhva->idle_frame_subscriber_textures_.push_back(subscriber_texture);
-}
-
-void RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinishedForVideo(
-    base::WeakPtr<RenderWidgetHostViewAura> rwhva,
-    const base::Callback<void(bool)>& callback,
-    scoped_refptr<OwnedMailbox> subscriber_texture,
-    scoped_ptr<cc::SingleReleaseCallback> release_callback,
-    bool result) {
-  callback.Run(result);
-
-  uint32 sync_point = 0;
-  if (result) {
-    GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
-    sync_point = gl_helper->InsertSyncPoint();
-  }
-  if (release_callback) {
-    // A release callback means the texture came from the compositor, so there
-    // should be no |subscriber_texture|.
-    DCHECK(!subscriber_texture);
-    bool lost_resource = sync_point == 0;
-    release_callback->Run(sync_point, lost_resource);
-  }
-  ReturnSubscriberTexture(rwhva, subscriber_texture, sync_point);
-}
-
-// static
-void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResultForVideo(
-    base::WeakPtr<RenderWidgetHostViewAura> rwhva,
-    scoped_refptr<OwnedMailbox> subscriber_texture,
-    scoped_refptr<media::VideoFrame> video_frame,
-    const base::Callback<void(bool)>& callback,
-    scoped_ptr<cc::CopyOutputResult> result) {
-  base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false));
-  base::ScopedClosureRunner scoped_return_subscriber_texture(
-      base::Bind(&ReturnSubscriberTexture, rwhva, subscriber_texture, 0));
-
-  if (!rwhva)
-    return;
-  if (result->IsEmpty())
-    return;
-  if (result->size().IsEmpty())
-    return;
-
-  // Compute the dest size we want after the letterboxing resize. Make the
-  // coordinates and sizes even because we letterbox in YUV space
-  // (see CopyRGBToVideoFrame). They need to be even for the UV samples to
-  // line up correctly.
-  // The video frame's coded_size() and the result's size() are both physical
-  // pixels.
-  gfx::Rect region_in_frame =
-      media::ComputeLetterboxRegion(gfx::Rect(video_frame->coded_size()),
-                                    result->size());
-  region_in_frame = gfx::Rect(region_in_frame.x() & ~1,
-                              region_in_frame.y() & ~1,
-                              region_in_frame.width() & ~1,
-                              region_in_frame.height() & ~1);
-  if (region_in_frame.IsEmpty())
-    return;
-
-  if (!result->HasTexture()) {
-    DCHECK(result->HasBitmap());
-    scoped_ptr<SkBitmap> bitmap = result->TakeBitmap();
-    // Scale the bitmap to the required size, if necessary.
-    SkBitmap scaled_bitmap;
-    if (result->size().width() != region_in_frame.width() ||
-        result->size().height() != region_in_frame.height()) {
-      skia::ImageOperations::ResizeMethod method =
-          skia::ImageOperations::RESIZE_GOOD;
-      scaled_bitmap = skia::ImageOperations::Resize(*bitmap.get(), method,
-                                                    region_in_frame.width(),
-                                                    region_in_frame.height());
-    } else {
-      scaled_bitmap = *bitmap.get();
-    }
-
-    {
-      SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap);
-
-      media::CopyRGBToVideoFrame(
-          reinterpret_cast<uint8*>(scaled_bitmap.getPixels()),
-          scaled_bitmap.rowBytes(),
-          region_in_frame,
-          video_frame.get());
-    }
-    ignore_result(scoped_callback_runner.Release());
-    callback.Run(true);
-    return;
-  }
-
-  ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
-  GLHelper* gl_helper = factory->GetGLHelper();
-  if (!gl_helper)
-    return;
-  if (subscriber_texture.get() && !subscriber_texture->texture_id())
-    return;
-
-  cc::TextureMailbox texture_mailbox;
-  scoped_ptr<cc::SingleReleaseCallback> release_callback;
-  result->TakeTexture(&texture_mailbox, &release_callback);
-  DCHECK(texture_mailbox.IsTexture());
-  if (!texture_mailbox.IsTexture())
-    return;
-
-  gfx::Rect result_rect(result->size());
-
-  content::ReadbackYUVInterface* yuv_readback_pipeline =
-      rwhva->yuv_readback_pipeline_.get();
-  if (yuv_readback_pipeline == NULL ||
-      yuv_readback_pipeline->scaler()->SrcSize() != result_rect.size() ||
-      yuv_readback_pipeline->scaler()->SrcSubrect() != result_rect ||
-      yuv_readback_pipeline->scaler()->DstSize() != region_in_frame.size()) {
-    GLHelper::ScalerQuality quality = GLHelper::SCALER_QUALITY_FAST;
-    std::string quality_switch = switches::kTabCaptureDownscaleQuality;
-    // If we're scaling up, we can use the "best" quality.
-    if (result_rect.size().width() < region_in_frame.size().width() &&
-        result_rect.size().height() < region_in_frame.size().height())
-      quality_switch = switches::kTabCaptureUpscaleQuality;
-
-    std::string switch_value =
-        CommandLine::ForCurrentProcess()->GetSwitchValueASCII(quality_switch);
-    if (switch_value == "fast")
-      quality = GLHelper::SCALER_QUALITY_FAST;
-    else if (switch_value == "good")
-      quality = GLHelper::SCALER_QUALITY_GOOD;
-    else if (switch_value == "best")
-      quality = GLHelper::SCALER_QUALITY_BEST;
-
-    rwhva->yuv_readback_pipeline_.reset(
-        gl_helper->CreateReadbackPipelineYUV(quality,
-                                             result_rect.size(),
-                                             result_rect,
-                                             video_frame->coded_size(),
-                                             region_in_frame,
-                                             true,
-                                             true));
-    yuv_readback_pipeline = rwhva->yuv_readback_pipeline_.get();
-  }
-
-  ignore_result(scoped_callback_runner.Release());
-  ignore_result(scoped_return_subscriber_texture.Release());
-  base::Callback<void(bool result)> finished_callback = base::Bind(
-      &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinishedForVideo,
-      rwhva->AsWeakPtr(),
-      callback,
-      subscriber_texture,
-      base::Passed(&release_callback));
-  yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(),
-                                     texture_mailbox.sync_point(),
-                                     video_frame.get(),
-                                     finished_callback);
-}
-
 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) {
   GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL);
 }
 
 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() {
-#if defined(OS_WIN)
-  // aura::Window::GetBoundsInScreen doesn't take non-client area into
-  // account.
-  RECT window_rect = {0};
-
   aura::Window* top_level = window_->GetToplevelWindow();
-  aura::WindowTreeHost* host = top_level->GetHost();
-  if (!host)
-    return top_level->GetBoundsInScreen();
-  HWND hwnd = host->GetAcceleratedWidget();
-  ::GetWindowRect(hwnd, &window_rect);
-  gfx::Rect rect(window_rect);
+  gfx::Rect bounds(top_level->GetBoundsInScreen());
 
-  // Maximized windows are outdented from the work area by the frame thickness
-  // even though this "frame" is not painted.  This confuses code (and people)
-  // that think of a maximized window as corresponding exactly to the work area.
-  // Correct for this by subtracting the frame thickness back off.
-  if (::IsZoomed(hwnd)) {
-    rect.Inset(GetSystemMetrics(SM_CXSIZEFRAME),
-               GetSystemMetrics(SM_CYSIZEFRAME));
+#if defined(OS_WIN)
+  // TODO(zturner,iyengar): This will break when we remove support for NPAPI and
+  // remove the legacy hwnd, so a better fix will need to be decided when that
+  // happens.
+  if (UsesNativeWindowFrame()) {
+    // aura::Window doesn't take into account non-client area of native windows
+    // (e.g. HWNDs), so for that case ask Windows directly what the bounds are.
+    aura::WindowTreeHost* host = top_level->GetHost();
+    if (!host)
+      return top_level->GetBoundsInScreen();
+    RECT window_rect = {0};
+    HWND hwnd = host->GetAcceleratedWidget();
+    ::GetWindowRect(hwnd, &window_rect);
+    bounds = gfx::Rect(window_rect);
+
+    // Maximized windows are outdented from the work area by the frame thickness
+    // even though this "frame" is not painted.  This confuses code (and people)
+    // that think of a maximized window as corresponding exactly to the work
+    // area.  Correct for this by subtracting the frame thickness back off.
+    if (::IsZoomed(hwnd)) {
+      bounds.Inset(GetSystemMetrics(SM_CXSIZEFRAME),
+                   GetSystemMetrics(SM_CYSIZEFRAME));
+
+      bounds.Inset(GetSystemMetrics(SM_CXPADDEDBORDER),
+                   GetSystemMetrics(SM_CXPADDEDBORDER));
+    }
   }
 
-  return gfx::win::ScreenToDIPRect(rect);
-#else
-  return window_->GetToplevelWindow()->GetBoundsInScreen();
+  bounds = gfx::win::ScreenToDIPRect(bounds);
 #endif
+
+  return bounds;
 }
 
 void RenderWidgetHostViewAura::GestureEventAck(
@@ -2249,11 +1186,6 @@ RenderWidgetHostViewAura::CreateSyntheticGestureTarget() {
       new SyntheticGestureTargetAura(host_));
 }
 
-void RenderWidgetHostViewAura::SetHasHorizontalScrollbar(
-    bool has_horizontal_scrollbar) {
-  // Not needed. Mac-only.
-}
-
 void RenderWidgetHostViewAura::SetScrollOffsetPinning(
     bool is_pinned_to_left, bool is_pinned_to_right) {
   // Not needed. Mac-only.
@@ -2280,11 +1212,11 @@ void RenderWidgetHostViewAura::CreateBrowserAccessibilityManagerIfNeeded() {
   if (legacy_render_widget_host_HWND_) {
     manager = new BrowserAccessibilityManagerWin(
         legacy_render_widget_host_HWND_.get(), accessible_parent,
-        BrowserAccessibilityManagerWin::GetEmptyDocument(), this);
+        BrowserAccessibilityManagerWin::GetEmptyDocument(), host_);
   }
 #else
   manager = BrowserAccessibilityManager::Create(
-      BrowserAccessibilityManager::GetEmptyDocument(), this);
+      BrowserAccessibilityManager::GetEmptyDocument(), host_);
 #endif
   SetBrowserAccessibilityManager(manager);
 }
@@ -2637,6 +1569,9 @@ void RenderWidgetHostViewAura::OnBoundsChanged(const gfx::Rect& old_bounds,
   // SetBounds() itself.  No matter how we got here, any redundant calls are
   // harmless.
   SetSize(new_bounds.size());
+
+  if (GetInputMethod())
+    GetInputMethod()->OnCaretBoundsChanged(this);
 }
 
 gfx::NativeCursor RenderWidgetHostViewAura::GetCursor(const gfx::Point& point) {
@@ -2667,27 +1602,11 @@ void RenderWidgetHostViewAura::OnCaptureLost() {
 }
 
 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) {
-  bool has_backing_store = !!host_->GetBackingStore(false);
-  if (has_backing_store) {
-    paint_canvas_ = canvas;
-    BackingStoreAura* backing_store = static_cast<BackingStoreAura*>(
-        host_->GetBackingStore(true));
-    paint_canvas_ = NULL;
-    backing_store->SkiaShowRect(gfx::Point(), canvas);
-
-    ui::Compositor* compositor = GetCompositor();
-    if (compositor) {
-      for (size_t i = 0; i < software_latency_info_.size(); i++)
-        compositor->SetLatencyInfo(software_latency_info_[i]);
-    }
-    software_latency_info_.clear();
-  } else {
-    // For non-opaque windows, we don't draw anything, since we depend on the
-    // canvas coming from the compositor to already be initialized as
-    // transparent.
-    if (window_->layer()->fills_bounds_opaquely())
-      canvas->DrawColor(SK_ColorWHITE);
-  }
+  // For non-opaque windows, we don't draw anything, since we depend on the
+  // canvas coming from the compositor to already be initialized as
+  // transparent.
+  if (window_->layer()->fills_bounds_opaquely())
+    canvas->DrawColor(SK_ColorWHITE);
 }
 
 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
@@ -2695,11 +1614,6 @@ void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
   if (!host_)
     return;
 
-  BackingStoreAura* backing_store = static_cast<BackingStoreAura*>(
-      host_->GetBackingStore(false));
-  if (backing_store)  // NULL in hardware path.
-    backing_store->ScaleFactorChanged(device_scale_factor);
-
   UpdateScreenInfo(window_);
 
   const gfx::Display display = gfx::Screen::GetScreenFor(window_)->
@@ -3116,6 +2030,10 @@ void RenderWidgetHostViewAura::OnWindowFocused(aura::Window* gained_focus,
     } else {
       host_->SetInputMethodActive(false);
     }
+
+    BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager();
+    if (manager)
+      manager->OnWindowFocused();
   } else if (window_ == lost_focus) {
     host_->SetActive(false);
     host_->Blur();
@@ -3126,6 +2044,10 @@ void RenderWidgetHostViewAura::OnWindowFocused(aura::Window* gained_focus,
     if (touch_editing_client_)
       touch_editing_client_->EndTouchEditing(false);
 
+    BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager();
+    if (manager)
+      manager->OnWindowBlurred();
+
     // If we lose the focus while fullscreen, close the window; Pepper Flash
     // won't do it for us (unlike NPAPI Flash). However, we do not close the
     // window if we lose the focus to a window on another display.
@@ -3164,150 +2086,13 @@ void RenderWidgetHostViewAura::OnHostMoved(const aura::WindowTreeHost* host,
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// RenderWidgetHostViewAura, SoftwareFrameManagerClient implementation:
-
-void RenderWidgetHostViewAura::SoftwareFrameWasFreed(
-    uint32 output_surface_id, unsigned frame_id) {
-  ReleaseSoftwareFrame(output_surface_id, frame_id);
-}
-
-void RenderWidgetHostViewAura::ReleaseReferencesToSoftwareFrame() {
-  ui::Compositor* compositor = GetCompositor();
-  if (compositor) {
-    AddOnCommitCallbackAndDisableLocks(base::Bind(
-        &RenderWidgetHostViewAura::SendReclaimSoftwareFrames, AsWeakPtr()));
-  }
-  UpdateExternalTexture();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// RenderWidgetHostViewAura, ui::CompositorObserver implementation:
-
-void RenderWidgetHostViewAura::OnCompositingDidCommit(
-    ui::Compositor* compositor) {
-  if (can_lock_compositor_ == NO_PENDING_COMMIT) {
-    can_lock_compositor_ = YES;
-    if (resize_lock_.get() && resize_lock_->GrabDeferredLock())
-      can_lock_compositor_ = YES_DID_LOCK;
-  }
-  RunOnCommitCallbacks();
-  if (resize_lock_ && resize_lock_->expected_size() == current_frame_size_) {
-    resize_lock_.reset();
-    host_->WasResized();
-    // We may have had a resize while we had the lock (e.g. if the lock expired,
-    // or if the UI still gave us some resizes), so make sure we grab a new lock
-    // if necessary.
-    MaybeCreateResizeLock();
-  }
-}
-
-void RenderWidgetHostViewAura::OnCompositingStarted(
-    ui::Compositor* compositor, base::TimeTicks start_time) {
-  last_draw_ended_ = start_time;
-}
-
-void RenderWidgetHostViewAura::OnCompositingEnded(
-    ui::Compositor* compositor) {
-}
-
-void RenderWidgetHostViewAura::OnCompositingAborted(
-    ui::Compositor* compositor) {
-}
-
-void RenderWidgetHostViewAura::OnCompositingLockStateChanged(
-    ui::Compositor* compositor) {
-  // A compositor lock that is part of a resize lock timed out. We
-  // should display a renderer frame.
-  if (!compositor->IsLocked() && can_lock_compositor_ == YES_DID_LOCK) {
-    can_lock_compositor_ = NO_PENDING_RENDERER_FRAME;
-  }
-}
-
-void RenderWidgetHostViewAura::OnUpdateVSyncParameters(
-    base::TimeTicks timebase,
-    base::TimeDelta interval) {
-  if (IsShowing())
-    host_->UpdateVSyncParameters(timebase, interval);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// RenderWidgetHostViewAura, BrowserAccessibilityDelegate implementation:
-
-void RenderWidgetHostViewAura::SetAccessibilityFocus(int acc_obj_id) {
-  if (!host_)
-    return;
-
-  host_->AccessibilitySetFocus(acc_obj_id);
-}
-
-void RenderWidgetHostViewAura::AccessibilityDoDefaultAction(int acc_obj_id) {
-  if (!host_)
-    return;
-
-  host_->AccessibilityDoDefaultAction(acc_obj_id);
-}
-
-void RenderWidgetHostViewAura::AccessibilityScrollToMakeVisible(
-    int acc_obj_id, gfx::Rect subfocus) {
-  if (!host_)
-    return;
-
-  host_->AccessibilityScrollToMakeVisible(acc_obj_id, subfocus);
-}
-
-void RenderWidgetHostViewAura::AccessibilityScrollToPoint(
-    int acc_obj_id, gfx::Point point) {
-  if (!host_)
-    return;
-
-  host_->AccessibilityScrollToPoint(acc_obj_id, point);
-}
-
-void RenderWidgetHostViewAura::AccessibilitySetTextSelection(
-    int acc_obj_id, int start_offset, int end_offset) {
-  if (!host_)
-    return;
-
-  host_->AccessibilitySetTextSelection(
-      acc_obj_id, start_offset, end_offset);
-}
-
-gfx::Point RenderWidgetHostViewAura::GetLastTouchEventLocation() const {
-  // Only needed for Win 8 non-aura.
-  return gfx::Point();
-}
-
-void RenderWidgetHostViewAura::FatalAccessibilityTreeError() {
-  host_->FatalAccessibilityTreeError();
-  SetBrowserAccessibilityManager(NULL);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// RenderWidgetHostViewAura, ImageTransportFactoryObserver implementation:
-
-void RenderWidgetHostViewAura::OnLostResources() {
-  current_surface_ = NULL;
-  UpdateExternalTexture();
-
-  idle_frame_subscriber_textures_.clear();
-  yuv_readback_pipeline_.reset();
-
-  // Make sure all ImageTransportClients are deleted now that the context those
-  // are using is becoming invalid. This sends pending ACKs and needs to happen
-  // after calling UpdateExternalTexture() which syncs with the impl thread.
-  RunOnCommitCallbacks();
-  host_->ScheduleComposite();
-}
-
-////////////////////////////////////////////////////////////////////////////////
 // RenderWidgetHostViewAura, private:
 
 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
   if (touch_editing_client_)
     touch_editing_client_->OnViewDestroyed();
 
-  ImageTransportFactory::GetInstance()->RemoveObserver(this);
-
+  delegated_frame_host_.reset();
   window_observer_.reset();
   if (window_->GetHost())
     window_->GetHost()->RemoveObserver(this);
@@ -3331,24 +2116,9 @@ RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
   // associated with the window, but just in case.
   DetachFromInputMethod();
 
-  if (resource_collection_.get())
-    resource_collection_->SetClient(NULL);
-
-  // An OwnedMailbox should not refer to the GLHelper anymore once the RWHVA is
-  // destroyed, as it may then outlive the GLHelper.
-  for (std::set<OwnedMailbox*>::iterator it =
-           active_frame_subscriber_textures_.begin();
-       it != active_frame_subscriber_textures_.end();
-       ++it) {
-    (*it)->Destroy();
-  }
-  active_frame_subscriber_textures_.clear();
-
 #if defined(OS_WIN)
   legacy_render_widget_host_HWND_.reset(NULL);
 #endif
-
-  DCHECK(!vsync_manager_);
 }
 
 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
@@ -3471,27 +2241,6 @@ bool RenderWidgetHostViewAura::ShouldMoveToCenter() {
       global_mouse_position_.y() > rect.bottom() - border_y;
 }
 
-void RenderWidgetHostViewAura::RunOnCommitCallbacks() {
-  for (std::vector<base::Closure>::const_iterator
-      it = on_compositing_did_commit_callbacks_.begin();
-      it != on_compositing_did_commit_callbacks_.end(); ++it) {
-    it->Run();
-  }
-  on_compositing_did_commit_callbacks_.clear();
-}
-
-void RenderWidgetHostViewAura::AddOnCommitCallbackAndDisableLocks(
-    const base::Closure& callback) {
-  ui::Compositor* compositor = GetCompositor();
-  DCHECK(compositor);
-
-  if (!compositor->HasObserver(this))
-    compositor->AddObserver(this);
-
-  can_lock_compositor_ = NO_PENDING_COMMIT;
-  on_compositing_did_commit_callbacks_.push_back(callback);
-}
-
 void RenderWidgetHostViewAura::AddedToRootWindow() {
   window_->GetHost()->AddObserver(this);
   UpdateScreenInfo(window_);
@@ -3502,8 +2251,6 @@ void RenderWidgetHostViewAura::AddedToRootWindow() {
     cursor_client->AddObserver(this);
     NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
   }
-  if (current_surface_.get())
-    UpdateExternalTexture();
   if (HasFocus()) {
     ui::InputMethod* input_method = GetInputMethod();
     if (input_method)
@@ -3518,12 +2265,7 @@ void RenderWidgetHostViewAura::AddedToRootWindow() {
         reinterpret_cast<HWND>(GetNativeViewId()));
 #endif
 
-  ui::Compositor* compositor = GetCompositor();
-  if (compositor) {
-    DCHECK(!vsync_manager_);
-    vsync_manager_ = compositor->vsync_manager();
-    vsync_manager_->AddObserver(this);
-  }
+  delegated_frame_host_->AddedToWindow();
 }
 
 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
@@ -3535,21 +2277,7 @@ void RenderWidgetHostViewAura::RemovingFromRootWindow() {
   DetachFromInputMethod();
 
   window_->GetHost()->RemoveObserver(this);
-  ui::Compositor* compositor = GetCompositor();
-  if (current_surface_.get()) {
-    // We can't get notification for commits after this point, which would
-    // guarantee that the compositor isn't using an old texture any more, so
-    // instead we force the layer to stop using any external resources which
-    // synchronizes with the compositor thread, and makes it safe to run the
-    // callback.
-    window_->layer()->SetShowPaintedContent();
-  }
-  RunOnCommitCallbacks();
-  resize_lock_.reset();
-  host_->WasResized();
-
-  if (compositor && compositor->HasObserver(this))
-    compositor->RemoveObserver(this);
+  delegated_frame_host_->RemovingFromWindow();
 
 #if defined(OS_WIN)
   // Update the legacy window's parent temporarily to the desktop window. It
@@ -3557,16 +2285,6 @@ void RenderWidgetHostViewAura::RemovingFromRootWindow() {
   if (legacy_render_widget_host_HWND_)
     legacy_render_widget_host_HWND_->UpdateParent(::GetDesktopWindow());
 #endif
-
-  if (vsync_manager_) {
-    vsync_manager_->RemoveObserver(this);
-    vsync_manager_ = NULL;
-  }
-}
-
-ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const {
-  aura::WindowTreeHost* host = window_->GetHost();
-  return host ? host->compositor() : NULL;
 }
 
 void RenderWidgetHostViewAura::DetachFromInputMethod() {
@@ -3604,88 +2322,69 @@ void RenderWidgetHostViewAura::ForwardKeyboardEvent(
   host_->ForwardKeyboardEvent(event);
 }
 
-void RenderWidgetHostViewAura::LockResources() {
-  DCHECK(frame_provider_);
-  delegated_frame_evictor_->LockFrame();
+SkBitmap::Config RenderWidgetHostViewAura::PreferredReadbackFormat() {
+  return SkBitmap::kARGB_8888_Config;
 }
 
-void RenderWidgetHostViewAura::UnlockResources() {
-  DCHECK(frame_provider_);
-  delegated_frame_evictor_->UnlockFrame();
+////////////////////////////////////////////////////////////////////////////////
+// DelegatedFrameHost, public:
+
+ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const {
+  aura::WindowTreeHost* host = window_->GetHost();
+  return host ? host->compositor() : NULL;
 }
 
-SkBitmap::Config RenderWidgetHostViewAura::PreferredReadbackFormat() {
-  return SkBitmap::kARGB_8888_Config;
+ui::Layer* RenderWidgetHostViewAura::GetLayer() {
+  return window_->layer();
 }
 
-////////////////////////////////////////////////////////////////////////////////
-// RenderWidgetHostViewAura, ui::LayerOwnerDelegate implementation:
-
-void RenderWidgetHostViewAura::OnLayerRecreated(ui::Layer* old_layer,
-                                                ui::Layer* new_layer) {
-  float mailbox_scale_factor;
-  cc::TextureMailbox old_mailbox =
-      old_layer->GetTextureMailbox(&mailbox_scale_factor);
-  scoped_refptr<ui::Texture> old_texture = old_layer->external_texture();
-  // The new_layer is the one that will be used by our Window, so that's the one
-  // that should keep our texture. old_layer will be returned to the
-  // RecreateLayer caller, and should have a copy.
-  if (old_texture.get()) {
-    ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
-    GLHelper* gl_helper = factory->GetGLHelper();
-    scoped_refptr<ui::Texture> new_texture;
-    if (host_->is_accelerated_compositing_active() &&
-        gl_helper && current_surface_.get()) {
-      GLuint texture_id =
-          gl_helper->CopyTexture(current_surface_->PrepareTexture(),
-                                 current_surface_->size());
-      if (texture_id) {
-        new_texture = factory->CreateOwnedTexture(
-          current_surface_->size(),
-          current_surface_->device_scale_factor(), texture_id);
-      }
-    }
-    if (new_texture.get())
-      old_layer->SetExternalTexture(new_texture.get());
-    else
-      old_layer->SetShowPaintedContent();
-    new_layer->SetExternalTexture(old_texture.get());
-  } else if (old_mailbox.IsSharedMemory()) {
-    base::SharedMemory* old_buffer = old_mailbox.shared_memory();
-    const size_t size = old_mailbox.shared_memory_size_in_bytes();
-
-    scoped_ptr<base::SharedMemory> new_buffer(new base::SharedMemory);
-    new_buffer->CreateAndMapAnonymous(size);
-
-    if (old_buffer->memory() && new_buffer->memory()) {
-      memcpy(new_buffer->memory(), old_buffer->memory(), size);
-      base::SharedMemory* new_buffer_raw_ptr = new_buffer.get();
-      scoped_ptr<cc::SingleReleaseCallback> callback =
-          cc::SingleReleaseCallback::Create(base::Bind(MailboxReleaseCallback,
-                                                       Passed(&new_buffer)));
-      cc::TextureMailbox new_mailbox(new_buffer_raw_ptr,
-                                     old_mailbox.shared_memory_size());
-      new_layer->SetTextureMailbox(new_mailbox,
-                                   callback.Pass(),
-                                   mailbox_scale_factor);
-    }
-  } else if (frame_provider_.get()) {
-    new_layer->SetShowDelegatedContent(frame_provider_.get(),
-                                       current_frame_size_);
-  }
+RenderWidgetHostImpl* RenderWidgetHostViewAura::GetHost() {
+  return host_;
 }
 
-////////////////////////////////////////////////////////////////////////////////
-// RenderWidgetHostView, public:
+void RenderWidgetHostViewAura::SchedulePaintInRect(
+    const gfx::Rect& damage_rect_in_dip) {
+  window_->SchedulePaintInRect(damage_rect_in_dip);
+}
 
-// static
-RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
-    RenderWidgetHost* widget) {
-  return new RenderWidgetHostViewAura(widget);
+bool RenderWidgetHostViewAura::IsVisible() {
+  return IsShowing();
 }
 
+gfx::Size RenderWidgetHostViewAura::DesiredFrameSize() {
+  return window_->bounds().size();
+}
+
+float RenderWidgetHostViewAura::CurrentDeviceScaleFactor() {
+  return current_device_scale_factor_;
+}
+
+gfx::Size RenderWidgetHostViewAura::ConvertViewSizeToPixel(
+    const gfx::Size& size) {
+  return content::ConvertViewSizeToPixel(this, size);
+}
+
+scoped_ptr<ResizeLock> RenderWidgetHostViewAura::CreateResizeLock(
+    bool defer_compositor_lock) {
+  gfx::Size desired_size = window_->bounds().size();
+  return scoped_ptr<ResizeLock>(new CompositorResizeLock(
+      window_->GetHost(),
+      desired_size,
+      defer_compositor_lock,
+      base::TimeDelta::FromMilliseconds(kResizeLockTimeoutMs)));
+  ResizeLock* lock = NULL;
+  return scoped_ptr<ResizeLock>(lock);
+}
+
+DelegatedFrameHost* RenderWidgetHostViewAura::GetDelegatedFrameHost() const {
+  return delegated_frame_host_.get();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// RenderWidgetHostViewBase, public:
+
 // static
-void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
+void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
   GetScreenInfoForWindow(results, NULL);
 }