blob: bce85dab80566c5336a4669ad0dd2704af6307b5 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "chromecast/browser/renderer_config.h"
#include "ipc/ipc_listener.h"
#include "url/gurl.h"
namespace content {
class BrowserContext;
class RenderProcessHost;
class SiteInstance;
} // namespace content
namespace chromecast {
// This class pre-launches a renderer process for the SiteInstance of a URL,
// and retains a handle on its RenderProcessHost to keep it alive even when
// there is no WebContents using the renderer process. To release the
// RenderProcessHost, this class must be deleted.
class RendererPrelauncher : private IPC::Listener {
RendererPrelauncher(content::BrowserContext* browser_context,
shell::RendererConfigurator renderer_configurator,
const GURL& gurl);
~RendererPrelauncher() override;
virtual void Prelaunch();
bool IsForURL(const GURL& gurl) const;
const GURL& url() const { return gurl_; }
scoped_refptr<content::SiteInstance> site_instance() const {
return site_instance_;
// IPC::Listener implementation:
bool OnMessageReceived(const IPC::Message& message) override;
content::BrowserContext* const browser_context_;
shell::RendererConfigurator renderer_configurator_;
scoped_refptr<content::SiteInstance> site_instance_;
const GURL gurl_;
int32_t rph_routing_id_;
} // namespace chromecast