Commit f88a86cf authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

Finish reverting r719801.

This CL finishes reverting r719801 (started in
https://crrev.com/c/2327963) while preserving the test coverage added
via MultiOriginSessionRestoreTest.

Bug: 1107269
Change-Id: I5172e610b098cb4a09187972498a031f12ee8539
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2336506Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarTobias Sargeant <tobiasjs@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Auto-Submit: Łukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798248}
parent e6685162
...@@ -92,9 +92,8 @@ bool RestoreFromPickle(base::PickleIterator* iterator, ...@@ -92,9 +92,8 @@ bool RestoreFromPickle(base::PickleIterator* iterator,
entries.reserve(entry_count); entries.reserve(entry_count);
for (int i = 0; i < entry_count; ++i) { for (int i = 0; i < entry_count; ++i) {
entries.push_back(content::NavigationEntry::Create()); entries.push_back(content::NavigationEntry::Create());
if (!internal::RestoreNavigationEntryFromPickle( if (!internal::RestoreNavigationEntryFromPickle(state_version, iterator,
state_version, iterator, web_contents->GetBrowserContext(), entries[i].get()))
entries[i].get()))
return false; return false;
} }
...@@ -183,19 +182,15 @@ void WriteNavigationEntryToPickle(uint32_t state_version, ...@@ -183,19 +182,15 @@ void WriteNavigationEntryToPickle(uint32_t state_version,
} }
bool RestoreNavigationEntryFromPickle(base::PickleIterator* iterator, bool RestoreNavigationEntryFromPickle(base::PickleIterator* iterator,
content::BrowserContext* browser_context,
content::NavigationEntry* entry) { content::NavigationEntry* entry) {
return RestoreNavigationEntryFromPickle(AW_STATE_VERSION, iterator, return RestoreNavigationEntryFromPickle(AW_STATE_VERSION, iterator, entry);
browser_context, entry);
} }
bool RestoreNavigationEntryFromPickle(uint32_t state_version, bool RestoreNavigationEntryFromPickle(uint32_t state_version,
base::PickleIterator* iterator, base::PickleIterator* iterator,
content::BrowserContext* browser_context,
content::NavigationEntry* entry) { content::NavigationEntry* entry) {
DCHECK(IsSupportedVersion(state_version)); DCHECK(IsSupportedVersion(state_version));
DCHECK(iterator); DCHECK(iterator);
DCHECK(browser_context);
DCHECK(entry); DCHECK(entry);
GURL deserialized_url; GURL deserialized_url;
...@@ -337,7 +332,6 @@ bool RestoreNavigationEntryFromPickle(uint32_t state_version, ...@@ -337,7 +332,6 @@ bool RestoreNavigationEntryFromPickle(uint32_t state_version,
entry->SetHttpStatusCode(http_status_code); entry->SetHttpStatusCode(http_status_code);
} }
entry->InitRestoredEntry(browser_context);
return true; return true;
} }
......
...@@ -18,7 +18,6 @@ class PickleIterator; ...@@ -18,7 +18,6 @@ class PickleIterator;
namespace content { namespace content {
class BrowserContext;
class NavigationEntry; class NavigationEntry;
class WebContents; class WebContents;
...@@ -55,12 +54,10 @@ void WriteNavigationEntryToPickle(uint32_t state_version, ...@@ -55,12 +54,10 @@ void WriteNavigationEntryToPickle(uint32_t state_version,
content::NavigationEntry& entry, content::NavigationEntry& entry,
base::Pickle* pickle); base::Pickle* pickle);
bool RestoreNavigationEntryFromPickle(base::PickleIterator* iterator, bool RestoreNavigationEntryFromPickle(base::PickleIterator* iterator,
content::BrowserContext* browser_context,
content::NavigationEntry* entry) content::NavigationEntry* entry)
WARN_UNUSED_RESULT; WARN_UNUSED_RESULT;
bool RestoreNavigationEntryFromPickle(uint32_t state_version, bool RestoreNavigationEntryFromPickle(uint32_t state_version,
base::PickleIterator* iterator, base::PickleIterator* iterator,
content::BrowserContext* browser_context,
content::NavigationEntry* entry) content::NavigationEntry* entry)
WARN_UNUSED_RESULT; WARN_UNUSED_RESULT;
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/page_state.h" #include "content/public/common/page_state.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "services/network/public/mojom/referrer_policy.mojom-shared.h" #include "services/network/public/mojom/referrer_policy.mojom-shared.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -74,13 +72,7 @@ class AndroidWebViewStateSerializerTest : public testing::Test { ...@@ -74,13 +72,7 @@ class AndroidWebViewStateSerializerTest : public testing::Test {
content::SetContentClient(nullptr); content::SetContentClient(nullptr);
} }
protected:
content::BrowserContext* browser_context() { return &browser_context_; }
private: private:
content::BrowserTaskEnvironment test_environment_;
content::TestBrowserContext browser_context_;
content::ContentClient content_client_; content::ContentClient content_client_;
content::ContentBrowserClient browser_client_; content::ContentBrowserClient browser_client_;
...@@ -127,8 +119,8 @@ TEST_F(AndroidWebViewStateSerializerTest, TestNavigationEntrySerialization) { ...@@ -127,8 +119,8 @@ TEST_F(AndroidWebViewStateSerializerTest, TestNavigationEntrySerialization) {
std::unique_ptr<content::NavigationEntry> copy( std::unique_ptr<content::NavigationEntry> copy(
content::NavigationEntry::Create()); content::NavigationEntry::Create());
base::PickleIterator iterator(pickle); base::PickleIterator iterator(pickle);
bool result = internal::RestoreNavigationEntryFromPickle( bool result =
&iterator, browser_context(), copy.get()); internal::RestoreNavigationEntryFromPickle(&iterator, copy.get());
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ(entry->GetURL(), copy->GetURL()); EXPECT_EQ(entry->GetURL(), copy->GetURL());
...@@ -160,8 +152,7 @@ TEST_F(AndroidWebViewStateSerializerTest, ...@@ -160,8 +152,7 @@ TEST_F(AndroidWebViewStateSerializerTest,
content::NavigationEntry::Create()); content::NavigationEntry::Create());
base::PickleIterator iterator(pickle); base::PickleIterator iterator(pickle);
bool result = internal::RestoreNavigationEntryFromPickle( bool result = internal::RestoreNavigationEntryFromPickle(
internal::AW_STATE_VERSION_INITIAL, &iterator, browser_context(), internal::AW_STATE_VERSION_INITIAL, &iterator, copy.get());
copy.get());
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ(entry->GetURL(), copy->GetURL()); EXPECT_EQ(entry->GetURL(), copy->GetURL());
...@@ -222,8 +213,8 @@ TEST_F(AndroidWebViewStateSerializerTest, ...@@ -222,8 +213,8 @@ TEST_F(AndroidWebViewStateSerializerTest,
base::PickleIterator iterator(pickle); base::PickleIterator iterator(pickle);
std::unique_ptr<content::NavigationEntry> copy = std::unique_ptr<content::NavigationEntry> copy =
content::NavigationEntry::Create(); content::NavigationEntry::Create();
bool result = internal::RestoreNavigationEntryFromPickle( bool result =
&iterator, browser_context(), copy.get()); internal::RestoreNavigationEntryFromPickle(&iterator, copy.get());
EXPECT_TRUE(result); EXPECT_TRUE(result);
// In https://crbug.com/999078, the empty PageState would clobber the URL // In https://crbug.com/999078, the empty PageState would clobber the URL
...@@ -262,8 +253,8 @@ TEST_F(AndroidWebViewStateSerializerTest, TestEmptyDataURLSerialization) { ...@@ -262,8 +253,8 @@ TEST_F(AndroidWebViewStateSerializerTest, TestEmptyDataURLSerialization) {
std::unique_ptr<content::NavigationEntry> copy( std::unique_ptr<content::NavigationEntry> copy(
content::NavigationEntry::Create()); content::NavigationEntry::Create());
base::PickleIterator iterator(pickle); base::PickleIterator iterator(pickle);
bool result = internal::RestoreNavigationEntryFromPickle( bool result =
&iterator, browser_context(), copy.get()); internal::RestoreNavigationEntryFromPickle(&iterator, copy.get());
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_FALSE(entry->GetDataURLAsString()); EXPECT_FALSE(entry->GetDataURLAsString());
} }
...@@ -285,8 +276,8 @@ TEST_F(AndroidWebViewStateSerializerTest, TestHugeDataURLSerialization) { ...@@ -285,8 +276,8 @@ TEST_F(AndroidWebViewStateSerializerTest, TestHugeDataURLSerialization) {
std::unique_ptr<content::NavigationEntry> copy( std::unique_ptr<content::NavigationEntry> copy(
content::NavigationEntry::Create()); content::NavigationEntry::Create());
base::PickleIterator iterator(pickle); base::PickleIterator iterator(pickle);
bool result = internal::RestoreNavigationEntryFromPickle( bool result =
&iterator, browser_context(), copy.get()); internal::RestoreNavigationEntryFromPickle(&iterator, copy.get());
EXPECT_TRUE(result); EXPECT_TRUE(result);
EXPECT_EQ(huge_data_url, copy->GetDataURLAsString()->data()); EXPECT_EQ(huge_data_url, copy->GetDataURLAsString()->data());
} }
......
...@@ -180,8 +180,6 @@ ContentSerializedNavigationBuilder::ToNavigationEntry( ...@@ -180,8 +180,6 @@ ContentSerializedNavigationBuilder::ToNavigationEntry(
entry.get()); entry.get());
} }
entry->InitRestoredEntry(browser_context);
// These fields should have default values. // These fields should have default values.
DCHECK_EQ(SerializedNavigationEntry::STATE_INVALID, DCHECK_EQ(SerializedNavigationEntry::STATE_INVALID,
navigation->blocked_state_); navigation->blocked_state_);
......
...@@ -181,32 +181,6 @@ bool InSameTreePosition(FrameTreeNode* frame_tree_node, ...@@ -181,32 +181,6 @@ bool InSameTreePosition(FrameTreeNode* frame_tree_node,
return true; return true;
} }
void InitRestoredTreeNode(BrowserContext* browser_context,
NavigationEntryImpl::TreeNode* node) {
DCHECK(browser_context);
DCHECK(node);
// Check that this is a freshly restored entry.
FrameNavigationEntry* frame_entry = node->frame_entry.get();
DCHECK(!frame_entry->site_instance());
// Check that the entry has been already populated with required information.
DCHECK(frame_entry->page_state().IsValid());
// TODO(lukasza): Finish reverting r719801 and remove this empty function and
// its callers.
}
void RecursivelyInitRestoredTreeNode(BrowserContext* browser_context,
NavigationEntryImpl::TreeNode* node) {
DCHECK(browser_context);
DCHECK(node);
InitRestoredTreeNode(browser_context, node);
for (const auto& child : node->children)
RecursivelyInitRestoredTreeNode(browser_context, child.get());
}
void RegisterOriginsRecursive(NavigationEntryImpl::TreeNode* node, void RegisterOriginsRecursive(NavigationEntryImpl::TreeNode* node,
const url::Origin& origin) { const url::Origin& origin) {
if (node->frame_entry->committed_origin().has_value()) { if (node->frame_entry->committed_origin().has_value()) {
...@@ -673,11 +647,6 @@ int64_t NavigationEntryImpl::GetMainFrameDocumentSequenceNumber() { ...@@ -673,11 +647,6 @@ int64_t NavigationEntryImpl::GetMainFrameDocumentSequenceNumber() {
return frame_tree_->frame_entry->document_sequence_number(); return frame_tree_->frame_entry->document_sequence_number();
} }
void NavigationEntryImpl::InitRestoredEntry(BrowserContext* browser_context) {
DCHECK(browser_context);
RecursivelyInitRestoredTreeNode(browser_context, root_node());
}
void NavigationEntryImpl::SetCanLoadLocalResources(bool allow) { void NavigationEntryImpl::SetCanLoadLocalResources(bool allow) {
can_load_local_resources_ = allow; can_load_local_resources_ = allow;
} }
......
...@@ -148,7 +148,6 @@ class CONTENT_EXPORT NavigationEntryImpl : public NavigationEntry { ...@@ -148,7 +148,6 @@ class CONTENT_EXPORT NavigationEntryImpl : public NavigationEntry {
std::string GetExtraHeaders() override; std::string GetExtraHeaders() override;
void AddExtraHeaders(const std::string& extra_headers) override; void AddExtraHeaders(const std::string& extra_headers) override;
int64_t GetMainFrameDocumentSequenceNumber() override; int64_t GetMainFrameDocumentSequenceNumber() override;
void InitRestoredEntry(BrowserContext* browser_context) override;
// Creates a copy of this NavigationEntryImpl that can be modified // Creates a copy of this NavigationEntryImpl that can be modified
// independently from the original. Does not copy any value that would be // independently from the original. Does not copy any value that would be
......
...@@ -26,7 +26,6 @@ class GURL; ...@@ -26,7 +26,6 @@ class GURL;
namespace content { namespace content {
class BrowserContext;
class PageState; class PageState;
struct FaviconStatus; struct FaviconStatus;
struct ReplacedNavigationEntryData; struct ReplacedNavigationEntryData;
...@@ -42,16 +41,6 @@ class NavigationEntry : public base::SupportsUserData { ...@@ -42,16 +41,6 @@ class NavigationEntry : public base::SupportsUserData {
CONTENT_EXPORT static std::unique_ptr<NavigationEntry> Create(); CONTENT_EXPORT static std::unique_ptr<NavigationEntry> Create();
// Performs initialization of a restored NavigationEntry.
//
// An example of work performed by this method is recomputing SiteInstance
// information in some scenarios (see also https://crbug.com/1026474).
//
// This method needs to be called after |this| entry has been fully populated
// during session restore. In particular, the SetURL and SetPageState calls
// should have already happened before calling InitRestoredEntry.
virtual void InitRestoredEntry(BrowserContext* browser_context) = 0;
// Page-related stuff -------------------------------------------------------- // Page-related stuff --------------------------------------------------------
// A unique ID is preserved across commits and redirects, which means that // A unique ID is preserved across commits and redirects, which means that
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment