Fix finding the WebContents of a pending renderer process

Apparently after Chrome 44 a renderer process can be started before the
corresponding render view is created, though it can be patched but from
the source code Chromium is enforcing this everywhere now, so fixing it
on our side seems the only reliable solution.

This fix is very similar to what we did, but instead of blindly setting
swapped process, we now remember which process the pending process is
going to replace, so we should not have those race conditions.
This commit is contained in:
Cheng Zhao 2015-08-11 15:39:17 +08:00
parent 0f990d40cc
commit e6a2b0a479
2 changed files with 39 additions and 12 deletions

View file

@ -5,10 +5,12 @@
#ifndef ATOM_BROWSER_ATOM_BROWSER_CLIENT_H_
#define ATOM_BROWSER_ATOM_BROWSER_CLIENT_H_
#include <map>
#include <string>
#include <vector>
#include "brightray/browser/browser_client.h"
#include "content/public/browser/render_process_host_observer.h"
namespace content {
class QuotaPermissionContext;
@ -21,7 +23,8 @@ class SSLCertRequestInfo;
namespace atom {
class AtomBrowserClient : public brightray::BrowserClient {
class AtomBrowserClient : public brightray::BrowserClient,
public content::RenderProcessHostObserver {
public:
AtomBrowserClient();
virtual ~AtomBrowserClient();
@ -54,10 +57,17 @@ class AtomBrowserClient : public brightray::BrowserClient {
net::SSLCertRequestInfo* cert_request_info,
scoped_ptr<content::ClientCertificateDelegate> delegate) override;
private:
// brightray::BrowserClient:
brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
const content::MainFunctionParams&) override;
// content::RenderProcessHostObserver:
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
private:
// pending_render_process => current_render_process.
std::map<int, int> pending_processes_;
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
};