Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8021)

Unified Diff: chrome/renderer/render_view.cc

Issue 6099013: Fix race condition where chrome.tabs.executeScript sometimes wouldn't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/navigation_state.cc ('k') | chrome/renderer/user_script_idle_scheduler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_view.cc
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 64b0812a663f44d56b4f88c80137764d7dff9fc7..89aec82df7ec8959f8a7ea73434fe70b73dfd87a 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -3265,8 +3265,16 @@ void RenderView::didCreateDataSource(WebFrame* frame, WebDataSource* ds) {
}
}
- state->set_user_script_idle_scheduler(
- new UserScriptIdleScheduler(this, frame));
+ // If this datasource already has a UserScriptIdleScheduler, reuse that one.
+ // This is for navigations within a page (didNavigateWithinPage). See
+ // http://code.google.com/p/chromium/issues/detail?id=64093
+ NavigationState* old_state = NavigationState::FromDataSource(ds);
+ if (old_state && old_state->user_script_idle_scheduler()) {
+ state->swap_user_script_idle_scheduler(old_state);
+ } else {
+ state->set_user_script_idle_scheduler(
+ new UserScriptIdleScheduler(this, frame));
+ }
ds->setExtraData(state);
}
@@ -3595,11 +3603,6 @@ void RenderView::didFinishLoad(WebFrame* frame) {
void RenderView::didNavigateWithinPage(
WebFrame* frame, bool is_new_navigation) {
- // Determine if the UserScriptIdleScheduler already ran scripts on this page,
- // since a new one gets created by didCreateDataSource.
- NavigationState* state = NavigationState::FromDataSource(frame->dataSource());
- bool idle_scheduler_ran = state->user_script_idle_scheduler()->has_run();
-
// If this was a reference fragment navigation that we initiated, then we
// could end up having a non-null pending navigation state. We just need to
// update the ExtraData on the datasource so that others who read the
@@ -3613,11 +3616,6 @@ void RenderView::didNavigateWithinPage(
NavigationState::FromDataSource(frame->dataSource());
new_state->set_was_within_same_page(true);
- if (idle_scheduler_ran) {
- // Update the new UserScriptIdleScheduler so we don't re-run scripts.
- new_state->user_script_idle_scheduler()->set_has_run(true);
- }
-
didCommitProvisionalLoad(frame, is_new_navigation);
UpdateTitle(frame, frame->view()->mainFrame()->dataSource()->pageTitle());
« no previous file with comments | « chrome/renderer/navigation_state.cc ('k') | chrome/renderer/user_script_idle_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698