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

Unified Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2239273002: Don't use SSLStatus from FrameHostMsg_DidCommitProvisionalLoad and instead cache it on the browser … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Store SSLStatus in NavigationHandle Created 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/loader/resource_dispatcher_host_impl.cc
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index 847f0fd5f9d82e6dd5d54a4e4db3d75360c35fde..705ff922aa4d85b6b0dd797e0beb1d82f9551f35 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -42,6 +42,7 @@
#include "content/browser/download/download_resource_handler.h"
#include "content/browser/download/save_file_resource_handler.h"
#include "content/browser/frame_host/frame_tree.h"
+#include "content/browser/frame_host/navigation_handle_impl.h"
#include "content/browser/frame_host/navigation_request_info.h"
#include "content/browser/frame_host/navigator.h"
#include "content/browser/loader/async_resource_handler.h"
@@ -421,6 +422,23 @@ void NotifyForEachFrameFromUI(
base::Passed(std::move(routing_ids))));
}
+void UpdateSSLStatus(int render_process_id,
+ int render_frame_host_id,
+ int new_cert_id) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ RenderFrameHostImpl* render_frame_host =
+ RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id);
+ if (!render_frame_host)
+ return;
+
+ NavigationHandleImpl* navigation_handle =
+ render_frame_host->navigation_handle();
+ if (!navigation_handle)
+ return;
+
+ navigation_handle->UpdateSSLCertId(new_cert_id);
nasko 2016/08/25 18:09:48 I think it is still possible to have race conditio
jam 2016/08/25 21:56:46 this method is just for one case (cross-site trans
clamy 2016/08/25 23:25:14 Regarding the possible race condition, the issue c
clamy 2016/08/26 00:06:57 Looking at the code some more, I'm wondering if it
jam 2016/08/26 03:36:43 The first paragraph makes it sound like there's a
jam 2016/08/26 03:36:43 which method are you referring to?
clamy 2016/08/26 18:14:30 Hmm my first paragraph is not very clear. What I m
clamy 2016/08/26 18:14:30 It was just an optimization to avoid thread hops,.
+}
+
} // namespace
ResourceDispatcherHostImpl::HeaderInterceptorInfo::HeaderInterceptorInfo() {}
@@ -1206,8 +1224,8 @@ void ResourceDispatcherHostImpl::UpdateRequestForTransfer(
// updated to be associated with the new process.
if (loader->transferring_response()) {
UpdateResponseCertificateForTransfer(loader->transferring_response(),
- loader->request()->ssl_info(),
- child_id);
+ loader->request(),
+ info);
}
// Update maps that used the old IDs, if necessary. Some transfers in tests
@@ -1708,7 +1726,7 @@ ResourceDispatcherHostImpl::AddStandardHandlers(
// thread is handled by the NavigationURLloader.
if (!IsBrowserSideNavigationEnabled() && IsResourceTypeFrame(resource_type)) {
throttles.push_back(new NavigationResourceThrottle(
- request, delegate(), fetch_request_context_type));
+ request, delegate_, GetCertStore(), fetch_request_context_type));
}
if (delegate_) {
@@ -2297,7 +2315,8 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
// TODO(davidben): Attach AppCacheInterceptor.
std::unique_ptr<ResourceHandler> handler(
- new NavigationResourceHandler(new_request.get(), loader, delegate()));
+ new NavigationResourceHandler(new_request.get(), loader, delegate(),
+ GetCertStore()));
// TODO(davidben): Pass in the appropriate appcache_service. Also fix the
// dependency on child_id/route_id. Those are used by the ResourceScheduler;
@@ -2645,8 +2664,9 @@ int ResourceDispatcherHostImpl::BuildLoadFlagsForRequest(
void ResourceDispatcherHostImpl::UpdateResponseCertificateForTransfer(
ResourceResponse* response,
- const net::SSLInfo& ssl_info,
- int child_id) {
+ net::URLRequest* request,
+ ResourceRequestInfoImpl* info) {
+ const net::SSLInfo& ssl_info = request->ssl_info();
if (!ssl_info.cert)
return;
SSLStatus ssl;
@@ -2659,8 +2679,21 @@ void ResourceDispatcherHostImpl::UpdateResponseCertificateForTransfer(
bool deserialized =
DeserializeSecurityInfo(response->head.security_info, &ssl);
DCHECK(deserialized);
- ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id);
+ ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(),
+ info->GetChildID());
response->head.security_info = SerializeSecurityInfo(ssl);
+
+ if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME) {
+ int render_process_id, render_frame_id;
+ if (info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) {
+ BrowserThread::PostTask(BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(UpdateSSLStatus,
+ render_process_id,
+ render_frame_id,
+ ssl.cert_id));
+ }
+ }
}
CertStore* ResourceDispatcherHostImpl::GetCertStore() {

Powered by Google App Engine
This is Rietveld 408576698