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

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

Issue 743803002: Avoid stale navigation requests without excessive page id knowledge in the renderer process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 6 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') | content/test/test_web_contents.h » ('j') | 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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 // This ensures we are in a unique origin that others cannot script. 841 // This ensures we are in a unique origin that others cannot script.
842 if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame()) 842 if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame())
843 main_render_frame_->NavigateToSwappedOutURL(); 843 main_render_frame_->NavigateToSwappedOutURL();
844 } 844 }
845 845
846 RenderViewImpl::~RenderViewImpl() { 846 RenderViewImpl::~RenderViewImpl() {
847 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); 847 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin();
848 it != disambiguation_bitmaps_.end(); 848 it != disambiguation_bitmaps_.end();
849 ++it) 849 ++it)
850 delete it->second; 850 delete it->second;
851 history_page_ids_.clear();
852
853 base::debug::TraceLog::GetInstance()->RemoveProcessLabel(routing_id_); 851 base::debug::TraceLog::GetInstance()->RemoveProcessLabel(routing_id_);
854 852
855 // If file chooser is still waiting for answer, dispatch empty answer. 853 // If file chooser is still waiting for answer, dispatch empty answer.
856 while (!file_chooser_completions_.empty()) { 854 while (!file_chooser_completions_.empty()) {
857 if (file_chooser_completions_.front()->completion) { 855 if (file_chooser_completions_.front()->completion) {
858 file_chooser_completions_.front()->completion->didChooseFile( 856 file_chooser_completions_.front()->completion->didChooseFile(
859 WebVector<WebString>()); 857 WebVector<WebString>());
860 } 858 }
861 file_chooser_completions_.pop_front(); 859 file_chooser_completions_.pop_front();
862 } 860 }
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) 1346 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt)
1349 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) 1347 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt)
1350 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) 1348 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive)
1351 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, 1349 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
1352 OnGetAllSavableResourceLinksForCurrentPage) 1350 OnGetAllSavableResourceLinksForCurrentPage)
1353 IPC_MESSAGE_HANDLER( 1351 IPC_MESSAGE_HANDLER(
1354 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, 1352 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
1355 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) 1353 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
1356 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) 1354 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu)
1357 // TODO(viettrungluu): Move to a separate message filter. 1355 // TODO(viettrungluu): Move to a separate message filter.
1358 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, 1356 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryOffsetAndLength,
1359 OnSetHistoryLengthAndPrune) 1357 OnSetHistoryOffsetAndLength)
1360 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 1358 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
1361 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, 1359 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1362 OnReleaseDisambiguationPopupBitmap) 1360 OnReleaseDisambiguationPopupBitmap)
1363 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, 1361 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted,
1364 OnWindowSnapshotCompleted) 1362 OnWindowSnapshotCompleted)
1365 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) 1363 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
1366 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) 1364 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
1367 #if defined(OS_ANDROID) 1365 #if defined(OS_ANDROID)
1368 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, 1366 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult,
1369 OnActivateNearestFindResult) 1367 OnActivateNearestFindResult)
(...skipping 22 matching lines...) Expand all
1392 1390
1393 void RenderViewImpl::OnSelectWordAroundCaret() { 1391 void RenderViewImpl::OnSelectWordAroundCaret() {
1394 if (!webview()) 1392 if (!webview())
1395 return; 1393 return;
1396 1394
1397 handling_input_event_ = true; 1395 handling_input_event_ = true;
1398 webview()->focusedFrame()->selectWordAroundCaret(); 1396 webview()->focusedFrame()->selectWordAroundCaret();
1399 handling_input_event_ = false; 1397 handling_input_event_ = false;
1400 } 1398 }
1401 1399
1402 bool RenderViewImpl::IsBackForwardToStaleEntry(const PageState& state,
1403 int pending_history_list_offset,
1404 int32 page_id,
1405 bool is_reload) {
1406 // Make sure this isn't a back/forward to an entry we have already cropped
1407 // or replaced from our history, before the browser knew about it. If so,
1408 // a new navigation has committed in the mean time, and we can ignore this.
1409 bool is_back_forward = !is_reload && state.IsValid();
1410
1411 // Note: if the history_list_length_ is 0 for a back/forward, we must be
1412 // restoring from a previous session. We'll update our state in OnNavigate.
1413 if (!is_back_forward || history_list_length_ <= 0)
1414 return false;
1415
1416 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_);
1417
1418 // Check for whether the forward history has been cropped due to a recent
1419 // navigation the browser didn't know about.
1420 if (pending_history_list_offset >= history_list_length_)
1421 return true;
1422
1423 // Check for whether this entry has been replaced with a new one.
1424 int expected_page_id =
1425 history_page_ids_[pending_history_list_offset];
1426 if (expected_page_id > 0 && page_id != expected_page_id) {
1427 if (page_id < expected_page_id)
1428 return true;
1429
1430 // Otherwise we've removed an earlier entry and should have shifted all
1431 // entries left. For now, it's ok to lazily update the list.
1432 // TODO(creis): Notify all live renderers when we remove entries from
1433 // the front of the list, so that we don't hit this case.
1434 history_page_ids_[pending_history_list_offset] = page_id;
1435 }
1436
1437 return false;
1438 }
1439
1440 void RenderViewImpl::OnCopyImageAt(int x, int y) { 1400 void RenderViewImpl::OnCopyImageAt(int x, int y) {
1441 webview()->copyImageAt(WebPoint(x, y)); 1401 webview()->copyImageAt(WebPoint(x, y));
1442 } 1402 }
1443 1403
1444 void RenderViewImpl::OnSaveImageAt(int x, int y) { 1404 void RenderViewImpl::OnSaveImageAt(int x, int y) {
1445 webview()->saveImageAt(WebPoint(x, y)); 1405 webview()->saveImageAt(WebPoint(x, y));
1446 } 1406 }
1447 1407
1448 void RenderViewImpl::OnUpdateTargetURLAck() { 1408 void RenderViewImpl::OnUpdateTargetURLAck() {
1449 // Check if there is a targeturl waiting to be sent. 1409 // Check if there is a targeturl waiting to be sent.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 has_scrolled_focused_editable_node_into_rect_ = true; 1444 has_scrolled_focused_editable_node_into_rect_ = true;
1485 webview()->scrollFocusedNodeIntoRect(rect); 1445 webview()->scrollFocusedNodeIntoRect(rect);
1486 } 1446 }
1487 } 1447 }
1488 1448
1489 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( 1449 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent(
1490 const EditCommands& edit_commands) { 1450 const EditCommands& edit_commands) {
1491 edit_commands_ = edit_commands; 1451 edit_commands_ = edit_commands;
1492 } 1452 }
1493 1453
1494 void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, 1454 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset,
1495 int32 minimum_page_id) { 1455 int history_length) {
1456 DCHECK_GE(history_offset, -1);
1496 DCHECK_GE(history_length, 0); 1457 DCHECK_GE(history_length, 0);
1497 DCHECK(history_list_offset_ == history_list_length_ - 1);
1498 DCHECK_GE(minimum_page_id, -1);
1499 1458
1500 // Generate the new list. 1459 history_list_offset_ = history_offset;
1501 std::vector<int32> new_history_page_ids(history_length, -1); 1460 history_list_length_ = history_length;
1502 for (size_t i = 0; i < history_page_ids_.size(); ++i) {
1503 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id)
1504 continue;
1505 new_history_page_ids.push_back(history_page_ids_[i]);
1506 }
1507 new_history_page_ids.swap(history_page_ids_);
1508
1509 // Update indexes.
1510 history_list_length_ = history_page_ids_.size();
1511 history_list_offset_ = history_list_length_ - 1;
1512 } 1461 }
1513 1462
1514
1515 void RenderViewImpl::OnSetInitialFocus(bool reverse) { 1463 void RenderViewImpl::OnSetInitialFocus(bool reverse) {
1516 if (!webview()) 1464 if (!webview())
1517 return; 1465 return;
1518 webview()->setInitialFocus(reverse); 1466 webview()->setInitialFocus(reverse);
1519 } 1467 }
1520 1468
1521 #if defined(OS_MACOSX) 1469 #if defined(OS_MACOSX)
1522 void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) { 1470 void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) {
1523 if (!webview()) 1471 if (!webview())
1524 return; 1472 return;
(...skipping 2683 matching lines...) Expand 10 before | Expand all | Expand 10 after
4208 std::vector<gfx::Size> sizes; 4156 std::vector<gfx::Size> sizes;
4209 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4157 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4210 if (!url.isEmpty()) 4158 if (!url.isEmpty())
4211 urls.push_back( 4159 urls.push_back(
4212 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4160 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4213 } 4161 }
4214 SendUpdateFaviconURL(urls); 4162 SendUpdateFaviconURL(urls);
4215 } 4163 }
4216 4164
4217 } // namespace content 4165 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/test/test_web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698