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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 1449353002: OOPIF: Set timer for per-frame UpdateState. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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 unified diff | Download patch
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 return; 1477 return;
1478 1478
1479 // Don't send state updates for kSwappedOutURL. 1479 // Don't send state updates for kSwappedOutURL.
1480 if (entry->root().urlString() == WebString::fromUTF8(kSwappedOutURL)) 1480 if (entry->root().urlString() == WebString::fromUTF8(kSwappedOutURL))
1481 return; 1481 return;
1482 1482
1483 Send(new ViewHostMsg_UpdateState( 1483 Send(new ViewHostMsg_UpdateState(
1484 routing_id_, page_id_, HistoryEntryToPageState(entry))); 1484 routing_id_, page_id_, HistoryEntryToPageState(entry)));
1485 } 1485 }
1486 1486
1487 void RenderViewImpl::SendFrameStateUpdates() {
1488 // We only use this path in OOPIF-enabled modes.
1489 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries());
1490
1491 // Tell each frame with pending state to send its UpdateState message.
1492 for (int render_frame_routing_id : frames_with_pending_state_) {
1493 RenderFrameImpl* frame =
1494 RenderFrameImpl::FromRoutingID(render_frame_routing_id);
1495 if (frame)
1496 frame->SendUpdateState();
1497 }
1498 frames_with_pending_state_.clear();
1499 }
1500
1487 void RenderViewImpl::ApplyWebPreferencesInternal( 1501 void RenderViewImpl::ApplyWebPreferencesInternal(
1488 const WebPreferences& prefs, 1502 const WebPreferences& prefs,
1489 blink::WebView* web_view, 1503 blink::WebView* web_view,
1490 CompositorDependencies* compositor_deps) { 1504 CompositorDependencies* compositor_deps) {
1491 ApplyWebPreferences(prefs, web_view); 1505 ApplyWebPreferences(prefs, web_view);
1492 #if defined(OS_MACOSX) && !defined(OS_IOS) 1506 #if defined(OS_MACOSX) && !defined(OS_IOS)
1493 DCHECK(compositor_deps); 1507 DCHECK(compositor_deps);
1494 bool is_elastic_overscroll_enabled = 1508 bool is_elastic_overscroll_enabled =
1495 compositor_deps->IsElasticOverscrollEnabled(); 1509 compositor_deps->IsElasticOverscrollEnabled();
1496 web_view->settings()->setReportWheelOverscroll(is_elastic_overscroll_enabled); 1510 web_view->settings()->setReportWheelOverscroll(is_elastic_overscroll_enabled);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 } 1855 }
1842 } 1856 }
1843 1857
1844 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( 1858 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect(
1845 const gfx::RectF& rect) const { 1859 const gfx::RectF& rect) const {
1846 gfx::RectF window_rect = rect; 1860 gfx::RectF window_rect = rect;
1847 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); 1861 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor());
1848 return window_rect; 1862 return window_rect;
1849 } 1863 }
1850 1864
1851 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { 1865 void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) {
1852 // TODO(creis): Move this to RenderFrameHost. In the meantime, we'll ignore 1866 // In OOPIF modes, keep track of which frames have pending updates.
1853 // state changes between navigation events in OOPIF-enabled modes.
1854 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 1867 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
1855 return; 1868 frames_with_pending_state_.insert(frame->GetRoutingID());
1856 1869
1857 int delay; 1870 int delay;
1858 if (send_content_state_immediately_) 1871 if (send_content_state_immediately_)
1859 delay = 0; 1872 delay = 0;
1860 else if (is_hidden()) 1873 else if (is_hidden())
1861 delay = kDelaySecondsForContentStateSyncHidden; 1874 delay = kDelaySecondsForContentStateSyncHidden;
1862 else 1875 else
1863 delay = kDelaySecondsForContentStateSync; 1876 delay = kDelaySecondsForContentStateSync;
1864 1877
1865 if (nav_state_sync_timer_.IsRunning()) { 1878 if (nav_state_sync_timer_.IsRunning()) {
1866 // The timer is already running. If the delay of the timer maches the amount 1879 // The timer is already running. If the delay of the timer maches the amount
1867 // we want to delay by, then return. Otherwise stop the timer so that it 1880 // we want to delay by, then return. Otherwise stop the timer so that it
1868 // gets started with the right delay. 1881 // gets started with the right delay.
1869 if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) 1882 if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay)
1870 return; 1883 return;
1871 nav_state_sync_timer_.Stop(); 1884 nav_state_sync_timer_.Stop();
1872 } 1885 }
1873 1886
1874 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, 1887 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1875 &RenderViewImpl::SendUpdateState); 1888 // In OOPIF modes, tell each frame with pending state to inform the browser.
1889 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this,
1890 &RenderViewImpl::SendFrameStateUpdates);
1891 } else {
1892 // By default, send an UpdateState for the current history item.
1893 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this,
1894 &RenderViewImpl::SendUpdateState);
1895 }
1876 } 1896 }
1877 1897
1878 void RenderViewImpl::setMouseOverURL(const WebURL& url) { 1898 void RenderViewImpl::setMouseOverURL(const WebURL& url) {
1879 mouse_over_url_ = GURL(url); 1899 mouse_over_url_ = GURL(url);
1880 UpdateTargetURL(mouse_over_url_, focus_url_); 1900 UpdateTargetURL(mouse_over_url_, focus_url_);
1881 } 1901 }
1882 1902
1883 void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { 1903 void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) {
1884 focus_url_ = GURL(url); 1904 focus_url_ = GURL(url);
1885 UpdateTargetURL(focus_url_, mouse_over_url_); 1905 UpdateTargetURL(focus_url_, mouse_over_url_);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 std::vector<FaviconURL> urls; 2146 std::vector<FaviconURL> urls;
2127 for (size_t i = 0; i < icon_urls.size(); i++) { 2147 for (size_t i = 0; i < icon_urls.size(); i++) {
2128 std::vector<gfx::Size> sizes; 2148 std::vector<gfx::Size> sizes;
2129 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 2149 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
2130 urls.push_back(FaviconURL( 2150 urls.push_back(FaviconURL(
2131 icon_urls[i].iconURL(), ToFaviconType(icon_urls[i].iconType()), sizes)); 2151 icon_urls[i].iconURL(), ToFaviconType(icon_urls[i].iconType()), sizes));
2132 } 2152 }
2133 SendUpdateFaviconURL(urls); 2153 SendUpdateFaviconURL(urls);
2134 } 2154 }
2135 2155
2136 void RenderViewImpl::didUpdateCurrentHistoryItem(WebLocalFrame* frame) {
2137 StartNavStateSyncTimerIfNecessary();
2138 }
2139
2140 void RenderViewImpl::CheckPreferredSize() { 2156 void RenderViewImpl::CheckPreferredSize() {
2141 // We don't always want to send the change messages over IPC, only if we've 2157 // We don't always want to send the change messages over IPC, only if we've
2142 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| 2158 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
2143 // message. 2159 // message.
2144 if (!send_preferred_size_changes_ || !webview()) 2160 if (!send_preferred_size_changes_ || !webview())
2145 return; 2161 return;
2146 2162
2147 gfx::Size size = webview()->contentsPreferredMinimumSize(); 2163 gfx::Size size = webview()->contentsPreferredMinimumSize();
2148 if (size == preferred_size_) 2164 if (size == preferred_size_)
2149 return; 2165 return;
2150 2166
2151 preferred_size_ = size; 2167 preferred_size_ = size;
2152 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, 2168 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_,
2153 preferred_size_)); 2169 preferred_size_));
2154 } 2170 }
2155 2171
2156 void RenderViewImpl::didChangeScrollOffset(WebLocalFrame* frame) {
2157 StartNavStateSyncTimerIfNecessary();
2158 }
2159
2160 void RenderViewImpl::SendFindReply(int request_id, 2172 void RenderViewImpl::SendFindReply(int request_id,
2161 int match_count, 2173 int match_count,
2162 int ordinal, 2174 int ordinal,
2163 const WebRect& selection_rect, 2175 const WebRect& selection_rect,
2164 bool final_status_update) { 2176 bool final_status_update) {
2165 Send(new ViewHostMsg_Find_Reply(routing_id_, 2177 Send(new ViewHostMsg_Find_Reply(routing_id_,
2166 request_id, 2178 request_id,
2167 match_count, 2179 match_count,
2168 selection_rect, 2180 selection_rect,
2169 ordinal, 2181 ordinal,
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
3709 if (IsUseZoomForDSFEnabled()) { 3721 if (IsUseZoomForDSFEnabled()) {
3710 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_); 3722 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_);
3711 webview()->setZoomFactorForDeviceScaleFactor( 3723 webview()->setZoomFactorForDeviceScaleFactor(
3712 device_scale_factor_); 3724 device_scale_factor_);
3713 } else { 3725 } else {
3714 webview()->setDeviceScaleFactor(device_scale_factor_); 3726 webview()->setDeviceScaleFactor(device_scale_factor_);
3715 } 3727 }
3716 } 3728 }
3717 3729
3718 } // namespace content 3730 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698