blob: eb17e8ba36ead9c180923b4afb9c6ebab208fa15 [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 "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,
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_;
scoped_refptr<content::SiteInstance> site_instance_;
const GURL gurl_;
int32_t rph_routing_id_;
} // namespace chromecast