diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-03 05:03:22 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-03 05:03:22 +0000 |
commit | 396c3a461549b02dcb830a287ac4656b2ca181e7 (patch) | |
tree | dfd70c68c3fc4aa501a8f1bf13bf4853d2f7faef /chrome/renderer/render_view.cc | |
parent | 29a694916746e366724f7ac6f9aa0d103894f4a9 (diff) | |
download | chromium_src-396c3a461549b02dcb830a287ac4656b2ca181e7.zip chromium_src-396c3a461549b02dcb830a287ac4656b2ca181e7.tar.gz chromium_src-396c3a461549b02dcb830a287ac4656b2ca181e7.tar.bz2 |
Make the pepper 2D flush callback actually function as advertised. It will now
get called asynchronously when the bits are actually copied to the screen,
rather than synchronously from inside the paint function. This makes it useful
for plugins to use the callback for rate limiting.
This also adds a lot of infrastructure for running tests on pepper devices, and
includes a unit test for the new flush behavior.
I made the existing RenderProcess object an abstract interface and made the
existing MockProcess (renamed to be more clear) implement that. This avoids
a static cast that would actually crash during a unit test because some code
was hardcoded to expect a RenderProcess object.
This fixes base's IDMap iterator which has apparently never been used for an
IDMap with ownership semantics.
TEST=Unit test included
BUG=none
Review URL: http://codereview.chromium.org/661124
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40490 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_view.cc')
-rw-r--r-- | chrome/renderer/render_view.cc | 92 |
1 files changed, 64 insertions, 28 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 892735f..236cf87 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -53,6 +53,7 @@ #include "chrome/renderer/plugin_channel_host.h" #include "chrome/renderer/print_web_view_helper.h" #include "chrome/renderer/render_process.h" +#include "chrome/renderer/render_thread.h" #include "chrome/renderer/renderer_webstoragenamespace_impl.h" #include "chrome/renderer/spellchecker/spellcheck.h" #include "chrome/renderer/user_script_slave.h" @@ -1348,29 +1349,6 @@ void RenderView::OpenURL( // WebViewDelegate ------------------------------------------------------------ -void RenderView::DidPaint() { - WebFrame* main_frame = webview()->mainFrame(); - - if (main_frame->provisionalDataSource()) { - // If we have a provisional frame we are between the start - // and commit stages of loading...ignore this paint. - return; - } - - WebDataSource* ds = main_frame->dataSource(); - NavigationState* navigation_state = NavigationState::FromDataSource(ds); - DCHECK(navigation_state); - - Time now = Time::Now(); - if (navigation_state->first_paint_time().is_null()) { - navigation_state->set_first_paint_time(now); - } - if (navigation_state->first_paint_after_load_time().is_null() && - !navigation_state->finish_load_time().is_null()) { - navigation_state->set_first_paint_after_load_time(now); - } -} - void RenderView::LoadNavigationErrorPage(WebFrame* frame, const WebURLRequest& failed_request, const WebURLError& error, @@ -2984,7 +2962,7 @@ webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( mime_type_to_use = &mime_type; bool use_pepper_host = false; - bool in_process_plugin = RenderProcess::current()->in_process_plugins(); + bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); // Check for trusted Pepper plugins. const char kPepperPrefix[] = "pepper-"; if (StartsWithASCII(*mime_type_to_use, kPepperPrefix, true)) { @@ -3006,10 +2984,10 @@ webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( } if (in_process_plugin) { if (use_pepper_host) { - return WebPluginDelegatePepper::Create( - path, - *mime_type_to_use, - AsWeakPtr()); + WebPluginDelegatePepper* pepper_plugin = + WebPluginDelegatePepper::Create(path, *mime_type_to_use, + AsWeakPtr()); + current_pepper_plugins_.insert(pepper_plugin); } else { #if defined(OS_WIN) // In-proc plugins aren't supported on Linux or Mac. return WebPluginDelegateImpl::Create( @@ -3468,6 +3446,17 @@ void RenderView::InsertCSS(const std::wstring& frame_xpath, web_frame->insertStyleText(WebString::fromUTF8(css), WebString::fromUTF8(id)); } +void RenderView::OnPepperPluginDestroy( + WebPluginDelegatePepper* pepper_plugin) { + std::set<WebPluginDelegatePepper*>::iterator found_pepper = + current_pepper_plugins_.find(pepper_plugin); + if (found_pepper == current_pepper_plugins_.end()) { + NOTREACHED(); + return; + } + current_pepper_plugins_.erase(found_pepper); +} + void RenderView::OnScriptEvalRequest(const std::wstring& frame_xpath, const std::wstring& jscript) { EvaluateScript(frame_xpath, jscript); @@ -3947,6 +3936,53 @@ void RenderView::OnResize(const gfx::Size& new_size, RenderWidget::OnResize(new_size, resizer_rect); } +void RenderView::DidInitiatePaint() { + // Notify any pepper plugins that we started painting. The plugin "should" + // never notified that we started painting, this is used for internal + // bookkeeping only, so we know that the set can not change under us. + for (std::set<WebPluginDelegatePepper*>::iterator i = + current_pepper_plugins_.begin(); + i != current_pepper_plugins_.end(); ++i) + (*i)->RenderViewInitiatedPaint(); +} + +void RenderView::DidFlushPaint() { + // Notify any pepper plugins that we painted. This will call into the plugin, + // and we it may ask to close itself as a result. This will, in turn, modify + // our set, possibly invalidating the iterator. So we iterate on a copy that + // won't change out from under us. + std::set<WebPluginDelegatePepper*> plugins = current_pepper_plugins_; + for (std::set<WebPluginDelegatePepper*>::iterator i = plugins.begin(); + i != plugins.end(); ++i) { + // The copy above makes sure our iterator is never invalid if some plugins + // are destroyed. But some plugin may decide to close all of its views in + // response to a paint in one of them, so we need to make sure each one is + // still "current" before using it. + if (current_pepper_plugins_.find(*i) != current_pepper_plugins_.end()) + (*i)->RenderViewFlushedPaint(); + } + + WebFrame* main_frame = webview()->mainFrame(); + + // If we have a provisional frame we are between the start and commit stages + // of loading and we don't want to save stats. + if (!main_frame->provisionalDataSource()) { + WebDataSource* ds = main_frame->dataSource(); + NavigationState* navigation_state = NavigationState::FromDataSource(ds); + DCHECK(navigation_state); + + Time now = Time::Now(); + if (navigation_state->first_paint_time().is_null()) { + navigation_state->set_first_paint_time(now); + } + if (navigation_state->first_paint_after_load_time().is_null() && + !navigation_state->finish_load_time().is_null()) { + navigation_state->set_first_paint_after_load_time(now); + } + } +} + + void RenderView::OnClearFocusedNode() { if (webview()) webview()->clearFocusedNode(); |