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

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: more saving 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) 1335 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt)
1338 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) 1336 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt)
1339 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) 1337 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive)
1340 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, 1338 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
1341 OnGetAllSavableResourceLinksForCurrentPage) 1339 OnGetAllSavableResourceLinksForCurrentPage)
1342 IPC_MESSAGE_HANDLER( 1340 IPC_MESSAGE_HANDLER(
1343 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, 1341 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
1344 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) 1342 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
1345 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) 1343 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu)
1346 // TODO(viettrungluu): Move to a separate message filter. 1344 // TODO(viettrungluu): Move to a separate message filter.
1347 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, 1345 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryOffsetAndLength,
1348 OnSetHistoryLengthAndPrune) 1346 OnSetHistoryOffsetAndLength)
1349 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 1347 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
1350 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, 1348 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1351 OnReleaseDisambiguationPopupBitmap) 1349 OnReleaseDisambiguationPopupBitmap)
1352 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, 1350 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted,
1353 OnWindowSnapshotCompleted) 1351 OnWindowSnapshotCompleted)
1354 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) 1352 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
1355 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) 1353 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
1356 #if defined(OS_ANDROID) 1354 #if defined(OS_ANDROID)
1357 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, 1355 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult,
1358 OnActivateNearestFindResult) 1356 OnActivateNearestFindResult)
(...skipping 22 matching lines...) Expand all
1381 1379
1382 void RenderViewImpl::OnSelectWordAroundCaret() { 1380 void RenderViewImpl::OnSelectWordAroundCaret() {
1383 if (!webview()) 1381 if (!webview())
1384 return; 1382 return;
1385 1383
1386 handling_input_event_ = true; 1384 handling_input_event_ = true;
1387 webview()->focusedFrame()->selectWordAroundCaret(); 1385 webview()->focusedFrame()->selectWordAroundCaret();
1388 handling_input_event_ = false; 1386 handling_input_event_ = false;
1389 } 1387 }
1390 1388
1391 bool RenderViewImpl::IsBackForwardToStaleEntry(const PageState& state,
1392 int pending_history_list_offset,
1393 int32 page_id,
1394 bool is_reload) {
1395 // Make sure this isn't a back/forward to an entry we have already cropped
1396 // or replaced from our history, before the browser knew about it. If so,
1397 // a new navigation has committed in the mean time, and we can ignore this.
1398 bool is_back_forward = !is_reload && state.IsValid();
1399
1400 // Note: if the history_list_length_ is 0 for a back/forward, we must be
Charlie Reis 2014/12/03 23:48:07 Oh, is this the reason you added the SetHistoryOff
Avi (use Gerrit) 2014/12/04 21:15:16 No, and I'm not sure I see what you're talking abo
Charlie Reis 2014/12/04 23:13:58 Your other reply said: 'So either we set a flag in
Avi (use Gerrit) 2014/12/05 22:16:39 Oh.... right! Yes, got it.
1401 // restoring from a previous session. We'll update our state in OnNavigate.
1402 if (!is_back_forward || history_list_length_ <= 0)
1403 return false;
1404
1405 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_);
1406
1407 // Check for whether the forward history has been cropped due to a recent
1408 // navigation the browser didn't know about.
1409 if (pending_history_list_offset >= history_list_length_)
1410 return true;
1411
1412 // Check for whether this entry has been replaced with a new one.
1413 int expected_page_id =
1414 history_page_ids_[pending_history_list_offset];
1415 if (expected_page_id > 0 && page_id != expected_page_id) {
1416 if (page_id < expected_page_id)
1417 return true;
1418
1419 // Otherwise we've removed an earlier entry and should have shifted all
1420 // entries left. For now, it's ok to lazily update the list.
1421 // TODO(creis): Notify all live renderers when we remove entries from
1422 // the front of the list, so that we don't hit this case.
1423 history_page_ids_[pending_history_list_offset] = page_id;
1424 }
1425
1426 return false;
1427 }
1428
1429 void RenderViewImpl::OnCopyImageAt(int x, int y) { 1389 void RenderViewImpl::OnCopyImageAt(int x, int y) {
1430 webview()->copyImageAt(WebPoint(x, y)); 1390 webview()->copyImageAt(WebPoint(x, y));
1431 } 1391 }
1432 1392
1433 void RenderViewImpl::OnSaveImageAt(int x, int y) { 1393 void RenderViewImpl::OnSaveImageAt(int x, int y) {
1434 webview()->saveImageAt(WebPoint(x, y)); 1394 webview()->saveImageAt(WebPoint(x, y));
1435 } 1395 }
1436 1396
1437 void RenderViewImpl::OnUpdateTargetURLAck() { 1397 void RenderViewImpl::OnUpdateTargetURLAck() {
1438 // Check if there is a targeturl waiting to be sent. 1398 // Check if there is a targeturl waiting to be sent.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 has_scrolled_focused_editable_node_into_rect_ = true; 1433 has_scrolled_focused_editable_node_into_rect_ = true;
1474 webview()->scrollFocusedNodeIntoRect(rect); 1434 webview()->scrollFocusedNodeIntoRect(rect);
1475 } 1435 }
1476 } 1436 }
1477 1437
1478 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( 1438 void RenderViewImpl::OnSetEditCommandsForNextKeyEvent(
1479 const EditCommands& edit_commands) { 1439 const EditCommands& edit_commands) {
1480 edit_commands_ = edit_commands; 1440 edit_commands_ = edit_commands;
1481 } 1441 }
1482 1442
1483 void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, 1443 void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset,
1484 int32 minimum_page_id) { 1444 int history_length) {
1445 DCHECK_GE(history_offset, -1);
1485 DCHECK_GE(history_length, 0); 1446 DCHECK_GE(history_length, 0);
1486 DCHECK(history_list_offset_ == history_list_length_ - 1);
1487 DCHECK_GE(minimum_page_id, -1);
1488 1447
1489 // Generate the new list. 1448 history_list_offset_ = history_offset;
1490 std::vector<int32> new_history_page_ids(history_length, -1); 1449 history_list_length_ = history_length;
1491 for (size_t i = 0; i < history_page_ids_.size(); ++i) {
1492 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id)
1493 continue;
1494 new_history_page_ids.push_back(history_page_ids_[i]);
1495 }
1496 new_history_page_ids.swap(history_page_ids_);
1497
1498 // Update indexes.
1499 history_list_length_ = history_page_ids_.size();
1500 history_list_offset_ = history_list_length_ - 1;
1501 } 1450 }
1502 1451
1503
1504 void RenderViewImpl::OnSetInitialFocus(bool reverse) { 1452 void RenderViewImpl::OnSetInitialFocus(bool reverse) {
1505 if (!webview()) 1453 if (!webview())
1506 return; 1454 return;
1507 webview()->setInitialFocus(reverse); 1455 webview()->setInitialFocus(reverse);
1508 } 1456 }
1509 1457
1510 #if defined(OS_MACOSX) 1458 #if defined(OS_MACOSX)
1511 void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) { 1459 void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) {
1512 if (!webview()) 1460 if (!webview())
1513 return; 1461 return;
(...skipping 2682 matching lines...) Expand 10 before | Expand all | Expand 10 after
4196 std::vector<gfx::Size> sizes; 4144 std::vector<gfx::Size> sizes;
4197 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); 4145 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
4198 if (!url.isEmpty()) 4146 if (!url.isEmpty())
4199 urls.push_back( 4147 urls.push_back(
4200 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); 4148 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
4201 } 4149 }
4202 SendUpdateFaviconURL(urls); 4150 SendUpdateFaviconURL(urls);
4203 } 4151 }
4204 4152
4205 } // namespace content 4153 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698