Clean up FrameFetchContext |
||||
Issue descriptionFrameFetchContext contains too much logic than needed. Ideally, it should hold stuff for ResourceFetcher.
,
Dec 13 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/3b099320199a62fcb0e8b66f50e87fd1726c2449 commit 3b099320199a62fcb0e8b66f50e87fd1726c2449 Author: tyoshino <tyoshino@chromium.org> Date: Tue Dec 13 07:11:45 2016 Split methods for ClientHintsPreferences from FrameFetchContext FrameFetchContext is containing too many things. We'd like to slim it down to hold basically only things that receive and handle notifications from ResourceFetcher. The methods for ClientHintsPreferences on FrameFetchContext is placed there (I guess) just not to introduce dependencies from core/fetch to core/loader, core/frame, etc. See https://codereview.chromium.org/1189523015 which introduced this logic initially. ---- Compatibility analysis: It's safe to directly pass frame() to FrameClientHintsPreferencesContext in FrameFetchContext::dispatchDidReceiveResponseInternal(). If the passed ResourceFetcher is already clearContext()-ed, we never reach dispatchDidReceiveResponseInternal(). So, we can assume that the ResourceFetcher passed to updateFromAcceptClientHintsHeader() was always not yet clearContext()-ed. HttpEquiv::processHttpEquivAcceptCH() was passing document.fetcher() to updateFromAcceptClientHintsHeader(). Document::m_fetcher is cleared only in Document::shutdown(). Therefore, document.frame() being non-null at the beginning of processHttpEquivAcceptCH() means that the Document hasn't yet shutdown. context().frame() call on document.fetcher() returns document.frame() unless clearContext() was called. This is true even when setImportsController() was called on the Document. This is clarified by a separate CL https://codereview.chromium.org/2547843002/. There're three callers of ResourceFetcher::clearContext(). One of them is Document::shutdown(). So, we don't need to care it. The other cases are: - setImportsController() called by LinkImport::process() while Document::loader() is null - DocumentLoader::detachFromFrame() was called However, I think this behavior was not intended initially and was introduced just accidentally as stated above. R=yhirano@chromium.org BUG= 671533 Review-Url: https://codereview.chromium.org/2544933003 Cr-Commit-Position: refs/heads/master@{#438090} [modify] https://crrev.com/3b099320199a62fcb0e8b66f50e87fd1726c2449/third_party/WebKit/Source/core/fetch/ClientHintsPreferences.cpp [modify] https://crrev.com/3b099320199a62fcb0e8b66f50e87fd1726c2449/third_party/WebKit/Source/core/fetch/ClientHintsPreferences.h [modify] https://crrev.com/3b099320199a62fcb0e8b66f50e87fd1726c2449/third_party/WebKit/Source/core/fetch/FetchContext.h [modify] https://crrev.com/3b099320199a62fcb0e8b66f50e87fd1726c2449/third_party/WebKit/Source/core/loader/BUILD.gn [add] https://crrev.com/3b099320199a62fcb0e8b66f50e87fd1726c2449/third_party/WebKit/Source/core/loader/FrameClientHintsPreferencesContext.cpp [add] https://crrev.com/3b099320199a62fcb0e8b66f50e87fd1726c2449/third_party/WebKit/Source/core/loader/FrameClientHintsPreferencesContext.h [modify] https://crrev.com/3b099320199a62fcb0e8b66f50e87fd1726c2449/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp [modify] https://crrev.com/3b099320199a62fcb0e8b66f50e87fd1726c2449/third_party/WebKit/Source/core/loader/FrameFetchContext.h [modify] https://crrev.com/3b099320199a62fcb0e8b66f50e87fd1726c2449/third_party/WebKit/Source/core/loader/HttpEquiv.cpp
,
Jan 18 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/ad61664891105622dd6a46201f97bec138f00f4c commit ad61664891105622dd6a46201f97bec138f00f4c Author: tyoshino <tyoshino@chromium.org> Date: Wed Jan 18 11:17:24 2017 Use LocalFrame::client() than getting the FrameLoader and then call client() on it. FrameLoader::client() is just calling m_frame->client(). R=yhirano@chromium.org BUG= 671533 Review-Url: https://codereview.chromium.org/2557053002 Cr-Commit-Position: refs/heads/master@{#444332} [modify] https://crrev.com/ad61664891105622dd6a46201f97bec138f00f4c/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp [modify] https://crrev.com/ad61664891105622dd6a46201f97bec138f00f4c/third_party/WebKit/Source/core/loader/FrameFetchContext.h [modify] https://crrev.com/ad61664891105622dd6a46201f97bec138f00f4c/third_party/WebKit/Source/core/loader/ProgressTracker.cpp [modify] https://crrev.com/ad61664891105622dd6a46201f97bec138f00f4c/third_party/WebKit/Source/core/loader/ProgressTracker.h
,
Jan 18 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/78f5a0c23df6926c73cf92839638868e982aae7e commit 78f5a0c23df6926c73cf92839638868e982aae7e Author: tyoshino <tyoshino@chromium.org> Date: Wed Jan 18 11:23:36 2017 Clarify when DocumentLoader's FrameLoader/FrameLoaderClient accessors can be used - Change frameLoader() to return a reference after DCHECK on m_frame - Get FrameLoaderClient directly from m_frame when needed than getting the FrameLoader and then calling client() on it. FrameLoader::client() is just calling m_frame->client(). - Replace code checking nullness of frameLoader() with m_frame - Use m_frame inside DocumentLoader than calling frame() which doesn't add any value. R=yhirano@chromium.org,tkent@chromium.org BUG= 671533 Review-Url: https://codereview.chromium.org/2556053002 Cr-Commit-Position: refs/heads/master@{#444333} [modify] https://crrev.com/78f5a0c23df6926c73cf92839638868e982aae7e/third_party/WebKit/Source/core/loader/DocumentLoader.cpp [modify] https://crrev.com/78f5a0c23df6926c73cf92839638868e982aae7e/third_party/WebKit/Source/core/loader/DocumentLoader.h [modify] https://crrev.com/78f5a0c23df6926c73cf92839638868e982aae7e/third_party/WebKit/Source/core/loader/EmptyClients.cpp [modify] https://crrev.com/78f5a0c23df6926c73cf92839638868e982aae7e/third_party/WebKit/Source/web/FrameLoaderClientImpl.cpp [modify] https://crrev.com/78f5a0c23df6926c73cf92839638868e982aae7e/third_party/WebKit/Source/web/WebDataSourceImpl.cpp
,
Apr 20 2017
Assigning to kinuko@ as kinuko@ has been actively working on FrameFetchContext redesigning recently. Feel free to use this or close.
,
Jun 9 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/74a7fb2fa4307c69812945586b39018ae4f231b2 commit 74a7fb2fa4307c69812945586b39018ae4f231b2 Author: kinuko <kinuko@chromium.org> Date: Fri Jun 09 03:50:22 2017 Remove dup'ed code for RequestorOrigin and FirstPartyCookie - Remove RequestorOrigin and FirstPartyCookie code in RenderFrameImpl (except for PlzNavigate's main frame resource case) - Most of the code now lives in FrameFetchContext - Also fix TODO to initialize ResourceRequest::RequestorOrigin with null Some implementation notes: Before this change, the logic was like: 1. When ResourceFetcher populates an initial resource request FetchContext::SetFirstPartyCookieAndRequestorOrigin was called in PopulateResourceRequest, and this used to do: if (!GetDocument()) return; if (request.FirstPartyForCookies().IsNull()) { request.SetFirstPartyForCookies( GetDocument() ? GetDocument()->FirstPartyForCookies() // [A] : SecurityOrigin::UrlWithUniqueSecurityOrigin()); // [B] } if (request.GetFrameType() == WebURLRequest::kFrameTypeNone && request.RequestorOrigin()->IsUnique()) { request.SetRequestorOrigin(GetDocument()->IsSandboxed(kSandboxOrigin) ? SecurityOrigin::Create(document_->Url()) // [a] : document_->GetSecurityOrigin()); // [b] } 2. After that, FrameFetchContext::WillSendRequest does: if (request.FirstPartyForCookies().IsEmpty()) { if (request.GetFrameType() == blink::WebURLRequest::kFrameTypeTopLevel) request.SetFirstPartyForCookies(request.Url()); // [C] else request.SetFirstPartyForCookies( frame_->GetDocument().FirstPartyForCookies()); // [D] } WebDocument frame_document = frame_->GetDocument(); if (request.RequestorOrigin().IsUnique() && !frame_document.GetSecurityOrigin().IsUnique()) { request.SetRequestorOrigin(frame_document.GetSecurityOrigin()); // [c] } This logic is also called on redirects. Note that: - [B] case is invalid as we return null-document case - [C],[D],[c] happens only if document is null, and for initial top-level frame request case this is always the case - Therefore: [A][C][D] are the valid cases for first-party-cookie, and [a][b][c] are for requestor-origin After this change, FrameFetchContext::WillSendRequest does: if (request.FirstPartyForCookies().IsNull()) { if (request.GetFrameType() == WebURLRequest::kFrameTypeTopLevel) { request.SetFirstPartyForCookies(request.Url()); // == [C] (document is null) } else { Document* document = GetDocument() ? GetDocument() : GetFrame()->GetDocument(); request.SetFirstPartyForCookies(document->FirstPartyForCookies()); // == [A][D] } } if (!request.RequestorOrigin()) { if (request.GetFrameType() == WebURLRequest::kFrameTypeNone) { Document* document = GetDocument(); request.SetRequestorOrigin(document->IsSandboxed(kSandboxOrigin) ? SecurityOrigin::Create(document->Url()) // [a] : document->GetSecurityOrigin()); // [b] } else { request.SetRequestorOrigin( GetFrame()->GetDocument()->GetSecurityOrigin()); // [c] } } BUG= 671533 , 625969 Review-Url: https://codereview.chromium.org/2918653004 Cr-Commit-Position: refs/heads/master@{#478191} [modify] https://crrev.com/74a7fb2fa4307c69812945586b39018ae4f231b2/content/renderer/fetchers/resource_fetcher_impl.cc [modify] https://crrev.com/74a7fb2fa4307c69812945586b39018ae4f231b2/content/renderer/render_frame_impl.cc [modify] https://crrev.com/74a7fb2fa4307c69812945586b39018ae4f231b2/third_party/WebKit/Source/core/loader/FrameFetchContext.cpp [modify] https://crrev.com/74a7fb2fa4307c69812945586b39018ae4f231b2/third_party/WebKit/Source/core/loader/FrameFetchContextTest.cpp [modify] https://crrev.com/74a7fb2fa4307c69812945586b39018ae4f231b2/third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp [modify] https://crrev.com/74a7fb2fa4307c69812945586b39018ae4f231b2/third_party/WebKit/Source/platform/loader/fetch/ResourceRequest.cpp [modify] https://crrev.com/74a7fb2fa4307c69812945586b39018ae4f231b2/third_party/WebKit/Source/platform/loader/fetch/ResourceRequestTest.cpp
,
Jun 9 2017
,
Aug 23
I have no immediate plan to work further on this one, let me close this. |
||||
►
Sign in to add a comment |
||||
Comment 1 by bugdroid1@chromium.org
, Dec 6 2016