mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Move the frame/handler association to CefResourceContext (see issue #2622).
A CefBrowserHostImpl is created using a CefRequestContextImpl that may have a CefRequestContextHandler. Multiple CefRequestContextImpl may share the same underlying CefBrowserContext which owns a CefResourceContext. IO-thread callbacks from Chromium are often associated with a CefResourceContext and the target frame is identified using render_process_id/render_frame_id routing IDs. This change forwards frame create/delete notifications from CefBrowserHostImpl (or CefMimeHandlerViewGuestDelegate) to CefResourceContext so that it can properly resolve the association from routing ID to Handler when queried from CefPluginServiceFilter::IsPluginAvailable. To test: Verify that all ceftests pass with NetworkService disabled.
This commit is contained in:
@@ -287,8 +287,7 @@ void CefBrowserContext::Initialize() {
|
||||
|
||||
content::BrowserContext::Initialize(this, GetPath());
|
||||
|
||||
resource_context_.reset(
|
||||
new CefResourceContext(IsOffTheRecord(), GetHandler()));
|
||||
resource_context_.reset(new CefResourceContext(IsOffTheRecord()));
|
||||
|
||||
// This must be called before creating any services to avoid hitting
|
||||
// DependencyManager::AssertContextWasntDestroyed when creating/destroying
|
||||
@@ -369,19 +368,6 @@ void CefBrowserContext::RemoveCefRequestContext(
|
||||
delete this;
|
||||
}
|
||||
|
||||
CefRequestContextImpl* CefBrowserContext::GetCefRequestContext(
|
||||
bool impl_only) const {
|
||||
CEF_REQUIRE_UIT();
|
||||
// First try to find a non-proxy RequestContext.
|
||||
for (CefRequestContextImpl* impl : request_context_set_) {
|
||||
if (!impl->GetHandler())
|
||||
return impl;
|
||||
}
|
||||
if (impl_only)
|
||||
return nullptr;
|
||||
return *request_context_set_.begin();
|
||||
}
|
||||
|
||||
// static
|
||||
CefBrowserContext* CefBrowserContext::GetForCachePath(
|
||||
const base::FilePath& cache_path) {
|
||||
@@ -572,10 +558,6 @@ SimpleFactoryKey* CefBrowserContext::GetSimpleFactoryKey() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CefRequestContextImpl* CefBrowserContext::GetCefRequestContext() const {
|
||||
return GetCefRequestContext(false);
|
||||
}
|
||||
|
||||
const CefRequestContextSettings& CefBrowserContext::GetSettings() const {
|
||||
return settings_;
|
||||
}
|
||||
@@ -625,11 +607,44 @@ void CefBrowserContext::RebuildTable(
|
||||
enumerator->OnComplete(true);
|
||||
}
|
||||
|
||||
void CefBrowserContext::OnRenderFrameDeleted(int render_process_id,
|
||||
int render_frame_id,
|
||||
bool is_main_frame,
|
||||
bool is_guest_view) {
|
||||
void CefBrowserContext::OnRenderFrameCreated(
|
||||
CefRequestContextImpl* request_context,
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
bool is_main_frame,
|
||||
bool is_guest_view) {
|
||||
CEF_REQUIRE_UIT();
|
||||
CefRefPtr<CefRequestContextHandler> handler = request_context->GetHandler();
|
||||
if (handler && resource_context_) {
|
||||
DCHECK_GE(render_process_id, 0);
|
||||
// Using base::Unretained() is safe because both this callback and possible
|
||||
// deletion of |resource_context_| will execute on the IO thread, and this
|
||||
// callback will be executed first.
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
base::Bind(&CefResourceContext::AddHandler,
|
||||
base::Unretained(resource_context_.get()),
|
||||
render_process_id, render_frame_id, handler));
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContext::OnRenderFrameDeleted(
|
||||
CefRequestContextImpl* request_context,
|
||||
int render_process_id,
|
||||
int render_frame_id,
|
||||
bool is_main_frame,
|
||||
bool is_guest_view) {
|
||||
CEF_REQUIRE_UIT();
|
||||
CefRefPtr<CefRequestContextHandler> handler = request_context->GetHandler();
|
||||
if (handler && resource_context_) {
|
||||
DCHECK_GE(render_process_id, 0);
|
||||
// Using base::Unretained() is safe because both this callback and possible
|
||||
// deletion of |resource_context_| will execute on the IO thread, and this
|
||||
// callback will be executed first.
|
||||
CEF_POST_TASK(CEF_IOT, base::Bind(&CefResourceContext::RemoveHandler,
|
||||
base::Unretained(resource_context_.get()),
|
||||
render_process_id, render_frame_id));
|
||||
}
|
||||
|
||||
if (resource_context_ && is_main_frame) {
|
||||
DCHECK_GE(render_process_id, 0);
|
||||
// Using base::Unretained() is safe because both this callback and possible
|
||||
|
Reference in New Issue
Block a user