diff options
author | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 07:16:07 +0000 |
---|---|---|
committer | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 07:16:07 +0000 |
commit | 913d99a74271ad98e28c965738fcd9adf98045a2 (patch) | |
tree | 9f954589c2c0d350ca7c24e2f8750bd2e644124a /android_webview/browser | |
parent | 800bb5c6b03972bf78c4ce86fc6f7dee767bf76d (diff) | |
download | chromium_src-913d99a74271ad98e28c965738fcd9adf98045a2.zip chromium_src-913d99a74271ad98e28c965738fcd9adf98045a2.tar.gz chromium_src-913d99a74271ad98e28c965738fcd9adf98045a2.tar.bz2 |
Move synchronous compositor into content/browser
This means all the hookup can remain in content/ so less internal
details need to be revealed in the public API long-term.
Now there is a single API to intialize the sync compositor mode per
process, and per WebContents, rather than a collection of flags and
hooks. The bulk of the browser->renderer hookup is done in content/ so
android_webview InProcessViewRenderer can be greatly simplified.
(depends on pending CL https://codereview.chromium.org/15875009/)
Review URL: https://chromiumcodereview.appspot.com/15851006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203351 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/browser')
-rw-r--r-- | android_webview/browser/aw_devtools_delegate.cc | 2 | ||||
-rw-r--r-- | android_webview/browser/browser_view_renderer_impl.cc | 2 | ||||
-rw-r--r-- | android_webview/browser/in_process_renderer/DEPS | 8 | ||||
-rw-r--r-- | android_webview/browser/in_process_renderer/in_process_renderer_client.cc | 56 | ||||
-rw-r--r-- | android_webview/browser/in_process_renderer/in_process_renderer_client.h | 27 | ||||
-rw-r--r-- | android_webview/browser/in_process_view_renderer.cc (renamed from android_webview/browser/in_process_renderer/in_process_view_renderer.cc) | 56 | ||||
-rw-r--r-- | android_webview/browser/in_process_view_renderer.h (renamed from android_webview/browser/in_process_renderer/in_process_view_renderer.h) | 10 |
7 files changed, 29 insertions, 132 deletions
diff --git a/android_webview/browser/aw_devtools_delegate.cc b/android_webview/browser/aw_devtools_delegate.cc index 54fd7806..7d367b4 100644 --- a/android_webview/browser/aw_devtools_delegate.cc +++ b/android_webview/browser/aw_devtools_delegate.cc @@ -5,7 +5,7 @@ #include "android_webview/browser/aw_devtools_delegate.h" #include "android_webview/browser/browser_view_renderer_impl.h" -#include "android_webview/browser/in_process_renderer/in_process_view_renderer.h" +#include "android_webview/browser/in_process_view_renderer.h" #include "android_webview/common/aw_switches.h" #include "base/bind.h" #include "base/command_line.h" diff --git a/android_webview/browser/browser_view_renderer_impl.cc b/android_webview/browser/browser_view_renderer_impl.cc index 72aaf39..9f790be 100644 --- a/android_webview/browser/browser_view_renderer_impl.cc +++ b/android_webview/browser/browser_view_renderer_impl.cc @@ -6,7 +6,7 @@ #include <android/bitmap.h> -#include "android_webview/browser/in_process_renderer/in_process_view_renderer.h" +#include "android_webview/browser/in_process_view_renderer.h" #include "android_webview/common/aw_switches.h" #include "android_webview/common/renderer_picture_map.h" #include "android_webview/public/browser/draw_gl.h" diff --git a/android_webview/browser/in_process_renderer/DEPS b/android_webview/browser/in_process_renderer/DEPS deleted file mode 100644 index 51ebf0f..0000000 --- a/android_webview/browser/in_process_renderer/DEPS +++ /dev/null @@ -1,8 +0,0 @@ -include_rules = [ - # In order to meet synchronous renderer requirements we need to make direct - # calls from android_webview/browser/in_process into some APIs that logically - # live in the renderer side. - "+android_webview/renderer/aw_content_renderer_client.h", - "+content/public/renderer/android", - # Include joth@chromium.org on the review for any additions to this file. -] diff --git a/android_webview/browser/in_process_renderer/in_process_renderer_client.cc b/android_webview/browser/in_process_renderer/in_process_renderer_client.cc deleted file mode 100644 index 20392ab..0000000 --- a/android_webview/browser/in_process_renderer/in_process_renderer_client.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2012 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 "android_webview/browser/in_process_renderer/in_process_renderer_client.h" - -#include "android_webview/browser/in_process_renderer/in_process_view_renderer.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/render_process_host.h" - -namespace android_webview { - -namespace { - -int GetInProcessRendererId() { - content::RenderProcessHost::iterator it = - content::RenderProcessHost::AllHostsIterator(); - if (it.IsAtEnd()) { - // There should always be one RPH in single process more. - NOTREACHED(); - return 0; - } - - int id = it.GetCurrentValue()->GetID(); - it.Advance(); - DCHECK(it.IsAtEnd()); // Not multiprocess compatible. - return id; -} - -} - -base::MessageLoop* InProcessRendererClient::OverrideCompositorMessageLoop() - const { - base::MessageLoop* rv = content::BrowserThread::UnsafeGetMessageLoopForThread( - content::BrowserThread::UI); - DCHECK(rv); - return rv; -} - -void InProcessRendererClient::DidCreateSynchronousCompositor( - int render_view_id, - content::SynchronousCompositor* compositor) { - InProcessViewRenderer* view_renderer = - InProcessViewRenderer::FromId(GetInProcessRendererId(), render_view_id); - if (view_renderer) - view_renderer->BindSynchronousCompositor(compositor); -} - -bool InProcessRendererClient::ShouldCreateCompositorInputHandler() const { - // Compositor input handling will be performed by the renderer host - // when UI and compositor threads are merged, so we disable client compositor - // input handling in this case. - return false; -} - -} // namespace android_webview diff --git a/android_webview/browser/in_process_renderer/in_process_renderer_client.h b/android_webview/browser/in_process_renderer/in_process_renderer_client.h deleted file mode 100644 index 3c597d5..0000000 --- a/android_webview/browser/in_process_renderer/in_process_renderer_client.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2013 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 ANDROID_WEBVIEW_COMMON_IN_PROCESS_RENDERER_CLIENT_ -#define ANDROID_WEBVIEW_COMMON_IN_PROCESS_RENDERER_CLIENT_ - -#include "android_webview/renderer/aw_content_renderer_client.h" - -namespace android_webview { - -// Specialization of the Renderer client used in single process mode, to -// route various factory-like methods to browser/ side code (in general, -// this is only needed / allowed in order to meet synchronous rendering -// requirements). -class InProcessRendererClient : public AwContentRendererClient { - public: - virtual base::MessageLoop* OverrideCompositorMessageLoop() const OVERRIDE; - virtual void DidCreateSynchronousCompositor( - int render_view_id, - content::SynchronousCompositor* compositor) OVERRIDE; - virtual bool ShouldCreateCompositorInputHandler() const OVERRIDE; -}; - -} // android_webview - -#endif // ANDROID_WEBVIEW_COMMON_IN_PROCESS_RENDERER_CLIENT_ diff --git a/android_webview/browser/in_process_renderer/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc index 553835c..73b8685 100644 --- a/android_webview/browser/in_process_renderer/in_process_view_renderer.cc +++ b/android_webview/browser/in_process_view_renderer.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Copyright 2013 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 "android_webview/browser/in_process_renderer/in_process_view_renderer.h" +#include "android_webview/browser/in_process_view_renderer.h" #include <android/bitmap.h> @@ -12,9 +12,9 @@ #include "base/debug/trace_event.h" #include "base/logging.h" #include "content/public/browser/android/content_view_core.h" +#include "content/public/browser/android/synchronous_compositor.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" -#include "content/public/renderer/android/synchronous_compositor.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkDevice.h" @@ -278,9 +278,8 @@ InProcessViewRenderer::InProcessViewRenderer( } InProcessViewRenderer::~InProcessViewRenderer() { - if (compositor_) - compositor_->SetClient(NULL); SetContents(NULL); + DCHECK(compositor_ == NULL); } // static @@ -289,34 +288,12 @@ InProcessViewRenderer* InProcessViewRenderer::FromWebContents( return UserData::GetInstance(contents); } -// static -InProcessViewRenderer* InProcessViewRenderer::FromId(int render_process_id, - int render_view_id) { - const content::RenderViewHost* rvh = - content::RenderViewHost::FromID(render_process_id, render_view_id); - if (!rvh) return NULL; - return InProcessViewRenderer::FromWebContents( - content::WebContents::FromRenderViewHost(rvh)); -} - -void InProcessViewRenderer::BindSynchronousCompositor( - content::SynchronousCompositor* compositor) { - DCHECK(compositor && compositor_ != compositor); - if (compositor_) - compositor_->SetClient(NULL); - compositor_ = compositor; - hardware_initialized_ = false; - hardware_failed_ = false; - compositor_->SetClient(this); - - if (attached_to_window_) - client_->RequestProcessMode(); -} - void InProcessViewRenderer::SetContents( content::ContentViewCore* content_view_core) { // First remove association from the prior ContentViewCore / WebContents. if (web_contents_) { + content::SynchronousCompositor::SetClientForWebContents(web_contents_, + NULL); web_contents_->SetUserData(kUserDataKey, NULL); DCHECK(!web_contents_); // WebContentsGone should have been called. } @@ -326,10 +303,14 @@ void InProcessViewRenderer::SetContents( web_contents_ = content_view_core->GetWebContents(); web_contents_->SetUserData(kUserDataKey, new UserData(this)); + content::SynchronousCompositor::SetClientForWebContents(web_contents_, this); + // Currently the logic in this class relies on |compositor_| remaining NULL + // until the DidInitializeCompositor() call, hence it is not set here. } void InProcessViewRenderer::WebContentsGone() { web_contents_ = NULL; + compositor_ = NULL; } bool InProcessViewRenderer::PrepareDrawGL(int x, int y) { @@ -549,12 +530,21 @@ gfx::Rect InProcessViewRenderer::GetScreenRect() { return gfx::Rect(client_->GetLocationOnScreen(), gfx::Size(width_, height_)); } +void InProcessViewRenderer::DidInitializeCompositor( + content::SynchronousCompositor* compositor) { + DCHECK(compositor && compositor_ == NULL); + compositor_ = compositor; + hardware_initialized_ = false; + hardware_failed_ = false; + + if (attached_to_window_) + client_->RequestProcessMode(); +} + void InProcessViewRenderer::DidDestroyCompositor( content::SynchronousCompositor* compositor) { - // Allow for transient hand-over when two compositors may reference - // a single client. - if (compositor_ == compositor) - compositor_ = NULL; + DCHECK(compositor_ == compositor); + compositor_ = NULL; } void InProcessViewRenderer::SetContinuousInvalidate(bool invalidate) { diff --git a/android_webview/browser/in_process_renderer/in_process_view_renderer.h b/android_webview/browser/in_process_view_renderer.h index 5aa3b4a..4175dd1 100644 --- a/android_webview/browser/in_process_renderer/in_process_view_renderer.h +++ b/android_webview/browser/in_process_view_renderer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Copyright 2013 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. @@ -8,7 +8,7 @@ #include "android_webview/browser/browser_view_renderer_impl.h" #include "base/memory/weak_ptr.h" -#include "content/public/renderer/android/synchronous_compositor_client.h" +#include "content/public/browser/android/synchronous_compositor_client.h" namespace content { class SynchronousCompositor; @@ -28,10 +28,6 @@ class InProcessViewRenderer : public BrowserViewRenderer, static InProcessViewRenderer* FromWebContents( content::WebContents* contents); - static InProcessViewRenderer* FromId( - int render_process_id, int render_view_id); - void BindSynchronousCompositor( - content::SynchronousCompositor* compositor); // BrowserViewRenderer overrides virtual void SetContents( @@ -52,6 +48,8 @@ class InProcessViewRenderer : public BrowserViewRenderer, virtual gfx::Rect GetScreenRect() OVERRIDE; // SynchronousCompositorClient overrides + virtual void DidInitializeCompositor( + content::SynchronousCompositor* compositor) OVERRIDE; virtual void DidDestroyCompositor( content::SynchronousCompositor* compositor) OVERRIDE; virtual void SetContinuousInvalidate(bool invalidate) OVERRIDE; |