| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 // We should not have a pending entry anymore. Clear it again in case any | 907 // We should not have a pending entry anymore. Clear it again in case any |
| 908 // error cases above forgot to do so. | 908 // error cases above forgot to do so. |
| 909 DiscardNonCommittedEntriesInternal(); | 909 DiscardNonCommittedEntriesInternal(); |
| 910 | 910 |
| 911 // All committed entries should have nonempty content state so WebKit doesn't | 911 // All committed entries should have nonempty content state so WebKit doesn't |
| 912 // get confused when we go back to them (see the function for details). | 912 // get confused when we go back to them (see the function for details). |
| 913 DCHECK(params.page_state.IsValid()); | 913 DCHECK(params.page_state.IsValid()); |
| 914 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); | 914 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); |
| 915 active_entry->SetTimestamp(timestamp); | 915 active_entry->SetTimestamp(timestamp); |
| 916 active_entry->SetHttpStatusCode(params.http_status_code); | 916 active_entry->SetHttpStatusCode(params.http_status_code); |
| 917 // TODO(creis): Do this on the frame entry instead, once we have them for |
| 918 // manual subframe navigations in --site-per-process. |
| 917 active_entry->SetPageState(params.page_state); | 919 active_entry->SetPageState(params.page_state); |
| 918 active_entry->SetRedirectChain(params.redirects); | 920 active_entry->SetRedirectChain(params.redirects); |
| 919 | 921 |
| 920 // Use histogram to track memory impact of redirect chain because it's now | 922 // Use histogram to track memory impact of redirect chain because it's now |
| 921 // not cleared for committed entries. | 923 // not cleared for committed entries. |
| 922 size_t redirect_chain_size = 0; | 924 size_t redirect_chain_size = 0; |
| 923 for (size_t i = 0; i < params.redirects.size(); ++i) { | 925 for (size_t i = 0; i < params.redirects.size(); ++i) { |
| 924 redirect_chain_size += params.redirects[i].spec().length(); | 926 redirect_chain_size += params.redirects[i].spec().length(); |
| 925 } | 927 } |
| 926 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); | 928 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 } | 1483 } |
| 1482 } | 1484 } |
| 1483 | 1485 |
| 1484 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1486 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1485 switches::kSitePerProcess)) { | 1487 switches::kSitePerProcess)) { |
| 1486 // This may be a "new auto" case where we add a new FrameNavigationEntry, or | 1488 // This may be a "new auto" case where we add a new FrameNavigationEntry, or |
| 1487 // it may be a "history auto" case where we update an existing one. | 1489 // it may be a "history auto" case where we update an existing one. |
| 1488 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); | 1490 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); |
| 1489 last_committed->AddOrUpdateFrameEntry(rfh->frame_tree_node(), | 1491 last_committed->AddOrUpdateFrameEntry(rfh->frame_tree_node(), |
| 1490 rfh->GetSiteInstance(), params.url, | 1492 rfh->GetSiteInstance(), params.url, |
| 1491 params.referrer); | 1493 params.referrer, params.page_state); |
| 1492 | 1494 |
| 1493 // Cross-process subframe navigations may leave a pending entry around. | 1495 // Cross-process subframe navigations may leave a pending entry around. |
| 1494 // Clear it if it's actually for the subframe. | 1496 // Clear it if it's actually for the subframe. |
| 1495 // TODO(creis): Don't use pending entries for subframe navigations. | 1497 // TODO(creis): Don't use pending entries for subframe navigations. |
| 1496 // See https://crbug.com/495161. | 1498 // See https://crbug.com/495161. |
| 1497 if (pending_entry_ && | 1499 if (pending_entry_ && |
| 1498 pending_entry_->frame_tree_node_id() == | 1500 pending_entry_->frame_tree_node_id() == |
| 1499 rfh->frame_tree_node()->frame_tree_node_id()) { | 1501 rfh->frame_tree_node()->frame_tree_node_id()) { |
| 1500 DiscardPendingEntry(false); | 1502 DiscardPendingEntry(false); |
| 1501 } | 1503 } |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2040 } | 2042 } |
| 2041 } | 2043 } |
| 2042 } | 2044 } |
| 2043 | 2045 |
| 2044 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2046 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 2045 const base::Callback<base::Time()>& get_timestamp_callback) { | 2047 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 2046 get_timestamp_callback_ = get_timestamp_callback; | 2048 get_timestamp_callback_ = get_timestamp_callback; |
| 2047 } | 2049 } |
| 2048 | 2050 |
| 2049 } // namespace content | 2051 } // namespace content |
| OLD | NEW |