0

Rename FrameServiceBase to DocumentServiceBase.

As a comment in the header correctly says, FrameServiceBase is used for
implementing mojo-based services tied to a document lifetime.
Rename it to DocumentServiceBase to make the lifetime expectations
clear.

Also this patch updates the comment in DocumentServiceBase to refer to
"RenderFrameHost" instead of a "frame".

R=alexmos@chromium.org
BUG=1216208

Change-Id: I00796c02b637e6e407bad0a8c797f1ce3af71436
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2938442
Auto-Submit: Alexander Timin <altimin@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Owners-Override: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#889336}
This commit is contained in:
Alexander Timin
2021-06-04 16:55:41 +00:00
committed by Chromium LUCI CQ
parent 7d22a9b9b6
commit a085dd45b3
60 changed files with 155 additions and 152 deletions
chrome/browser
chromecast/browser
components/cdm/browser
content
fuchsia/engine/browser

@ -16,7 +16,7 @@
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/search/ntp_features.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_user_data.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
@ -82,13 +82,13 @@ void ConstructCartProto(cart_db::ChromeCartContentProto* proto,
// Implementation of the Mojo CommerceHintObserver. This is called by the
// renderer to notify the browser that a commerce hint happens.
class CommerceHintObserverImpl
: public content::FrameServiceBase<mojom::CommerceHintObserver> {
: public content::DocumentServiceBase<mojom::CommerceHintObserver> {
public:
explicit CommerceHintObserverImpl(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<mojom::CommerceHintObserver> receiver,
base::WeakPtr<CommerceHintService> service)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
binding_url_(render_frame_host->GetLastCommittedURL()),
service_(std::move(service)) {}
@ -166,7 +166,7 @@ void CommerceHintService::BindCommerceHintObserver(
content::RenderFrameHost* host,
mojo::PendingReceiver<mojom::CommerceHintObserver> receiver) {
// The object is bound to the lifetime of |host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new CommerceHintObserverImpl(host, std::move(receiver),
weak_factory_.GetWeakPtr());
}

@ -43,7 +43,7 @@ bool IsTrustedContext(content::RenderFrameHost* host,
DeviceServiceImpl::DeviceServiceImpl(
content::RenderFrameHost* host,
mojo::PendingReceiver<blink::mojom::DeviceAPIService> receiver)
: FrameServiceBase(host, std::move(receiver)), host_(host) {
: DocumentServiceBase(host, std::move(receiver)), host_(host) {
pref_change_registrar_.Init(
Profile::FromBrowserContext(host->GetBrowserContext())->GetPrefs());
pref_change_registrar_.Add(
@ -67,7 +67,7 @@ void DeviceServiceImpl::Create(
return;
}
// The object is bound to the lifetime of |host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new DeviceServiceImpl(host, std::move(receiver));
}

@ -6,7 +6,7 @@
#define CHROME_BROWSER_DEVICE_API_DEVICE_SERVICE_IMPL_H_
#include "components/prefs/pref_change_registrar.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "third_party/blink/public/mojom/device/device.mojom.h"
namespace content {
@ -16,7 +16,7 @@ class RenderFrameHost;
// A browser-side mojo service, which corresponds to the navigator.managed Web
// API. Available only to trusted web applications.
class DeviceServiceImpl final
: public content::FrameServiceBase<blink::mojom::DeviceAPIService> {
: public content::DocumentServiceBase<blink::mojom::DeviceAPIService> {
public:
// Tries to attach this mojo service to |host| for trusted web applications.
// Will dynamically disconnect if the trustness status is revoked.

@ -21,14 +21,14 @@ void ManagedConfigurationServiceImpl::Create(
}
// The object is bound to the lifetime of |host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new ManagedConfigurationServiceImpl(host, std::move(receiver));
}
ManagedConfigurationServiceImpl::ManagedConfigurationServiceImpl(
content::RenderFrameHost* host,
mojo::PendingReceiver<blink::mojom::ManagedConfigurationService> receiver)
: FrameServiceBase(host, std::move(receiver)), host_(host) {
: DocumentServiceBase(host, std::move(receiver)), host_(host) {
managed_configuration_api()->AddObserver(this);
}

@ -6,11 +6,11 @@
#define CHROME_BROWSER_DEVICE_API_MANAGED_CONFIGURATION_SERVICE_H_
#include "chrome/browser/device_api/managed_configuration_api.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "third_party/blink/public/mojom/device/device.mojom.h"
class ManagedConfigurationServiceImpl
: public content::FrameServiceBase<
: public content::DocumentServiceBase<
blink::mojom::ManagedConfigurationService>,
public ManagedConfigurationAPI::Observer {
public:

@ -151,7 +151,7 @@ void CreateMediaDrmStorage(
: base::BindRepeating(&CreateOriginId);
// The object will be deleted on connection error, or when the frame navigates
// away. See FrameServiceBase for details.
// away. See DocumentServiceBase for details.
new cdm::MediaDrmStorageImpl(
render_frame_host, pref_service, get_origin_id_cb,
base::BindRepeating(&AllowEmptyOriginId, render_frame_host),

@ -93,14 +93,14 @@ void CdmPrefServiceImpl::Create(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// The object is bound to the lifetime of `render_frame_host` and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new CdmPrefServiceImpl(render_frame_host, std::move(receiver));
}
CdmPrefServiceImpl::CdmPrefServiceImpl(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<media::mojom::CdmPrefService> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)) {}
: DocumentServiceBase(render_frame_host, std::move(receiver)) {}
CdmPrefServiceImpl::~CdmPrefServiceImpl() = default;

@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_MEDIA_CDM_PREF_SERVICE_IMPL_H_
#define CHROME_BROWSER_MEDIA_CDM_PREF_SERVICE_IMPL_H_
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "media/mojo/mojom/cdm_pref_service.mojom.h"
#include "url/origin.h"
@ -17,7 +17,7 @@ class PrefRegistrySimple;
// for origins serving hardware security protected contents and as such the size
// of the CDM Origin ID dictionary should only contain a handful of items.
class CdmPrefServiceImpl final
: public content::FrameServiceBase<media::mojom::CdmPrefService> {
: public content::DocumentServiceBase<media::mojom::CdmPrefService> {
public:
static void Create(
content::RenderFrameHost* render_frame_host,
@ -35,7 +35,7 @@ class CdmPrefServiceImpl final
CdmPrefServiceImpl(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<media::mojom::CdmPrefService> receiver);
// `this` can only be destructed as a FrameServiceBase
// `this` can only be destructed as a DocumentServiceBase
~CdmPrefServiceImpl() final;
};

@ -24,14 +24,14 @@ void OutputProtectionImpl::Create(
DCHECK(render_frame_host);
// The object is bound to the lifetime of |render_frame_host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new OutputProtectionImpl(render_frame_host, std::move(receiver));
}
OutputProtectionImpl::OutputProtectionImpl(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<media::mojom::OutputProtection> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
render_process_id_(render_frame_host->GetProcess()->GetID()),
render_frame_id_(render_frame_host->GetRoutingID()) {}

@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_MEDIA_OUTPUT_PROTECTION_IMPL_H_
#define CHROME_BROWSER_MEDIA_OUTPUT_PROTECTION_IMPL_H_
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "media/mojo/mojom/output_protection.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
@ -19,7 +19,7 @@ class RenderFrameHost;
// their statuses. On all platforms we'll check the network links. On ChromeOS
// we'll also check the hardware links. Can only be used on the UI thread.
class OutputProtectionImpl final
: public content::FrameServiceBase<media::mojom::OutputProtection> {
: public content::DocumentServiceBase<media::mojom::OutputProtection> {
public:
static void Create(
content::RenderFrameHost* render_frame_host,
@ -35,7 +35,7 @@ class OutputProtectionImpl final
EnableProtectionCallback callback) final;
private:
// |this| can only be destructed as a FrameServiceBase.
// |this| can only be destructed as a DocumentServiceBase.
~OutputProtectionImpl() final;
// Callbacks for QueryStatus and EnableProtection results.

@ -61,14 +61,14 @@ void PlatformVerificationImpl::Create(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// The object is bound to the lifetime of |render_frame_host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new PlatformVerificationImpl(render_frame_host, std::move(receiver));
}
PlatformVerificationImpl::PlatformVerificationImpl(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<media::mojom::PlatformVerification> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
render_frame_host_(render_frame_host) {}
PlatformVerificationImpl::~PlatformVerificationImpl() {

@ -10,7 +10,7 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "build/chromeos_buildflags.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "media/mojo/mojom/platform_verification.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
@ -21,7 +21,7 @@
// Implements media::mojom::PlatformVerification. Can only be used on the
// UI thread because PlatformVerificationFlow lives on the UI thread.
class PlatformVerificationImpl final
: public content::FrameServiceBase<media::mojom::PlatformVerification> {
: public content::DocumentServiceBase<media::mojom::PlatformVerification> {
public:
static void Create(
content::RenderFrameHost* render_frame_host,
@ -41,7 +41,7 @@ class PlatformVerificationImpl final
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
private:
// |this| can only be destructed as a FrameServiceBase.
// |this| can only be destructed as a DocumentServiceBase.
~PlatformVerificationImpl() final;
#if BUILDFLAG(IS_CHROMEOS_ASH)

@ -42,7 +42,7 @@ size_t kMaxClicksTracked = 10;
NavigationPredictor::NavigationPredictor(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<AnchorElementMetricsHost> receiver)
: content::FrameServiceBase<blink::mojom::AnchorElementMetricsHost>(
: content::DocumentServiceBase<blink::mojom::AnchorElementMetricsHost>(
render_frame_host,
std::move(receiver)) {
DETACH_FROM_SEQUENCE(sequence_checker_);
@ -75,7 +75,7 @@ void NavigationPredictor::Create(
}
// The object is bound to the lifetime of the |render_frame_host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new NavigationPredictor(render_frame_host, std::move(receiver));
}

@ -12,7 +12,7 @@
#include "base/macros.h"
#include "base/sequence_checker.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "content/public/browser/visibility.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
@ -32,8 +32,8 @@ class RenderFrameHost;
//
// This class derives from WebContentsObserver so that it can keep track of when
// WebContents is being destroyed via web_contents().
class NavigationPredictor
: public content::FrameServiceBase<blink::mojom::AnchorElementMetricsHost> {
class NavigationPredictor : public content::DocumentServiceBase<
blink::mojom::AnchorElementMetricsHost> {
public:
NavigationPredictor(content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<AnchorElementMetricsHost> receiver);

@ -35,7 +35,7 @@ class ChromeSpeculationHostDelegate : public content::SpeculationHostDelegate {
std::vector<blink::mojom::SpeculationCandidatePtr>& candidates) override;
private:
// content::SpeculationHostImpl, which inherits content::FrameServiceBase,
// content::SpeculationHostImpl, which inherits content::DocumentServiceBase,
// owns `this`, so `this` can access `render_frame_host_` safely.
content::RenderFrameHost& render_frame_host_;

@ -14,7 +14,7 @@
DraggableRegionsHostImpl::DraggableRegionsHostImpl(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<chrome::mojom::DraggableRegions> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)) {}
: DocumentServiceBase(render_frame_host, std::move(receiver)) {}
DraggableRegionsHostImpl::~DraggableRegionsHostImpl() = default;
@ -31,7 +31,7 @@ void DraggableRegionsHostImpl::CreateIfAllowed(
return;
// The object is bound to the lifetime of |render_frame_host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new DraggableRegionsHostImpl(render_frame_host, std::move(receiver));
}

@ -6,14 +6,14 @@
#define CHROME_BROWSER_UI_WEB_APPLICATIONS_DRAGGABLE_REGION_HOST_IMPL_H_
#include "chrome/common/draggable_regions.mojom.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
namespace content {
class RenderFrameHost;
}
class DraggableRegionsHostImpl
: public content::FrameServiceBase<chrome::mojom::DraggableRegions> {
: public content::DocumentServiceBase<chrome::mojom::DraggableRegions> {
public:
DraggableRegionsHostImpl(const DraggableRegionsHostImpl&) = delete;
DraggableRegionsHostImpl& operator=(const DraggableRegionsHostImpl&) = delete;

@ -21,7 +21,8 @@ void CreateApplicationMediaInfoManager(
mojo::PendingReceiver<::media::mojom::CastApplicationMediaInfoManager>
receiver) {
// The created ApplicationMediaInfoManager will be deleted on connection
// error, or when the frame navigates away. See FrameServiceBase for details.
// error, or when the frame navigates away. See DocumentServiceBase for
// details.
new ApplicationMediaInfoManager(render_frame_host, std::move(receiver),
std::move(application_session_id),
mixer_audio_enabled);
@ -33,7 +34,7 @@ ApplicationMediaInfoManager::ApplicationMediaInfoManager(
receiver,
std::string application_session_id,
bool mixer_audio_enabled)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
application_session_id_(std::move(application_session_id)),
mixer_audio_enabled_(mixer_audio_enabled),
renderer_blocked_(false) {

@ -10,7 +10,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "media/mojo/mojom/cast_application_media_info_manager.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
@ -24,7 +24,7 @@ namespace media {
class ApplicationMediaInfoManagerTest;
class ApplicationMediaInfoManager
: public ::content::FrameServiceBase<
: public ::content::DocumentServiceBase<
::media::mojom::CastApplicationMediaInfoManager>,
public base::SupportsWeakPtr<ApplicationMediaInfoManager> {
public:

@ -717,7 +717,7 @@ MediaDrmStorageImpl::MediaDrmStorageImpl(
GetOriginIdCB get_origin_id_cb,
AllowEmptyOriginIdCB allow_empty_origin_id_cb,
mojo::PendingReceiver<media::mojom::MediaDrmStorage> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
pref_service_(pref_service),
get_origin_id_cb_(get_origin_id_cb),
allow_empty_origin_id_cb_(allow_empty_origin_id_cb) {

@ -15,7 +15,7 @@
#include "base/time/time.h"
#include "base/unguessable_token.h"
#include "build/build_config.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents_observer.h"
#include "media/mojo/mojom/media_drm_storage.mojom.h"
@ -43,7 +43,7 @@ extern const char kMediaDrmStorage[];
// This file is located under components/ so that it can be shared by multiple
// content embedders (e.g. chrome and chromecast).
class MediaDrmStorageImpl final
: public content::FrameServiceBase<media::mojom::MediaDrmStorage> {
: public content::DocumentServiceBase<media::mojom::MediaDrmStorage> {
public:
// When using per-origin provisioning, this is the ID for the origin.
// If not specified, the device specific origin ID is to be used.
@ -125,7 +125,7 @@ class MediaDrmStorageImpl final
RemovePersistentSessionCallback callback) final;
private:
// |this| can only be destructed as a FrameServiceBase.
// |this| can only be destructed as a DocumentServiceBase.
~MediaDrmStorageImpl() final;
// Called when |get_origin_id_cb_| asynchronously returns a origin ID as part

@ -43,7 +43,7 @@
#include "content/common/content_navigation_policy.h"
#include "content/common/render_accessibility.mojom.h"
#include "content/public/browser/back_forward_cache.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/idle_manager.h"
#include "content/public/browser/media_session.h"
@ -9005,13 +9005,13 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
namespace {
// Subclass of FrameServiceBase for test.
class EchoImpl final : public FrameServiceBase<mojom::Echo> {
// Subclass of DocumentServiceBase for test.
class EchoImpl final : public DocumentServiceBase<mojom::Echo> {
public:
EchoImpl(RenderFrameHost* render_frame_host,
mojo::PendingReceiver<mojom::Echo> receiver,
bool* deleted)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
deleted_(deleted) {}
~EchoImpl() final { *deleted_ = true; }
@ -9026,7 +9026,7 @@ class EchoImpl final : public FrameServiceBase<mojom::Echo> {
} // namespace
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, FrameServiceBase) {
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DocumentServiceBase) {
ASSERT_TRUE(embedded_test_server()->Start());
GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html"));
GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html"));

@ -39,7 +39,7 @@ void EyeDropperChooserImpl::Create(
EyeDropperChooserImpl::EyeDropperChooserImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::EyeDropperChooser> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)) {}
: DocumentServiceBase(render_frame_host, std::move(receiver)) {}
EyeDropperChooserImpl::~EyeDropperChooserImpl() {
if (callback_)

@ -7,8 +7,8 @@
#include <memory>
#include "content/public/browser/document_service_base.h"
#include "content/public/browser/eye_dropper_listener.h"
#include "content/public/browser/frame_service_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/choosers/color_chooser.mojom.h"
@ -18,7 +18,7 @@ class EyeDropper;
class EyeDropperListener;
class EyeDropperChooserImpl final
: public FrameServiceBase<blink::mojom::EyeDropperChooser>,
: public DocumentServiceBase<blink::mojom::EyeDropperChooser>,
public EyeDropperListener {
public:
static void Create(RenderFrameHost*,

@ -16,7 +16,7 @@ namespace content {
FlocServiceImpl::FlocServiceImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::FlocService> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
render_frame_host_(static_cast<RenderFrameHostImpl*>(render_frame_host)) {
DCHECK(render_frame_host_);
}
@ -28,7 +28,7 @@ void FlocServiceImpl::CreateMojoService(
DCHECK(render_frame_host);
// The object is bound to the lifetime of |render_frame_host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new FlocServiceImpl(render_frame_host, std::move(receiver));
}

@ -6,7 +6,7 @@
#define CONTENT_BROWSER_FEDERATED_LEARNING_FLOC_SERVICE_IMPL_H_
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/federated_learning/floc.mojom.h"
@ -16,7 +16,7 @@ class RenderFrameHost;
class RenderFrameHostImpl;
class CONTENT_EXPORT FlocServiceImpl final
: public FrameServiceBase<blink::mojom::FlocService> {
: public DocumentServiceBase<blink::mojom::FlocService> {
public:
FlocServiceImpl(RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::FlocService> receiver);
@ -29,7 +29,7 @@ class CONTENT_EXPORT FlocServiceImpl final
void GetInterestCohort(GetInterestCohortCallback callback) override;
private:
// |this| can only be destroyed by FrameServiceBase.
// |this| can only be destroyed by DocumentServiceBase.
~FlocServiceImpl() override;
RenderFrameHostImpl* const render_frame_host_;

@ -70,7 +70,7 @@ void RemoveProtectedReports(device::mojom::HidDeviceInfo& device) {
HidService::HidService(RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::HidService> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
origin_(render_frame_host->GetMainFrame()->GetLastCommittedOrigin()) {
watchers_.set_disconnect_handler(
base::BindRepeating(&HidService::OnWatcherRemoved, base::Unretained(this),

@ -10,7 +10,7 @@
#include <vector>
#include "base/memory/weak_ptr.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "content/public/browser/hid_delegate.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
@ -26,9 +26,10 @@ class RenderFrameHost;
// HidService provides an implementation of the HidService mojom interface. This
// interface is used by Blink to implement the WebHID API.
class HidService : public content::FrameServiceBase<blink::mojom::HidService>,
public device::mojom::HidConnectionWatcher,
public HidDelegate::Observer {
class HidService
: public content::DocumentServiceBase<blink::mojom::HidService>,
public device::mojom::HidConnectionWatcher,
public HidDelegate::Observer {
public:
HidService(HidService&) = delete;
HidService& operator=(HidService&) = delete;

@ -151,7 +151,7 @@ void ImageCaptureImpl::TakePhoto(const std::string& source_id,
ImageCaptureImpl::ImageCaptureImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<media::mojom::ImageCapture> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)) {}
: DocumentServiceBase(render_frame_host, std::move(receiver)) {}
ImageCaptureImpl::~ImageCaptureImpl() = default;

@ -6,14 +6,14 @@
#define CONTENT_BROWSER_IMAGE_CAPTURE_IMAGE_CAPTURE_IMPL_H_
#include "base/memory/weak_ptr.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "media/capture/mojom/image_capture.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace content {
class ImageCaptureImpl final
: public content::FrameServiceBase<media::mojom::ImageCapture> {
: public content::DocumentServiceBase<media::mojom::ImageCapture> {
public:
static void Create(
RenderFrameHost* render_frame_host,

@ -130,7 +130,7 @@ bool IsAuctionValid(const blink::mojom::AuctionAdConfig& config) {
AdAuctionServiceImpl::AdAuctionServiceImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::AdAuctionService> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)) {}
: DocumentServiceBase(render_frame_host, std::move(receiver)) {}
AdAuctionServiceImpl::~AdAuctionServiceImpl() = default;
@ -141,7 +141,7 @@ void AdAuctionServiceImpl::CreateMojoService(
DCHECK(render_frame_host);
// The object is bound to the lifetime of `render_frame_host` and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new AdAuctionServiceImpl(render_frame_host, std::move(receiver));
}

@ -12,7 +12,7 @@
#include "content/browser/interest_group/auction_runner.h"
#include "content/browser/interest_group/interest_group_manager.h"
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "content/services/auction_worklet/public/mojom/auction_worklet_service.mojom-forward.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
@ -29,7 +29,7 @@ class RenderFrameHost;
// Implements the AdAuctionService service called by Blink code.
class CONTENT_EXPORT AdAuctionServiceImpl final
: public FrameServiceBase<blink::mojom::AdAuctionService>,
: public DocumentServiceBase<blink::mojom::AdAuctionService>,
public AuctionRunner::Delegate {
public:
// Factory method for creating an instance of this interface that is
@ -47,17 +47,17 @@ class CONTENT_EXPORT AdAuctionServiceImpl final
network::mojom::URLLoaderFactory* GetTrustedURLLoaderFactory() override;
auction_worklet::mojom::AuctionWorkletService* GetWorkletService() override;
using FrameServiceBase::origin;
using FrameServiceBase::render_frame_host;
using DocumentServiceBase::origin;
using DocumentServiceBase::render_frame_host;
private:
// `render_frame_host` must not be null, and FrameServiceBase guarantees
// `render_frame_host` must not be null, and DocumentServiceBase guarantees
// `this` will not outlive the `render_frame_host`.
AdAuctionServiceImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::AdAuctionService> receiver);
// `this` can only be destroyed by FrameServiceBase.
// `this` can only be destroyed by DocumentServiceBase.
~AdAuctionServiceImpl() override;
// Deletes `auction`.

@ -42,7 +42,7 @@ bool IsUrlAllowed(const GURL& url, const blink::mojom::InterestGroup& group) {
InterestGroupServiceImpl::InterestGroupServiceImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::RestrictedInterestGroupStore> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
interest_group_manager_(*static_cast<StoragePartitionImpl*>(
render_frame_host->GetStoragePartition())
->GetInterestGroupStorage()) {}
@ -55,7 +55,7 @@ void InterestGroupServiceImpl::CreateMojoService(
DCHECK(render_frame_host);
// The object is bound to the lifetime of |render_frame_host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new InterestGroupServiceImpl(render_frame_host, std::move(receiver));
}

@ -7,7 +7,7 @@
#include "content/browser/interest_group/interest_group_manager.h"
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/interest_group/restricted_interest_group_store.mojom.h"
@ -17,7 +17,7 @@ class RenderFrameHost;
// Implements the RestrictedInterestGroupStore service called by Blink code.
class CONTENT_EXPORT InterestGroupServiceImpl final
: public FrameServiceBase<blink::mojom::RestrictedInterestGroupStore> {
: public DocumentServiceBase<blink::mojom::RestrictedInterestGroupStore> {
public:
// Factory method for creating an instance of this interface that is bound
// to the lifetime of the frame or receiver (whichever is shorter).
@ -32,14 +32,14 @@ class CONTENT_EXPORT InterestGroupServiceImpl final
const std::string& name) override;
private:
// `render_frame_host` must not be null, and FrameServiceBase guarantees
// `render_frame_host` must not be null, and DocumentServiceBase guarantees
// `this` will not outlive the `render_frame_host`.
InterestGroupServiceImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::RestrictedInterestGroupStore>
receiver);
// `this` can only be destroyed by FrameServiceBase.
// `this` can only be destroyed by DocumentServiceBase.
~InterestGroupServiceImpl() override;
InterestGroupManager& interest_group_manager_;

@ -40,7 +40,7 @@ void LogKeyboardLockMethodCalled(KeyboardLockMethods method) {
KeyboardLockServiceImpl::KeyboardLockServiceImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::KeyboardLockService> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
render_frame_host_(static_cast<RenderFrameHostImpl*>(render_frame_host)) {
DCHECK(render_frame_host_);
}
@ -52,7 +52,7 @@ void KeyboardLockServiceImpl::CreateMojoService(
DCHECK(render_frame_host);
// The object is bound to the lifetime of |render_frame_host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new KeyboardLockServiceImpl(render_frame_host, std::move(receiver));
}

@ -9,7 +9,7 @@
#include <vector>
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/keyboard_lock/keyboard_lock.mojom.h"
@ -19,7 +19,7 @@ class RenderFrameHost;
class RenderFrameHostImpl;
class CONTENT_EXPORT KeyboardLockServiceImpl final
: public FrameServiceBase<blink::mojom::KeyboardLockService> {
: public DocumentServiceBase<blink::mojom::KeyboardLockService> {
public:
KeyboardLockServiceImpl(
RenderFrameHost* render_frame_host,
@ -36,7 +36,7 @@ class CONTENT_EXPORT KeyboardLockServiceImpl final
void GetKeyboardLayoutMap(GetKeyboardLayoutMapCallback callback) override;
private:
// |this| can only be destroyed by FrameServiceBase.
// |this| can only be destroyed by DocumentServiceBase.
~KeyboardLockServiceImpl() override;
RenderFrameHostImpl* const render_frame_host_;

@ -77,7 +77,7 @@ CdmStorageImpl::CdmStorageImpl(
const std::string& cdm_file_system_id,
scoped_refptr<storage::FileSystemContext> file_system_context,
mojo::PendingReceiver<media::mojom::CdmStorage> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
cdm_file_system_id_(cdm_file_system_id),
file_system_context_(std::move(file_system_context)),
child_process_id_(render_frame_host->GetProcess()->GetID()) {}

@ -14,7 +14,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "media/mojo/mojom/cdm_storage.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/unique_associated_receiver_set.h"
@ -31,7 +31,7 @@ class RenderFrameHost;
// PluginPrivateFileSystem for backwards compatibility with CDMs running
// as a pepper plugin.
class CONTENT_EXPORT CdmStorageImpl final
: public content::FrameServiceBase<media::mojom::CdmStorage> {
: public content::DocumentServiceBase<media::mojom::CdmStorage> {
public:
// Check if |cdm_file_system_id| is valid.

@ -35,14 +35,14 @@ void AudioContextManagerImpl::Create(
DCHECK(render_frame_host);
// The object is bound to the lifetime of |render_frame_host| and the mojo
// connection. See FrameServiceBase for details.
// connection. See DocumentServiceBase for details.
new AudioContextManagerImpl(render_frame_host, std::move(receiver));
}
AudioContextManagerImpl::AudioContextManagerImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::AudioContextManager> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
render_frame_host_impl_(
static_cast<RenderFrameHostImpl*>(render_frame_host)),
clock_(base::DefaultTickClock::GetInstance()) {

@ -6,7 +6,7 @@
#define CONTENT_BROWSER_MEDIA_WEBAUDIO_AUDIO_CONTEXT_MANAGER_IMPL_H_
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/webaudio/audio_context_manager.mojom.h"
@ -26,7 +26,7 @@ class RenderFrameHostImpl;
// We do not expect to see more than 3~4 AudioContexts per render frame, so
// handling multiple contexts would not be a significant bottle neck.
class CONTENT_EXPORT AudioContextManagerImpl final
: public content::FrameServiceBase<blink::mojom::AudioContextManager> {
: public content::DocumentServiceBase<blink::mojom::AudioContextManager> {
public:
explicit AudioContextManagerImpl(
RenderFrameHost* render_frame_host,

@ -65,7 +65,7 @@ void PictureInPictureServiceImpl::StartSession(
PictureInPictureServiceImpl::PictureInPictureServiceImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::PictureInPictureService> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)) {}
: DocumentServiceBase(render_frame_host, std::move(receiver)) {}
PictureInPictureServiceImpl::~PictureInPictureServiceImpl() {
// If the service is destroyed because the frame was destroyed, the session

@ -6,7 +6,7 @@
#define CONTENT_BROWSER_PICTURE_IN_PICTURE_PICTURE_IN_PICTURE_SERVICE_IMPL_H_
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "media/mojo/mojom/media_player.mojom.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
@ -24,9 +24,10 @@ class PictureInPictureWindowControllerImpl;
// killed given that the PictureInPictureWindowControllerImpl is
// WebContents-bound instead of RenderFrameHost.
// PictureInPictureServiceImpl owns itself. It self-destruct as needed, see the
// FrameServiceBase's documentation for more information.
// DocumentServiceBase's documentation for more information.
class CONTENT_EXPORT PictureInPictureServiceImpl final
: public content::FrameServiceBase<blink::mojom::PictureInPictureService> {
: public content::DocumentServiceBase<
blink::mojom::PictureInPictureService> {
public:
static void Create(
RenderFrameHost*,

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "base/bind.h"
#include "base/run_loop.h"
@ -17,7 +17,7 @@
#include "mojo/public/cpp/bindings/remote.h"
#include "url/gurl.h"
// Unit test for FrameServiceBase in content/public/browser.
// Unit test for DocumentServiceBase in content/public/browser.
namespace content {
@ -26,13 +26,13 @@ namespace {
const char kFooOrigin[] = "https://foo.com";
const char kBarOrigin[] = "https://bar.com";
// Subclass of FrameServiceBase for test.
class EchoImpl final : public FrameServiceBase<mojom::Echo> {
// Subclass of DocumentServiceBase for test.
class EchoImpl final : public DocumentServiceBase<mojom::Echo> {
public:
EchoImpl(RenderFrameHost* render_frame_host,
mojo::PendingReceiver<mojom::Echo> receiver,
base::OnceClosure destruction_cb)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
destruction_cb_(std::move(destruction_cb)) {}
~EchoImpl() final { std::move(destruction_cb_).Run(); }
@ -67,7 +67,7 @@ void DetachFrame(RenderFrameHost* rfh) {
} // namespace
class FrameServiceBaseTest : public RenderViewHostTestHarness {
class DocumentServiceBaseTest : public RenderViewHostTestHarness {
protected:
void SetUp() final {
RenderViewHostTestHarness::SetUp();
@ -83,7 +83,7 @@ class FrameServiceBaseTest : public RenderViewHostTestHarness {
void CreateEchoImpl(RenderFrameHost* rfh) {
DCHECK(!is_echo_impl_alive_);
new EchoImpl(rfh, echo_remote_.BindNewPipeAndPassReceiver(),
base::BindOnce(&FrameServiceBaseTest::OnEchoImplDestructed,
base::BindOnce(&DocumentServiceBaseTest::OnEchoImplDestructed,
base::Unretained(this)));
is_echo_impl_alive_ = true;
}
@ -103,13 +103,13 @@ class FrameServiceBaseTest : public RenderViewHostTestHarness {
bool is_echo_impl_alive_ = false;
};
TEST_F(FrameServiceBaseTest, ConnectionError) {
TEST_F(DocumentServiceBaseTest, ConnectionError) {
CreateEchoImpl(main_rfh_);
ResetConnection();
EXPECT_FALSE(is_echo_impl_alive_);
}
TEST_F(FrameServiceBaseTest, RenderFrameDeleted) {
TEST_F(DocumentServiceBaseTest, RenderFrameDeleted) {
// Needs to create a child frame so we can delete it using DetachFrame()
// because it is not allowed to detach the main frame.
RenderFrameHost* child_rfh = AddChildFrame(main_rfh_, GURL(kBarOrigin));
@ -118,7 +118,7 @@ TEST_F(FrameServiceBaseTest, RenderFrameDeleted) {
EXPECT_FALSE(is_echo_impl_alive_);
}
TEST_F(FrameServiceBaseTest, DidFinishNavigation) {
TEST_F(DocumentServiceBaseTest, DidFinishNavigation) {
// When a page enters the BackForwardCache, the RenderFrameHost is not
// deleted.
web_contents()->GetController().GetBackForwardCache().DisableForTesting(
@ -128,7 +128,7 @@ TEST_F(FrameServiceBaseTest, DidFinishNavigation) {
EXPECT_FALSE(is_echo_impl_alive_);
}
TEST_F(FrameServiceBaseTest, SameDocumentNavigation) {
TEST_F(DocumentServiceBaseTest, SameDocumentNavigation) {
CreateEchoImpl(main_rfh_);
// Must use the same origin to simulate same document navigation.
@ -140,7 +140,7 @@ TEST_F(FrameServiceBaseTest, SameDocumentNavigation) {
EXPECT_TRUE(is_echo_impl_alive_);
}
TEST_F(FrameServiceBaseTest, FailedNavigation) {
TEST_F(DocumentServiceBaseTest, FailedNavigation) {
CreateEchoImpl(main_rfh_);
auto navigation_simulator =
@ -151,7 +151,7 @@ TEST_F(FrameServiceBaseTest, FailedNavigation) {
EXPECT_FALSE(is_echo_impl_alive_);
}
TEST_F(FrameServiceBaseTest, DeleteContents) {
TEST_F(DocumentServiceBaseTest, DeleteContents) {
CreateEchoImpl(main_rfh_);
DeleteContents();
EXPECT_FALSE(is_echo_impl_alive_);

@ -88,7 +88,7 @@ WebOTPService::WebOTPService(
const OriginList& origin_list,
RenderFrameHost* host,
mojo::PendingReceiver<blink::mojom::WebOTPService> receiver)
: FrameServiceBase(host, std::move(receiver)),
: DocumentServiceBase(host, std::move(receiver)),
fetcher_(fetcher),
origin_list_(origin_list),
timeout_timer_(FROM_HERE,

@ -17,7 +17,7 @@
#include "content/browser/sms/sms_queue.h"
#include "content/browser/sms/user_consent_handler.h"
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/sms/webotp_service.mojom.h"
#include "url/origin.h"
@ -31,11 +31,11 @@ struct LoadCommittedDetails;
// WebOTPService handles mojo connections from the renderer, observing the
// incoming SMS messages from an SmsFetcher. In practice, it is owned and
// managed by a RenderFrameHost. It accomplishes that via subclassing
// FrameServiceBase, which observes the lifecycle of a RenderFrameHost and
// DocumentServiceBase, which observes the lifecycle of a RenderFrameHost and
// manages it own memory. Create() creates a self-managed instance of
// WebOTPService and binds it to the request.
class CONTENT_EXPORT WebOTPService
: public FrameServiceBase<blink::mojom::WebOTPService>,
: public DocumentServiceBase<blink::mojom::WebOTPService>,
public SmsFetcher::Subscriber {
public:
// Return value indicates success. Creation can fail if origin requirements

@ -50,14 +50,14 @@ void SpeculationHostImpl::Bind(
return;
}
// FrameServiceBase will destroy this on pipe closure or frame destruction.
// DocumentServiceBase will destroy this on pipe closure or frame destruction.
new SpeculationHostImpl(frame_host, std::move(receiver));
}
SpeculationHostImpl::SpeculationHostImpl(
RenderFrameHost* frame_host,
mojo::PendingReceiver<blink::mojom::SpeculationHost> receiver)
: FrameServiceBase(frame_host, std::move(receiver)) {
: DocumentServiceBase(frame_host, std::move(receiver)) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
delegate_ = GetContentClient()->browser()->CreateSpeculationHostDelegate(
*render_frame_host());

@ -8,7 +8,7 @@
#include <vector>
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "content/public/browser/speculation_host_delegate.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/speculation_rules/speculation_rules.mojom.h"
@ -20,7 +20,7 @@ class PrerenderProcessor;
// Receiver for speculation rules from the web platform. See
// third_party/blink/renderer/core/speculation_rules/README.md
class CONTENT_EXPORT SpeculationHostImpl final
: public content::FrameServiceBase<blink::mojom::SpeculationHost> {
: public content::DocumentServiceBase<blink::mojom::SpeculationHost> {
public:
// Creates and binds an instance of this per-frame.
static void Bind(

@ -36,6 +36,6 @@ void WakeLockServiceImpl::GetWakeLock(
WakeLockServiceImpl::WakeLockServiceImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::WakeLockService> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)) {}
: DocumentServiceBase(render_frame_host, std::move(receiver)) {}
} // namespace content

@ -5,14 +5,14 @@
#ifndef CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_
#define CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_IMPL_H_
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/wake_lock/wake_lock.mojom.h"
namespace content {
class WakeLockServiceImpl final
: public FrameServiceBase<blink::mojom::WakeLockService> {
: public DocumentServiceBase<blink::mojom::WakeLockService> {
public:
static void Create(RenderFrameHost*,
mojo::PendingReceiver<blink::mojom::WakeLockService>);

@ -10,7 +10,7 @@
#include "base/timer/timer.h"
#include "content/browser/webauth/authenticator_common.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
@ -28,7 +28,7 @@ void AuthenticatorImpl::Create(
}
// AuthenticatorImpl owns itself. It self-destructs when the RenderFrameHost
// navigates or is deleted. See FrameServiceBase for details.
// navigates or is deleted. See DocumentServiceBase for details.
DCHECK(render_frame_host);
new AuthenticatorImpl(
render_frame_host, std::move(receiver),
@ -39,7 +39,7 @@ AuthenticatorImpl::AuthenticatorImpl(
RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::Authenticator> receiver,
std::unique_ptr<AuthenticatorCommon> authenticator_common)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
authenticator_common_(std::move(authenticator_common)) {
DCHECK(authenticator_common_);
}

@ -11,7 +11,7 @@
#include "base/macros.h"
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "third_party/blink/public/mojom/webauthn/authenticator.mojom.h"
@ -41,7 +41,7 @@ class RenderFrameHost;
// Implementation of the public Authenticator interface.
class CONTENT_EXPORT AuthenticatorImpl
: public FrameServiceBase<blink::mojom::Authenticator> {
: public DocumentServiceBase<blink::mojom::Authenticator> {
public:
static void Create(
RenderFrameHost* render_frame_host,

@ -25,7 +25,7 @@ namespace content {
FederatedAuthRequestImpl::FederatedAuthRequestImpl(
RenderFrameHost* host,
mojo::PendingReceiver<blink::mojom::FederatedAuthRequest> receiver)
: FrameServiceBase(host, std::move(receiver)) {}
: DocumentServiceBase(host, std::move(receiver)) {}
FederatedAuthRequestImpl::~FederatedAuthRequestImpl() {
// Ensures key data members are destructed in proper order and resolves any
@ -43,7 +43,7 @@ void FederatedAuthRequestImpl::Create(
// the mojo method is invoked, causing the promise to be rejected.
// https://crbug.com/1141125
// It is safe to access host->GetLastCommittedOrigin during construction
// but FrameServiceBase::origin() should be used thereafter.
// but DocumentServiceBase::origin() should be used thereafter.
if (!IsSameOriginWithAncestors(host, host->GetLastCommittedOrigin())) {
mojo::ReportBadMessage(
"navigator.id.get cannot be invoked from within cross-origin iframes.");

@ -13,7 +13,7 @@
#include "base/macros.h"
#include "content/browser/webid/idp_network_request_manager.h"
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "content/public/browser/identity_request_dialog_controller.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/webid/federated_auth_request.mojom.h"
@ -29,12 +29,12 @@ class RenderFrameHost;
// fulfill WebID-related requests.
//
// In practice, it is owned and managed by a RenderFrameHost. It accomplishes
// that via subclassing FrameServiceBase, which observes the lifecycle of a
// that via subclassing DocumentServiceBase, which observes the lifecycle of a
// RenderFrameHost and manages its own memory.
// Create() creates a self-managed instance of FederatedAuthRequestImpl and
// binds it to the receiver.
class CONTENT_EXPORT FederatedAuthRequestImpl
: public FrameServiceBase<blink::mojom::FederatedAuthRequest> {
: public DocumentServiceBase<blink::mojom::FederatedAuthRequest> {
public:
static void Create(RenderFrameHost*,
mojo::PendingReceiver<blink::mojom::FederatedAuthRequest>);

@ -18,7 +18,7 @@ namespace content {
FederatedAuthResponseImpl::FederatedAuthResponseImpl(
RenderFrameHost* host,
mojo::PendingReceiver<blink::mojom::FederatedAuthResponse> receiver)
: FrameServiceBase(host, std::move(receiver)) {}
: DocumentServiceBase(host, std::move(receiver)) {}
// TODO(majidvp): We should reject any pending promise here.
// http://crbug.com/1141125
@ -34,7 +34,7 @@ void FederatedAuthResponseImpl::Create(
// the mojo method is invoked, causing the promise to be rejected.
// https://crbug.com/1141125
// It is safe to access host->GetLastCommittedOrigin during construction
// but FrameServiceBase::origin() should be used thereafter.
// but DocumentServiceBase::origin() should be used thereafter.
if (!IsSameOriginWithAncestors(host, host->GetLastCommittedOrigin())) {
mojo::ReportBadMessage(
"WebID cannot be invoked from within cross-origin iframes.");

@ -11,7 +11,7 @@
#include "base/callback_forward.h"
#include "base/macros.h"
#include "content/common/content_export.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/mojom/webid/federated_auth_response.mojom.h"
@ -22,7 +22,7 @@ class RenderFrameHost;
// FederatedAuthResponseImpl handles mojo connections from the renderer to
// fulfill WebID-related response by an IDP.
class FederatedAuthResponseImpl
: public FrameServiceBase<blink::mojom::FederatedAuthResponse> {
: public DocumentServiceBase<blink::mojom::FederatedAuthResponse> {
public:
// Creates a self-managed instance of FederatedAuthResponseImpl and binds it
// to the receiver.

@ -14,8 +14,8 @@ class RenderFrameHost;
// Determines whether |host| is same-origin with all of its ancestors in the
// frame tree. Returns false if not.
// |origin| is provided because it is not considered safe to use
// host->GetLastCommittedOrigin() at some times, so FrameServiceBase::origin()
// should be used to obtain the frame's origin.
// host->GetLastCommittedOrigin() at some times, so
// DocumentServiceBase::origin() should be used to obtain the frame's origin.
bool IsSameOriginWithAncestors(RenderFrameHost* host,
const url::Origin& origin);

@ -140,6 +140,7 @@ source_set("browser_sources") {
"devtools_permission_overrides.cc",
"devtools_permission_overrides.h",
"devtools_socket_factory.h",
"document_service_base.h",
"dom_storage_context.h",
"download_item_utils.h",
"download_manager.cc",
@ -170,7 +171,6 @@ source_set("browser_sources") {
"font_list_async.h",
"frame_accept_header.cc",
"frame_accept_header.h",
"frame_service_base.h",
"generated_code_cache_settings.h",
"global_request_id.cc",
"global_request_id.h",

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_FRAME_SERVICE_BASE_H_
#define CONTENT_PUBLIC_BROWSER_FRAME_SERVICE_BASE_H_
#ifndef CONTENT_PUBLIC_BROWSER_DOCUMENT_SERVICE_BASE_H_
#define CONTENT_PUBLIC_BROWSER_DOCUMENT_SERVICE_BASE_H_
#include <utility>
@ -33,10 +33,10 @@ class RenderFrameHost;
// origin() instead of from |render_frame_host| passed in the constructor.
// See https://crbug.com/769189 for an example of such a race.
template <typename Interface>
class FrameServiceBase : public Interface, public WebContentsObserver {
class DocumentServiceBase : public Interface, public WebContentsObserver {
public:
FrameServiceBase(RenderFrameHost* render_frame_host,
mojo::PendingReceiver<Interface> pending_receiver)
DocumentServiceBase(RenderFrameHost* render_frame_host,
mojo::PendingReceiver<Interface> pending_receiver)
: WebContentsObserver(
WebContents::FromRenderFrameHost(render_frame_host)),
render_frame_host_(render_frame_host),
@ -44,12 +44,12 @@ class FrameServiceBase : public Interface, public WebContentsObserver {
receiver_(this, std::move(pending_receiver)) {
// |this| owns |receiver_|, so unretained is safe.
receiver_.set_disconnect_handler(
base::BindOnce(&FrameServiceBase::Close, base::Unretained(this)));
base::BindOnce(&DocumentServiceBase::Close, base::Unretained(this)));
}
protected:
// Make the destructor private since |this| can only be deleted by Close().
virtual ~FrameServiceBase() = default;
virtual ~DocumentServiceBase() = default;
// All subclasses should use this function to obtain the origin instead of
// trying to get it from the RenderFrameHost pointer directly.
@ -64,8 +64,8 @@ class FrameServiceBase : public Interface, public WebContentsObserver {
private:
// Disallow calling web_contents() directly from the subclasses to ensure that
// tab-level state doesn't get queried or updated when the frame is
// not current.
// tab-level state doesn't get queried or updated when the RenderFrameHost is
// not active.
// Use WebContents::From(render_frame_host()) instead, but please keep in mind
// that the render_frame_host() might not be active. See
// RenderFrameHost::IsActive() for details.
@ -110,4 +110,4 @@ class FrameServiceBase : public Interface, public WebContentsObserver {
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_FRAME_SERVICE_BASE_H_
#endif // CONTENT_PUBLIC_BROWSER_DOCUMENT_SERVICE_BASE_H_

@ -2028,8 +2028,8 @@ test("content_unittests") {
"../browser/renderer_host/clipboard_host_impl_unittest.cc",
"../browser/renderer_host/commit_deferring_condition_runner_unittest.cc",
"../browser/renderer_host/cursor_manager_unittest.cc",
"../browser/renderer_host/document_service_base_unittest.cc",
"../browser/renderer_host/embedded_frame_sink_provider_impl_unittest.cc",
"../browser/renderer_host/frame_service_base_unittest.cc",
"../browser/renderer_host/frame_token_message_queue_unittest.cc",
"../browser/renderer_host/frame_tree_node_blame_context_unittest.cc",
"../browser/renderer_host/frame_tree_unittest.cc",

@ -12,7 +12,7 @@
#include "base/files/file_path.h"
#include "base/fuchsia/process_context.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/frame_service_base.h"
#include "content/public/browser/document_service_base.h"
#include "content/public/browser/provision_fetcher_factory.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
@ -27,7 +27,7 @@
namespace {
class MediaResourceProviderImpl
: public content::FrameServiceBase<
: public content::DocumentServiceBase<
media::mojom::FuchsiaMediaResourceProvider> {
public:
MediaResourceProviderImpl(
@ -59,7 +59,7 @@ MediaResourceProviderImpl::MediaResourceProviderImpl(
media::FuchsiaCdmManager* cdm_manager,
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<media::mojom::FuchsiaMediaResourceProvider> receiver)
: FrameServiceBase(render_frame_host, std::move(receiver)),
: DocumentServiceBase(render_frame_host, std::move(receiver)),
cdm_manager_(cdm_manager) {
DCHECK(cdm_manager_);
}