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

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: charlie's fixes 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
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 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 // This ensures we are in a unique origin that others cannot script. 837 // This ensures we are in a unique origin that others cannot script.
838 if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame()) 838 if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame())
839 main_render_frame_->NavigateToSwappedOutURL(); 839 main_render_frame_->NavigateToSwappedOutURL();
840 } 840 }
841 841
842 RenderViewImpl::~RenderViewImpl() { 842 RenderViewImpl::~RenderViewImpl() {
843 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); 843 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin();
844 it != disambiguation_bitmaps_.end(); 844 it != disambiguation_bitmaps_.end();
845 ++it) 845 ++it)
846 delete it->second; 846 delete it->second;
847 history_page_ids_.clear();
848
849 base::debug::TraceLog::GetInstance()->RemoveProcessLabel(routing_id_); 847 base::debug::TraceLog::GetInstance()->RemoveProcessLabel(routing_id_);
850 848
851 // If file chooser is still waiting for answer, dispatch empty answer. 849 // If file chooser is still waiting for answer, dispatch empty answer.
852 while (!file_chooser_completions_.empty()) { 850 while (!file_chooser_completions_.empty()) {
853 if (file_chooser_completions_.front()->completion) { 851 if (file_chooser_completions_.front()->completion) {
854 file_chooser_completions_.front()->completion->didChooseFile( 852 file_chooser_completions_.front()->completion->didChooseFile(
855 WebVector<WebString>()); 853 WebVector<WebString>());
856 } 854 }
857 file_chooser_completions_.pop_front(); 855 file_chooser_completions_.pop_front();
858 } 856 }
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) 1336 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt)
1339 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) 1337 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt)
1340 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) 1338 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive)
1341 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, 1339 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
1342 OnGetAllSavableResourceLinksForCurrentPage) 1340 OnGetAllSavableResourceLinksForCurrentPage)
1343 IPC_MESSAGE_HANDLER( 1341 IPC_MESSAGE_HANDLER(
1344 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, 1342 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
1345 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) 1343 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
1346 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) 1344 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu)
1347 // TODO(viettrungluu): Move to a separate message filter. 1345 // TODO(viettrungluu): Move to a separate message filter.
1348 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, 1346 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryOffsetAndLength,
1349 OnSetHistoryLengthAndPrune) 1347 OnSetHistoryOffsetAndLength)
1350 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 1348 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
1351 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, 1349 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1352 OnReleaseDisambiguationPopupBitmap) 1350 OnReleaseDisambiguationPopupBitmap)
1353 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, 1351 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted,
1354 OnWindowSnapshotCompleted) 1352 OnWindowSnapshotCompleted)
1355 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) 1353 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
1356 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) 1354 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
1357 #if defined(OS_ANDROID) 1355 #if defined(OS_ANDROID)
1358 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, 1356 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult,
1359 OnActivateNearestFindResult) 1357 OnActivateNearestFindResult)
(...skipping 22 matching lines...) Expand all
1382 1380
1383 void RenderViewImpl::OnSelectWordAroundCaret() { 1381 void RenderViewImpl::OnSelectWordAroundCaret() {
1384 if (!webview()) 1382 if (!webview())
1385 return; 1383 return;
1386 1384
1387 handling_input_event_ = true; 1385 handling_input_event_ = true;
1388 webview()->focusedFrame()->selectWordAroundCaret(); 1386 webview()->focusedFrame()->selectWordAroundCaret();
1389 handling_input_event_ = false; 1387 handling_input_event_ = false;
1390 } 1388 }
1391 1389
1392 bool RenderViewImpl::IsBackForwardToStaleEntry(const PageState& state,
1393 int pending_history_list_offset,
1394 int32 page_id,
1395 bool is_reload) {
1396 // Make sure this isn't a back/forward to an entry we have already cropped
1397 // or replaced from our history, before the browser knew about it. If so,
1398 // a new navigation has committed in the mean time, and we can ignore this.
1399 bool is_back_forward = !is_reload && state.IsValid();
1400
1401 // Note: if the history_list_length_ is 0 for a back/forward, we must be
1402 // restoring from a previous session. We'll update our state in OnNavigate.
1403 if (!is_back_forward || history_list_length_ <= 0)
1404 return false;
1405
1406 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_);
1407
1408 // Check for whether the forward history has been cropped due to a recent
1409 // navigation the browser didn't know about.
1410 if (pending_history_list_offset >= history_list_length_)
1411 return true;
1412
1413 // Check for whether this entry has been replaced with a new one.
1414 int expected_page_id =
1415 history_page_ids_[pending_history_list_offset];
1416 if (expected_page_id > 0 && page_id != expected_page_id) {
1417 if (page_id < expected_page_id)
1418 return true;
1419
1420 // Otherwise we've removed an earlier entry and should have shifted all
1421 // entries left. For now, it's ok to lazily update the list.
1422 // TODO(creis): Notify all live renderers when we remove entries from
1423 // the front of the list, so that we don't hit this case.
1424 history_page_ids_[pending_history_list_offset] = page_id;
1425 }
1426
1427 return false;
1428 }
1429
1430 void RenderViewImpl::OnCopyImageAt(int x, int y) { 1390 void RenderViewImpl::OnCopyImageAt(int x, int y) {
1431 webview()->copyImageAt(WebPoint(x, y)); 1391 webview()->copyImageAt(WebPoint(x, y));
1432 } 1392 }
1433 1393
1434 void RenderViewImpl::OnSaveImageAt(int x, int y) { 1394 void RenderViewImpl::OnSaveImageAt(int x, int y) {
1435 webview()->saveImageAt(WebPoint(x, y)); 1395 webview()->saveImageAt(WebPoint(x, y));
1436 } 1396 }
1437 1397
1438 void RenderViewImpl::OnUpdateTargetURLAck() { 1398 void RenderViewImpl::OnUpdateTargetURLAck() {
1439 // Check if there is a targeturl waiting to be sent. 1399 // Check if there is a targeturl waiting to be sent.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 has_scrolled_focused_editable_node_into_rect_ = true; 1434 has_scrolled_focused_editable_node_into_rect_ = true;
1475 webview()->scrollFocusedNodeIntoRect(rect); 1435 webview()->scrollFocusedNodeIntoRect(rect);
1476 } 1436 }
1477 } 1437 }
1478 1438
1479 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( 1439 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent(
1480 const EditCommands& edit_commands) { 1440 const EditCommands& edit_commands) {
1481 edit_commands_ = edit_commands; 1441 edit_commands_ = edit_commands;
1482 } 1442 }
1483 1443
1484 void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, 1444 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset,
1485 int32 minimum_page_id) { 1445 int history_length) {
1446 DCHECK_GE(history_offset, -1);
1486 DCHECK_GE(history_length, 0); 1447 DCHECK_GE(history_length, 0);
1487 DCHECK(history_list_offset_ == history_list_length_ - 1);
1488 DCHECK_GE(minimum_page_id, -1);
1489 1448
1490 // Generate the new list. 1449 history_list_offset_ = history_offset;
1491 std::vector<int32> new_history_page_ids(history_length, -1); 1450 history_list_length_ = history_length;
1492 for (size_t i = 0; i < history_page_ids_.size(); ++i) {
1493 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id)
1494 continue;
1495 new_history_page_ids.push_back(history_page_ids_[i]);
1496 }
1497 new_history_page_ids.swap(history_page_ids_);
1498
1499 // Update indexes.
1500 history_list_length_ = history_page_ids_.size();
1501 history_list_offset_ = history_list_length_ - 1;
1502 } 1451 }
1503 1452
1504
1505 void RenderViewImpl::OnSetInitialFocus(bool reverse) { 1453 void RenderViewImpl::OnSetInitialFocus(bool reverse) {
1506 if (!webview()) 1454 if (!webview())
1507 return; 1455 return;
1508 webview()->setInitialFocus(reverse); 1456 webview()->setInitialFocus(reverse);
1509 } 1457 }
1510 1458
1511 #if defined(OS_MACOSX) 1459 #if defined(OS_MACOSX)
1512 void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) { 1460 void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) {
1513 if (!webview()) 1461 if (!webview())
1514 return; 1462 return;
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after
4199 std::vector<gfx::Size> sizes; 4147 std::vector<gfx::Size> sizes;
4200 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4148 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4201 if (!url.isEmpty()) 4149 if (!url.isEmpty())
4202 urls.push_back( 4150 urls.push_back(
4203 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4151 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4204 } 4152 }
4205 SendUpdateFaviconURL(urls); 4153 SendUpdateFaviconURL(urls);
4206 } 4154 }
4207 4155
4208 } // namespace content 4156 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698