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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1263393002: Gather debugging information for the switch away from page id for titles and state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 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/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/crash_logging.h"
10 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
14 #include "base/process/process.h" 15 #include "base/process/process.h"
15 #include "base/profiler/scoped_tracker.h" 16 #include "base/profiler/scoped_tracker.h"
16 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
17 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
(...skipping 3834 matching lines...) Expand 10 before | Expand all | Expand 10 after
3854 FOR_EACH_OBSERVER(WebContentsObserver, 3855 FOR_EACH_OBSERVER(WebContentsObserver,
3855 observers_, 3856 observers_,
3856 RenderProcessGone(GetCrashedStatus())); 3857 RenderProcessGone(GetCrashedStatus()));
3857 } 3858 }
3858 3859
3859 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { 3860 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) {
3860 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); 3861 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh));
3861 } 3862 }
3862 3863
3863 void WebContentsImpl::UpdateState(RenderViewHost* rvh, 3864 void WebContentsImpl::UpdateState(RenderViewHost* rvh,
3864 int32 page_id, 3865 int32 page_id,
Charlie Reis 2015/08/03 20:41:38 In this case, we should probably also log both pag
3865 const PageState& page_state) { 3866 const PageState& page_state) {
3866 // Ensure that this state update comes from a RenderViewHost that belongs to 3867 // Ensure that this state update comes from a RenderViewHost that belongs to
3867 // this WebContents. 3868 // this WebContents.
3868 // TODO(nasko): This should go through RenderFrameHost. 3869 // TODO(nasko): This should go through RenderFrameHost.
3869 if (rvh->GetDelegate()->GetAsWebContents() != this) 3870 if (rvh->GetDelegate()->GetAsWebContents() != this)
3870 return; 3871 return;
3871 3872
3872 // We must be prepared to handle state updates for any page. They occur 3873 // We must be prepared to handle state updates for any page. They occur
3873 // when the user is scrolling and entering form data, as well as when we're 3874 // when the user is scrolling and entering form data, as well as when we're
3874 // leaving a page, in which case our state may have already been moved to 3875 // leaving a page, in which case our state may have already been moved to
3875 // the next page. The navigation controller will look up the appropriate 3876 // the next page. The navigation controller will look up the appropriate
3876 // NavigationEntry and update it when it is notified via the delegate. 3877 // NavigationEntry and update it when it is notified via the delegate.
3877 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); 3878 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh);
3878 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( 3879 NavigationEntryImpl* entry = controller_.GetEntryWithPageID(
3879 rvhi->GetSiteInstance(), page_id); 3880 rvhi->GetSiteInstance(), page_id);
3880 if (!entry) 3881 if (!entry)
3881 return; 3882 return;
3882 3883
3883 NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID( 3884 NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID(
3884 rvhi->nav_entry_id()); 3885 rvhi->nav_entry_id());
3886 CHECK(new_entry);
3885 3887
3886 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 3888 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
3887 // TODO(creis): We can't properly update state for cross-process subframes 3889 // TODO(creis): We can't properly update state for cross-process subframes
3888 // until PageState is decomposed into FrameStates. Until then, use the new 3890 // until PageState is decomposed into FrameStates. Until then, use the new
3889 // method. 3891 // method.
3890 entry = new_entry; 3892 entry = new_entry;
3891 } else { 3893 } else {
3892 DCHECK_EQ(entry, new_entry); 3894 base::debug::SetCrashKeyValue(
3895 "oldindex", base::IntToString(controller_.GetIndexOfEntry(entry)));
3896 base::debug::SetCrashKeyValue(
3897 "newindex", base::IntToString(controller_.GetIndexOfEntry(new_entry)));
3898 base::debug::SetCrashKeyValue(
3899 "lastcommittedindex",
3900 base::IntToString(controller_.GetLastCommittedEntryIndex()));
3901 base::debug::SetCrashKeyValue("oldurl", entry->GetURL().spec());
3902 base::debug::SetCrashKeyValue("newurl", new_entry->GetURL().spec());
3903 base::debug::SetCrashKeyValue(
3904 "updatedvalue", page_state.GetTopLevelUrlStringTemporaryForBug369661());
3905 base::debug::SetCrashKeyValue("oldvalue", entry->GetURL().spec());
3906 base::debug::SetCrashKeyValue("newvalue", new_entry->GetURL().spec());
3907 CHECK_EQ(entry, new_entry);
3893 } 3908 }
3894 3909
3895 if (page_state == entry->GetPageState()) 3910 if (page_state == entry->GetPageState())
3896 return; // Nothing to update. 3911 return; // Nothing to update.
3897 entry->SetPageState(page_state); 3912 entry->SetPageState(page_state);
3898 controller_.NotifyEntryChanged(entry); 3913 controller_.NotifyEntryChanged(entry);
3899 } 3914 }
3900 3915
3901 void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host, 3916 void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host,
3902 const GURL& url) { 3917 const GURL& url) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
4046 DocumentOnLoadCompletedInMainFrame()); 4061 DocumentOnLoadCompletedInMainFrame());
4047 4062
4048 // TODO(avi): Remove. http://crbug.com/170921 4063 // TODO(avi): Remove. http://crbug.com/170921
4049 NotificationService::current()->Notify( 4064 NotificationService::current()->Notify(
4050 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 4065 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
4051 Source<WebContents>(this), 4066 Source<WebContents>(this),
4052 NotificationService::NoDetails()); 4067 NotificationService::NoDetails());
4053 } 4068 }
4054 4069
4055 void WebContentsImpl::UpdateTitle(RenderFrameHost* render_frame_host, 4070 void WebContentsImpl::UpdateTitle(RenderFrameHost* render_frame_host,
4056 int32 page_id, 4071 int32 page_id,
Charlie Reis 2015/08/03 20:41:38 Maybe we should report page_id and RVH::nav_entry_
Avi (use Gerrit) 2015/08/03 20:51:53 Done.
4057 const base::string16& title, 4072 const base::string16& title,
4058 base::i18n::TextDirection title_direction) { 4073 base::i18n::TextDirection title_direction) {
4059 // If we have a title, that's a pretty good indication that we've started 4074 // If we have a title, that's a pretty good indication that we've started
4060 // getting useful data. 4075 // getting useful data.
4061 SetNotWaitingForResponse(); 4076 SetNotWaitingForResponse();
4062 4077
4063 // Try to find the navigation entry, which might not be the current one. 4078 // Try to find the navigation entry, which might not be the current one.
4064 // For example, it might be from a recently swapped out RFH. 4079 // For example, it might be from a recently swapped out RFH.
4065 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( 4080 NavigationEntryImpl* entry = controller_.GetEntryWithPageID(
4066 render_frame_host->GetSiteInstance(), page_id); 4081 render_frame_host->GetSiteInstance(), page_id);
4067 4082
4068 RenderViewHostImpl* rvhi = 4083 RenderViewHostImpl* rvhi =
4069 static_cast<RenderViewHostImpl*>(render_frame_host->GetRenderViewHost()); 4084 static_cast<RenderViewHostImpl*>(render_frame_host->GetRenderViewHost());
4070 NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID( 4085 NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID(
4071 rvhi->nav_entry_id()); 4086 rvhi->nav_entry_id());
4072 DCHECK_EQ(entry, new_entry); 4087
4088 base::debug::SetCrashKeyValue(
4089 "oldindex", base::IntToString(controller_.GetIndexOfEntry(entry)));
Charlie Reis 2015/08/03 20:41:38 Sanity check: Will this crash if entry is null?
Avi (use Gerrit) 2015/08/03 20:51:53 No, it doesn't care.
4090 base::debug::SetCrashKeyValue(
4091 "newindex", base::IntToString(controller_.GetIndexOfEntry(new_entry)));
4092 base::debug::SetCrashKeyValue(
4093 "lastcommittedindex",
4094 base::IntToString(controller_.GetLastCommittedEntryIndex()));
4095 base::debug::SetCrashKeyValue("oldurl", entry->GetURL().spec());
4096 base::debug::SetCrashKeyValue("newurl", new_entry->GetURL().spec());
4097 base::debug::SetCrashKeyValue("updatedvalue", base::UTF16ToUTF8(title));
4098 base::debug::SetCrashKeyValue("oldvalue",
4099 base::UTF16ToUTF8(entry->GetTitle()));
4100 base::debug::SetCrashKeyValue("newvalue",
4101 base::UTF16ToUTF8(new_entry->GetTitle()));
4102 CHECK_EQ(entry, new_entry);
Charlie Reis 2015/08/03 20:41:38 Note: In f2b5526a1c958891, |entry| is null and |ne
Avi (use Gerrit) 2015/08/03 20:51:53 Accounted for in the new patchset.
4073 4103
4074 // We can handle title updates when we don't have an entry in 4104 // We can handle title updates when we don't have an entry in
4075 // UpdateTitleForEntry, but only if the update is from the current RVH. 4105 // UpdateTitleForEntry, but only if the update is from the current RVH.
4076 // TODO(avi): Change to make decisions based on the RenderFrameHost. 4106 // TODO(avi): Change to make decisions based on the RenderFrameHost.
4077 if (!entry && render_frame_host != GetMainFrame()) 4107 if (!entry && render_frame_host != GetMainFrame())
4078 return; 4108 return;
4079 4109
4080 // TODO(evan): make use of title_direction. 4110 // TODO(evan): make use of title_direction.
4081 // http://code.google.com/p/chromium/issues/detail?id=27094 4111 // http://code.google.com/p/chromium/issues/detail?id=27094
4082 if (!UpdateTitleForEntry(entry, title)) 4112 if (!UpdateTitleForEntry(entry, title))
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
4608 player_map->erase(it); 4638 player_map->erase(it);
4609 } 4639 }
4610 4640
4611 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4641 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4612 force_disable_overscroll_content_ = force_disable; 4642 force_disable_overscroll_content_ = force_disable;
4613 if (view_) 4643 if (view_)
4614 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4644 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4615 } 4645 }
4616 4646
4617 } // namespace content 4647 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698