Commit e0c15284 authored by Hidehiko Abe's avatar Hidehiko Abe Committed by Chromium LUCI CQ

Rename AshChromeService to Crosapi.

In order to make crosapi more isolated from actual ash/lacros
implementations, this CL renames AshChromeService and its
corresponding variables to Crosapi.
Also, AshChromeServiceImpl is renamed to CrosapiAsh,
following the common naming convention in Chrome that
it is the crosapi implementation in Ash.

BUG=1148448
TEST=Launch lacros on a device.

Change-Id: I600188445949a4de60325f5419f137f61360d0e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2640523
Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845941}
parent 38fad67d
...@@ -1049,8 +1049,6 @@ source_set("chromeos") { ...@@ -1049,8 +1049,6 @@ source_set("chromeos") {
"chrome_content_browser_client_chromeos_part.h", "chrome_content_browser_client_chromeos_part.h",
"concierge_helper_service.cc", "concierge_helper_service.cc",
"concierge_helper_service.h", "concierge_helper_service.h",
"crosapi/ash_chrome_service_impl.cc",
"crosapi/ash_chrome_service_impl.h",
"crosapi/browser_loader.cc", "crosapi/browser_loader.cc",
"crosapi/browser_loader.h", "crosapi/browser_loader.h",
"crosapi/browser_manager.cc", "crosapi/browser_manager.cc",
...@@ -1062,6 +1060,8 @@ source_set("chromeos") { ...@@ -1062,6 +1060,8 @@ source_set("chromeos") {
"crosapi/cert_database_ash.h", "crosapi/cert_database_ash.h",
"crosapi/clipboard_ash.cc", "crosapi/clipboard_ash.cc",
"crosapi/clipboard_ash.h", "crosapi/clipboard_ash.h",
"crosapi/crosapi_ash.cc",
"crosapi/crosapi_ash.h",
"crosapi/device_attributes_ash.cc", "crosapi/device_attributes_ash.cc",
"crosapi/device_attributes_ash.h", "crosapi/device_attributes_ash.h",
"crosapi/environment_provider.cc", "crosapi/environment_provider.cc",
......
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/crosapi/ash_chrome_service_impl.h"
#include "chrome/browser/chromeos/crosapi/browser_loader.h" #include "chrome/browser/chromeos/crosapi/browser_loader.h"
#include "chrome/browser/chromeos/crosapi/browser_util.h" #include "chrome/browser/chromeos/crosapi/browser_util.h"
#include "chrome/browser/chromeos/crosapi/crosapi_ash.h"
#include "chrome/browser/chromeos/crosapi/environment_provider.h" #include "chrome/browser/chromeos/crosapi/environment_provider.h"
#include "chrome/browser/chromeos/crosapi/test_mojo_connection_manager.h" #include "chrome/browser/chromeos/crosapi/test_mojo_connection_manager.h"
#include "chrome/browser/component_updater/cros_component_manager.h" #include "chrome/browser/component_updater/cros_component_manager.h"
...@@ -399,7 +399,7 @@ void BrowserManager::StartWithLogFile(base::ScopedFD logfd) { ...@@ -399,7 +399,7 @@ void BrowserManager::StartWithLogFile(base::ScopedFD logfd) {
environment_provider_.get(), channel.TakeLocalEndpoint(), environment_provider_.get(), channel.TakeLocalEndpoint(),
base::BindOnce(&BrowserManager::OnMojoDisconnected, base::BindOnce(&BrowserManager::OnMojoDisconnected,
weak_factory_.GetWeakPtr()), weak_factory_.GetWeakPtr()),
base::BindOnce(&BrowserManager::OnAshChromeServiceReceiverReceived, base::BindOnce(&BrowserManager::OnCrosapiReceiverReceived,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
browser_service_.QueryVersion( browser_service_.QueryVersion(
...@@ -422,11 +422,10 @@ void BrowserManager::StartWithLogFile(base::ScopedFD logfd) { ...@@ -422,11 +422,10 @@ void BrowserManager::StartWithLogFile(base::ScopedFD logfd) {
channel.RemoteProcessLaunchAttempted(); channel.RemoteProcessLaunchAttempted();
} }
void BrowserManager::OnAshChromeServiceReceiverReceived( void BrowserManager::OnCrosapiReceiverReceived(
mojo::PendingReceiver<crosapi::mojom::AshChromeService> pending_receiver) { mojo::PendingReceiver<mojom::Crosapi> pending_receiver) {
DCHECK_EQ(state_, State::STARTING); DCHECK_EQ(state_, State::STARTING);
ash_chrome_service_ = crosapi_ = std::make_unique<CrosapiAsh>(std::move(pending_receiver));
std::make_unique<AshChromeServiceImpl>(std::move(pending_receiver));
state_ = State::RUNNING; state_ = State::RUNNING;
base::UmaHistogramMediumTimes("ChromeOS.Lacros.StartTime", base::UmaHistogramMediumTimes("ChromeOS.Lacros.StartTime",
base::TimeTicks::Now() - lacros_launch_time_); base::TimeTicks::Now() - lacros_launch_time_);
...@@ -444,7 +443,7 @@ void BrowserManager::OnMojoDisconnected() { ...@@ -444,7 +443,7 @@ void BrowserManager::OnMojoDisconnected() {
state_ = State::TERMINATING; state_ = State::TERMINATING;
browser_service_.reset(); browser_service_.reset();
ash_chrome_service_ = nullptr; crosapi_ = nullptr;
base::ThreadPool::PostTaskAndReply( base::ThreadPool::PostTaskAndReply(
FROM_HERE, {base::WithBaseSyncPrimitives()}, FROM_HERE, {base::WithBaseSyncPrimitives()},
base::BindOnce(&TerminateLacrosChrome, std::move(lacros_process_)), base::BindOnce(&TerminateLacrosChrome, std::move(lacros_process_)),
......
...@@ -25,8 +25,10 @@ class CrOSComponentManager; ...@@ -25,8 +25,10 @@ class CrOSComponentManager;
} // namespace component_updater } // namespace component_updater
namespace crosapi { namespace crosapi {
namespace mojom {
class Crosapi;
} // namespace mojom
class AshChromeServiceImpl;
class BrowserLoader; class BrowserLoader;
class TestMojoConnectionManager; class TestMojoConnectionManager;
...@@ -154,10 +156,9 @@ class BrowserManager : public session_manager::SessionManagerObserver { ...@@ -154,10 +156,9 @@ class BrowserManager : public session_manager::SessionManagerObserver {
// by logfd. // by logfd.
void StartWithLogFile(base::ScopedFD logfd); void StartWithLogFile(base::ScopedFD logfd);
// Called when PendingReceiver of AshChromeService is passed from // Called when PendingReceiver of Crosapi is passed from lacros-chrome.
// lacros-chrome. void OnCrosapiReceiverReceived(
void OnAshChromeServiceReceiverReceived( mojo::PendingReceiver<mojom::Crosapi> pending_receiver);
mojo::PendingReceiver<crosapi::mojom::AshChromeService> pending_receiver);
// Called when the Mojo connection to lacros-chrome is disconnected. // Called when the Mojo connection to lacros-chrome is disconnected.
// It may be "just a Mojo error" or "lacros-chrome crash". // It may be "just a Mojo error" or "lacros-chrome crash".
...@@ -207,11 +208,11 @@ class BrowserManager : public session_manager::SessionManagerObserver { ...@@ -207,11 +208,11 @@ class BrowserManager : public session_manager::SessionManagerObserver {
// Proxy to BrowserService mojo service in lacros-chrome. // Proxy to BrowserService mojo service in lacros-chrome.
// Available during lacros-chrome is running. // Available during lacros-chrome is running.
mojo::Remote<crosapi::mojom::BrowserService> browser_service_; mojo::Remote<mojom::BrowserService> browser_service_;
// Implementation of AshChromeService Mojo APIs. // Implementation of Crosapi Mojo APIs.
// Instantiated on receiving the PendingReceiver from lacros-chrome. // Instantiated on receiving the PendingReceiver from lacros-chrome.
std::unique_ptr<AshChromeServiceImpl> ash_chrome_service_; std::unique_ptr<mojom::Crosapi> crosapi_;
// Helps set up and manage the mojo connections between lacros-chrome and // Helps set up and manage the mojo connections between lacros-chrome and
// ash-chrome in testing environment. Only applicable when // ash-chrome in testing environment. Only applicable when
......
...@@ -96,8 +96,7 @@ void AddVersion(InterfaceVersions* map) { ...@@ -96,8 +96,7 @@ void AddVersion(InterfaceVersions* map) {
mojom::BrowserInitParamsPtr GetBrowserInitParams( mojom::BrowserInitParamsPtr GetBrowserInitParams(
EnvironmentProvider* environment_provider) { EnvironmentProvider* environment_provider) {
auto params = mojom::BrowserInitParams::New(); auto params = mojom::BrowserInitParams::New();
params->ash_chrome_service_version = params->crosapi_version = crosapi::mojom::Crosapi::Version_;
crosapi::mojom::AshChromeService::Version_;
params->deprecated_ash_metrics_enabled_has_value = true; params->deprecated_ash_metrics_enabled_has_value = true;
PrefService* local_state = g_browser_process->local_state(); PrefService* local_state = g_browser_process->local_state();
params->ash_metrics_enabled = params->ash_metrics_enabled =
...@@ -216,13 +215,13 @@ bool IsLacrosWindow(const aura::Window* window) { ...@@ -216,13 +215,13 @@ bool IsLacrosWindow(const aura::Window* window) {
base::flat_map<base::Token, uint32_t> GetInterfaceVersions() { base::flat_map<base::Token, uint32_t> GetInterfaceVersions() {
static_assert( static_assert(
crosapi::mojom::AshChromeService::Version_ == 13, crosapi::mojom::Crosapi::Version_ == 13,
"if you add a new crosapi, please add it to the version map here"); "if you add a new crosapi, please add it to the version map here");
InterfaceVersions versions; InterfaceVersions versions;
AddVersion<crosapi::mojom::AccountManager>(&versions); AddVersion<crosapi::mojom::AccountManager>(&versions);
AddVersion<crosapi::mojom::AshChromeService>(&versions);
AddVersion<crosapi::mojom::CertDatabase>(&versions); AddVersion<crosapi::mojom::CertDatabase>(&versions);
AddVersion<crosapi::mojom::Clipboard>(&versions); AddVersion<crosapi::mojom::Clipboard>(&versions);
AddVersion<crosapi::mojom::Crosapi>(&versions);
AddVersion<crosapi::mojom::DeviceAttributes>(&versions); AddVersion<crosapi::mojom::DeviceAttributes>(&versions);
AddVersion<crosapi::mojom::Feedback>(&versions); AddVersion<crosapi::mojom::Feedback>(&versions);
AddVersion<crosapi::mojom::FileManager>(&versions); AddVersion<crosapi::mojom::FileManager>(&versions);
...@@ -246,9 +245,8 @@ mojo::Remote<crosapi::mojom::BrowserService> SendMojoInvitationToLacrosChrome( ...@@ -246,9 +245,8 @@ mojo::Remote<crosapi::mojom::BrowserService> SendMojoInvitationToLacrosChrome(
EnvironmentProvider* environment_provider, EnvironmentProvider* environment_provider,
mojo::PlatformChannelEndpoint local_endpoint, mojo::PlatformChannelEndpoint local_endpoint,
base::OnceClosure mojo_disconnected_callback, base::OnceClosure mojo_disconnected_callback,
base::OnceCallback< base::OnceCallback<void(mojo::PendingReceiver<crosapi::mojom::Crosapi>)>
void(mojo::PendingReceiver<crosapi::mojom::AshChromeService>)> crosapi_callback) {
ash_chrome_service_callback) {
mojo::OutgoingInvitation invitation; mojo::OutgoingInvitation invitation;
mojo::Remote<crosapi::mojom::BrowserService> browser_service; mojo::Remote<crosapi::mojom::BrowserService> browser_service;
browser_service.Bind(mojo::PendingRemote<crosapi::mojom::BrowserService>( browser_service.Bind(mojo::PendingRemote<crosapi::mojom::BrowserService>(
...@@ -260,8 +258,7 @@ mojo::Remote<crosapi::mojom::BrowserService> SendMojoInvitationToLacrosChrome( ...@@ -260,8 +258,7 @@ mojo::Remote<crosapi::mojom::BrowserService> SendMojoInvitationToLacrosChrome(
// becomes mature enough. // becomes mature enough.
browser_service->InitDeprecated(GetBrowserInitParams(environment_provider)); browser_service->InitDeprecated(GetBrowserInitParams(environment_provider));
browser_service->RequestAshChromeServiceReceiver( browser_service->RequestCrosapiReceiver(std::move(crosapi_callback));
std::move(ash_chrome_service_callback));
mojo::OutgoingInvitation::Send(std::move(invitation), mojo::OutgoingInvitation::Send(std::move(invitation),
base::kNullProcessHandle, base::kNullProcessHandle,
std::move(local_endpoint)); std::move(local_endpoint));
......
...@@ -77,9 +77,8 @@ mojo::Remote<crosapi::mojom::BrowserService> SendMojoInvitationToLacrosChrome( ...@@ -77,9 +77,8 @@ mojo::Remote<crosapi::mojom::BrowserService> SendMojoInvitationToLacrosChrome(
::crosapi::EnvironmentProvider* environment_provider, ::crosapi::EnvironmentProvider* environment_provider,
mojo::PlatformChannelEndpoint local_endpoint, mojo::PlatformChannelEndpoint local_endpoint,
base::OnceClosure mojo_disconnected_callback, base::OnceClosure mojo_disconnected_callback,
base::OnceCallback< base::OnceCallback<void(mojo::PendingReceiver<crosapi::mojom::Crosapi>)>
void(mojo::PendingReceiver<crosapi::mojom::AshChromeService>)> crosapi_callback);
ash_chrome_service_callback);
// Creates a memory backed file containing the serialized |params|, // Creates a memory backed file containing the serialized |params|,
// and returns its FD. // and returns its FD.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/crosapi/ash_chrome_service_impl.h" #include "chrome/browser/chromeos/crosapi/crosapi_ash.h"
#include <memory> #include <memory>
#include <utility> #include <utility>
...@@ -43,8 +43,7 @@ ...@@ -43,8 +43,7 @@
namespace crosapi { namespace crosapi {
AshChromeServiceImpl::AshChromeServiceImpl( CrosapiAsh::CrosapiAsh(mojo::PendingReceiver<mojom::Crosapi> pending_receiver)
mojo::PendingReceiver<mojom::AshChromeService> pending_receiver)
: receiver_(this, std::move(pending_receiver)), : receiver_(this, std::move(pending_receiver)),
device_attributes_ash_(std::make_unique<DeviceAttributesAsh>()), device_attributes_ash_(std::make_unique<DeviceAttributesAsh>()),
file_manager_ash_(std::make_unique<FileManagerAsh>()), file_manager_ash_(std::make_unique<FileManagerAsh>()),
...@@ -64,12 +63,12 @@ AshChromeServiceImpl::AshChromeServiceImpl( ...@@ -64,12 +63,12 @@ AshChromeServiceImpl::AshChromeServiceImpl(
url_handler_ash_(std::make_unique<UrlHandlerAsh>()) { url_handler_ash_(std::make_unique<UrlHandlerAsh>()) {
// TODO(hidehiko): Remove non-critical log from here. // TODO(hidehiko): Remove non-critical log from here.
// Currently this is the signal that the connection is established. // Currently this is the signal that the connection is established.
LOG(WARNING) << "AshChromeService connected."; LOG(WARNING) << "Crosapi connected.";
} }
AshChromeServiceImpl::~AshChromeServiceImpl() = default; CrosapiAsh::~CrosapiAsh() = default;
void AshChromeServiceImpl::BindAccountManager( void CrosapiAsh::BindAccountManager(
mojo::PendingReceiver<mojom::AccountManager> receiver) { mojo::PendingReceiver<mojom::AccountManager> receiver) {
// Assumptions: // Assumptions:
// 1. TODO(https://crbug.com/1102768): Multi-Signin / Fast-User-Switching is // 1. TODO(https://crbug.com/1102768): Multi-Signin / Fast-User-Switching is
...@@ -99,97 +98,94 @@ void AshChromeServiceImpl::BindAccountManager( ...@@ -99,97 +98,94 @@ void AshChromeServiceImpl::BindAccountManager(
account_manager_ash->BindReceiver(std::move(receiver)); account_manager_ash->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindFileManager( void CrosapiAsh::BindFileManager(
mojo::PendingReceiver<crosapi::mojom::FileManager> receiver) { mojo::PendingReceiver<crosapi::mojom::FileManager> receiver) {
file_manager_ash_->BindReceiver(std::move(receiver)); file_manager_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindKeystoreService( void CrosapiAsh::BindKeystoreService(
mojo::PendingReceiver<crosapi::mojom::KeystoreService> receiver) { mojo::PendingReceiver<crosapi::mojom::KeystoreService> receiver) {
keystore_service_ash_->BindReceiver(std::move(receiver)); keystore_service_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindMessageCenter( void CrosapiAsh::BindMessageCenter(
mojo::PendingReceiver<mojom::MessageCenter> receiver) { mojo::PendingReceiver<mojom::MessageCenter> receiver) {
message_center_ash_->BindReceiver(std::move(receiver)); message_center_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindMetricsReporting( void CrosapiAsh::BindMetricsReporting(
mojo::PendingReceiver<mojom::MetricsReporting> receiver) { mojo::PendingReceiver<mojom::MetricsReporting> receiver) {
metrics_reporting_ash_->BindReceiver(std::move(receiver)); metrics_reporting_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindSelectFile( void CrosapiAsh::BindSelectFile(
mojo::PendingReceiver<mojom::SelectFile> receiver) { mojo::PendingReceiver<mojom::SelectFile> receiver) {
select_file_ash_->BindReceiver(std::move(receiver)); select_file_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindScreenManager( void CrosapiAsh::BindScreenManager(
mojo::PendingReceiver<mojom::ScreenManager> receiver) { mojo::PendingReceiver<mojom::ScreenManager> receiver) {
screen_manager_ash_->BindReceiver(std::move(receiver)); screen_manager_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindHidManager( void CrosapiAsh::BindHidManager(
mojo::PendingReceiver<device::mojom::HidManager> receiver) { mojo::PendingReceiver<device::mojom::HidManager> receiver) {
content::GetDeviceService().BindHidManager(std::move(receiver)); content::GetDeviceService().BindHidManager(std::move(receiver));
} }
void AshChromeServiceImpl::BindFeedback( void CrosapiAsh::BindFeedback(mojo::PendingReceiver<mojom::Feedback> receiver) {
mojo::PendingReceiver<mojom::Feedback> receiver) {
feedback_ash_->BindReceiver(std::move(receiver)); feedback_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindMediaSessionController( void CrosapiAsh::BindMediaSessionController(
mojo::PendingReceiver<media_session::mojom::MediaControllerManager> mojo::PendingReceiver<media_session::mojom::MediaControllerManager>
receiver) { receiver) {
content::GetMediaSessionService().BindMediaControllerManager( content::GetMediaSessionService().BindMediaControllerManager(
std::move(receiver)); std::move(receiver));
} }
void AshChromeServiceImpl::BindMediaSessionAudioFocus( void CrosapiAsh::BindMediaSessionAudioFocus(
mojo::PendingReceiver<media_session::mojom::AudioFocusManager> receiver) { mojo::PendingReceiver<media_session::mojom::AudioFocusManager> receiver) {
content::GetMediaSessionService().BindAudioFocusManager(std::move(receiver)); content::GetMediaSessionService().BindAudioFocusManager(std::move(receiver));
} }
void AshChromeServiceImpl::BindMediaSessionAudioFocusDebug( void CrosapiAsh::BindMediaSessionAudioFocusDebug(
mojo::PendingReceiver<media_session::mojom::AudioFocusManagerDebug> mojo::PendingReceiver<media_session::mojom::AudioFocusManagerDebug>
receiver) { receiver) {
content::GetMediaSessionService().BindAudioFocusManagerDebug( content::GetMediaSessionService().BindAudioFocusManagerDebug(
std::move(receiver)); std::move(receiver));
} }
void AshChromeServiceImpl::BindCertDatabase( void CrosapiAsh::BindCertDatabase(
mojo::PendingReceiver<mojom::CertDatabase> receiver) { mojo::PendingReceiver<mojom::CertDatabase> receiver) {
cert_database_ash_->BindReceiver(std::move(receiver)); cert_database_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindTestController( void CrosapiAsh::BindTestController(
mojo::PendingReceiver<mojom::TestController> receiver) { mojo::PendingReceiver<mojom::TestController> receiver) {
test_controller_ash_->BindReceiver(std::move(receiver)); test_controller_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindClipboard( void CrosapiAsh::BindClipboard(
mojo::PendingReceiver<mojom::Clipboard> receiver) { mojo::PendingReceiver<mojom::Clipboard> receiver) {
clipboard_ash_->BindReceiver(std::move(receiver)); clipboard_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindDeviceAttributes( void CrosapiAsh::BindDeviceAttributes(
mojo::PendingReceiver<mojom::DeviceAttributes> receiver) { mojo::PendingReceiver<mojom::DeviceAttributes> receiver) {
device_attributes_ash_->BindReceiver(std::move(receiver)); device_attributes_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindPrefs( void CrosapiAsh::BindPrefs(mojo::PendingReceiver<mojom::Prefs> receiver) {
mojo::PendingReceiver<mojom::Prefs> receiver) {
prefs_ash_->BindReceiver(std::move(receiver)); prefs_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::BindUrlHandler( void CrosapiAsh::BindUrlHandler(
mojo::PendingReceiver<mojom::UrlHandler> receiver) { mojo::PendingReceiver<mojom::UrlHandler> receiver) {
url_handler_ash_->BindReceiver(std::move(receiver)); url_handler_ash_->BindReceiver(std::move(receiver));
} }
void AshChromeServiceImpl::OnBrowserStartup( void CrosapiAsh::OnBrowserStartup(mojom::BrowserInfoPtr browser_info) {
mojom::BrowserInfoPtr browser_info) {
BrowserManager::Get()->set_browser_version(browser_info->browser_version); BrowserManager::Get()->set_browser_version(browser_info->browser_version);
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_CROSAPI_ASH_CHROME_SERVICE_IMPL_H_ #ifndef CHROME_BROWSER_CHROMEOS_CROSAPI_CROSAPI_ASH_H_
#define CHROME_BROWSER_CHROMEOS_CROSAPI_ASH_CHROME_SERVICE_IMPL_H_ #define CHROME_BROWSER_CHROMEOS_CROSAPI_CROSAPI_ASH_H_
#include <memory> #include <memory>
...@@ -27,15 +27,14 @@ class SelectFileAsh; ...@@ -27,15 +27,14 @@ class SelectFileAsh;
class TestControllerAsh; class TestControllerAsh;
class UrlHandlerAsh; class UrlHandlerAsh;
// Implementation of AshChromeService. It provides a set of APIs that // Implementation of Crosapi in Ash. It provides a set of APIs that
// lacros-chrome can call into. // crosapi clients, such as lacros-chrome, can call into.
class AshChromeServiceImpl : public mojom::AshChromeService { class CrosapiAsh : public mojom::Crosapi {
public: public:
explicit AshChromeServiceImpl( explicit CrosapiAsh(mojo::PendingReceiver<mojom::Crosapi> pending_receiver);
mojo::PendingReceiver<mojom::AshChromeService> pending_receiver); ~CrosapiAsh() override;
~AshChromeServiceImpl() override;
// crosapi::mojom::AshChromeService: // crosapi::mojom::Crosapi:
void BindAccountManager( void BindAccountManager(
mojo::PendingReceiver<mojom::AccountManager> receiver) override; mojo::PendingReceiver<mojom::AccountManager> receiver) override;
void BindCertDatabase( void BindCertDatabase(
...@@ -75,7 +74,7 @@ class AshChromeServiceImpl : public mojom::AshChromeService { ...@@ -75,7 +74,7 @@ class AshChromeServiceImpl : public mojom::AshChromeService {
mojo::PendingReceiver<mojom::UrlHandler> receiver) override; mojo::PendingReceiver<mojom::UrlHandler> receiver) override;
private: private:
mojo::Receiver<mojom::AshChromeService> receiver_; mojo::Receiver<mojom::Crosapi> receiver_;
std::unique_ptr<DeviceAttributesAsh> device_attributes_ash_; std::unique_ptr<DeviceAttributesAsh> device_attributes_ash_;
std::unique_ptr<FileManagerAsh> file_manager_ash_; std::unique_ptr<FileManagerAsh> file_manager_ash_;
...@@ -94,4 +93,4 @@ class AshChromeServiceImpl : public mojom::AshChromeService { ...@@ -94,4 +93,4 @@ class AshChromeServiceImpl : public mojom::AshChromeService {
} // namespace crosapi } // namespace crosapi
#endif // CHROME_BROWSER_CHROMEOS_CROSAPI_ASH_CHROME_SERVICE_IMPL_H_ #endif // CHROME_BROWSER_CHROMEOS_CROSAPI_CROSAPI_ASH_H_
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "chrome/browser/chromeos/crosapi/ash_chrome_service_impl.h"
#include "chrome/browser/chromeos/crosapi/browser_util.h" #include "chrome/browser/chromeos/crosapi/browser_util.h"
#include "chrome/browser/chromeos/crosapi/crosapi_ash.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "mojo/public/cpp/platform/named_platform_channel.h" #include "mojo/public/cpp/platform/named_platform_channel.h"
...@@ -103,9 +103,8 @@ void TestMojoConnectionManager::OnTestingSocketAvailable() { ...@@ -103,9 +103,8 @@ void TestMojoConnectionManager::OnTestingSocketAvailable() {
environment_provider_.get(), channel.TakeLocalEndpoint(), environment_provider_.get(), channel.TakeLocalEndpoint(),
base::BindOnce(&TestMojoConnectionManager::OnMojoDisconnected, base::BindOnce(&TestMojoConnectionManager::OnMojoDisconnected,
weak_factory_.GetWeakPtr()), weak_factory_.GetWeakPtr()),
base::BindOnce( base::BindOnce(&TestMojoConnectionManager::OnCrosapiReceiverReceived,
&TestMojoConnectionManager::OnAshChromeServiceReceiverReceived, weak_factory_.GetWeakPtr()));
weak_factory_.GetWeakPtr()));
base::ScopedFD startup_fd = base::ScopedFD startup_fd =
browser_util::CreateStartupData(environment_provider_.get()); browser_util::CreateStartupData(environment_provider_.get());
...@@ -129,16 +128,15 @@ void TestMojoConnectionManager::OnTestingSocketAvailable() { ...@@ -129,16 +128,15 @@ void TestMojoConnectionManager::OnTestingSocketAvailable() {
} }
} }
void TestMojoConnectionManager::OnAshChromeServiceReceiverReceived( void TestMojoConnectionManager::OnCrosapiReceiverReceived(
mojo::PendingReceiver<crosapi::mojom::AshChromeService> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::Crosapi> pending_receiver) {
ash_chrome_service_ = crosapi_ = std::make_unique<CrosapiAsh>(std::move(pending_receiver));
std::make_unique<AshChromeServiceImpl>(std::move(pending_receiver));
LOG(INFO) << "Connection to lacros-chrome is established."; LOG(INFO) << "Connection to lacros-chrome is established.";
} }
void TestMojoConnectionManager::OnMojoDisconnected() { void TestMojoConnectionManager::OnMojoDisconnected() {
browser_service_.reset(); browser_service_.reset();
ash_chrome_service_ = nullptr; crosapi_ = nullptr;
LOG(WARNING) << "Mojo to lacros-chrome is disconnected."; LOG(WARNING) << "Mojo to lacros-chrome is disconnected.";
} }
......
...@@ -18,8 +18,9 @@ ...@@ -18,8 +18,9 @@
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
namespace crosapi { namespace crosapi {
namespace mojom {
class AshChromeServiceImpl; class Crosapi;
} // namespace mojom
// An extension of BrowserManager to help set up and manage the mojo connections // An extension of BrowserManager to help set up and manage the mojo connections
// between the test executable and ash-chrome in testing environment. // between the test executable and ash-chrome in testing environment.
...@@ -52,10 +53,9 @@ class TestMojoConnectionManager { ...@@ -52,10 +53,9 @@ class TestMojoConnectionManager {
// Called when a client, such as a test launcher, attempts to connect. // Called when a client, such as a test launcher, attempts to connect.
void OnTestingSocketAvailable(); void OnTestingSocketAvailable();
// Called when PendingReceiver of AshChromeService is passed from // Called when PendingReceiver of Crosapi is passed from lacros-chrome.
// lacros-chrome. void OnCrosapiReceiverReceived(
void OnAshChromeServiceReceiverReceived( mojo::PendingReceiver<crosapi::mojom::Crosapi> pending_receiver);
mojo::PendingReceiver<crosapi::mojom::AshChromeService> pending_receiver);
// Called when the Mojo connection to lacros-chrome is disconnected. // Called when the Mojo connection to lacros-chrome is disconnected.
// It may be "just a Mojo error" or "test is finished". // It may be "just a Mojo error" or "test is finished".
...@@ -66,9 +66,9 @@ class TestMojoConnectionManager { ...@@ -66,9 +66,9 @@ class TestMojoConnectionManager {
// Available during the connected browser is running. // Available during the connected browser is running.
mojo::Remote<crosapi::mojom::BrowserService> browser_service_; mojo::Remote<crosapi::mojom::BrowserService> browser_service_;
// Implementation of AshChromeService Mojo APIs. // Implementation of Crosapi Mojo APIs.
// Instantiated on receiving the PendingReceiver from lacros-chrome. // Instantiated on receiving the PendingReceiver from lacros-chrome.
std::unique_ptr<AshChromeServiceImpl> ash_chrome_service_; std::unique_ptr<crosapi::mojom::Crosapi> crosapi_;
// A socket for a client, such as a test launcher, to connect to. // A socket for a client, such as a test launcher, to connect to.
base::ScopedFD testing_socket_; base::ScopedFD testing_socket_;
......
...@@ -45,11 +45,11 @@ class TestBrowserService : public crosapi::mojom::BrowserService { ...@@ -45,11 +45,11 @@ class TestBrowserService : public crosapi::mojom::BrowserService {
init_is_called_ = true; init_is_called_ = true;
} }
void RequestAshChromeServiceReceiver( void RequestCrosapiReceiver(
RequestAshChromeServiceReceiverCallback callback) override { RequestCrosapiReceiverCallback callback) override {
EXPECT_TRUE(init_is_called_); EXPECT_TRUE(init_is_called_);
std::move(callback).Run(ash_chrome_service_.BindNewPipeAndPassReceiver()); std::move(callback).Run(crosapi_.BindNewPipeAndPassReceiver());
request_ash_chrome_service_is_called_ = true; request_crosapi_is_called_ = true;
run_loop_.Quit(); run_loop_.Quit();
} }
...@@ -60,19 +60,17 @@ class TestBrowserService : public crosapi::mojom::BrowserService { ...@@ -60,19 +60,17 @@ class TestBrowserService : public crosapi::mojom::BrowserService {
bool init_is_called() { return init_is_called_; } bool init_is_called() { return init_is_called_; }
bool request_ash_chrome_service_is_called() { bool request_crosapi_is_called() { return request_crosapi_is_called_; }
return request_ash_chrome_service_is_called_;
}
private: private:
mojo::Receiver<mojom::BrowserService> receiver_; mojo::Receiver<mojom::BrowserService> receiver_;
bool init_is_called_ = false; bool init_is_called_ = false;
bool request_ash_chrome_service_is_called_ = false; bool request_crosapi_is_called_ = false;
base::RunLoop& run_loop_; base::RunLoop& run_loop_;
mojo::Remote<crosapi::mojom::AshChromeService> ash_chrome_service_; mojo::Remote<crosapi::mojom::Crosapi> crosapi_;
}; };
using TestMojoConnectionManagerTest = testing::Test; using TestMojoConnectionManagerTest = testing::Test;
...@@ -170,7 +168,7 @@ MULTIPROCESS_TEST_MAIN(LacrosMain) { ...@@ -170,7 +168,7 @@ MULTIPROCESS_TEST_MAIN(LacrosMain) {
run_loop); run_loop);
run_loop.Run(); run_loop.Run();
DCHECK(test_browser_service.init_is_called()); DCHECK(test_browser_service.init_is_called());
DCHECK(test_browser_service.request_ash_chrome_service_is_called()); DCHECK(test_browser_service.request_crosapi_is_called());
return 0; return 0;
} }
......
...@@ -41,16 +41,16 @@ struct BrowserInfo { ...@@ -41,16 +41,16 @@ struct BrowserInfo {
// TODO(crbug.com/1119925): Add more parameters later. // TODO(crbug.com/1119925): Add more parameters later.
}; };
// AshChromeService defines the APIs that live in ash-chrome and are // Crosapi defines the APIs that live in ash-chrome and are accessed from
// accessed from client applications (such as lacros-chrome). When adding a // client applications (such as lacros-chrome). When adding a major new API
// major new API please note the milestone when you added it, to help us // please note the milestone when you added it, to help us reason about
// reason about compatibility between the client applications and older // compatibility between the client applications and older ash-chrome binaries.
// ash-chrome binaries.
// //
// Next version: 14 // Next version: 14
// Next method id: 19 // Next method id: 19
[Stable, Uuid="8b79c34f-2bf8-4499-979a-b17cac522c1e"] [Stable, Uuid="8b79c34f-2bf8-4499-979a-b17cac522c1e",
interface AshChromeService { RenamedFrom="crosapi.mojom.AshChromeService"]
interface Crosapi {
// Binds Chrome OS Account Manager for Identity management. // Binds Chrome OS Account Manager for Identity management.
// Added in M87. // Added in M87.
[MinVersion=4] [MinVersion=4]
...@@ -234,11 +234,10 @@ enum ExoImeSupport { ...@@ -234,11 +234,10 @@ enum ExoImeSupport {
// Next version: 12 // Next version: 12
[Stable, RenamedFrom="crosapi.mojom.LacrosInitParams"] [Stable, RenamedFrom="crosapi.mojom.LacrosInitParams"]
struct BrowserInitParams { struct BrowserInitParams {
// This is ash-chrome's version of the AshChromeService interface. This is // This is ash-chrome's version of the Crosapi interface. This is used by
// used by lacros-chrome to determine which interface methods are safe to // lacros-chrome to determine which interface methods are safe to call.
// call.
[MinVersion=1] [MinVersion=1]
uint32 ash_chrome_service_version@0; uint32 crosapi_version@0;
// Deprecated in M88. |ash_metrics_enabled| always has a value. // Deprecated in M88. |ash_metrics_enabled| always has a value.
[MinVersion=2] [MinVersion=2]
...@@ -321,13 +320,12 @@ interface BrowserService { ...@@ -321,13 +320,12 @@ interface BrowserService {
// The parameters are available on the browser startup. // The parameters are available on the browser startup.
InitDeprecated@2(BrowserInitParams params); InitDeprecated@2(BrowserInitParams params);
// Returns the pending_receiver of AshChromeService. // Returns the pending_receiver of Crosapi.
// Ash-chrome is expected to call this method on initialization. // Ash-chrome is expected to call this method on initialization.
// The browser may call AshChromeService APIs earlier than this // The browser may call Crosapi APIs earlier than this invocation.
// invocation. In the case, the calls are queued, and processed // In the case, the calls are queued, and processed sequentially, when
// sequentially, when ash-chrome binds the receiver to the service. // ash-chrome binds the receiver to the service.
RequestAshChromeServiceReceiver@0() => ( RequestCrosapiReceiver@0() => (pending_receiver<Crosapi> receiver);
pending_receiver<AshChromeService> receiver);
// Opens a new window in the browser with, currently, the last used profile. // Opens a new window in the browser with, currently, the last used profile.
// The callback is called on the command execution. // The callback is called on the command execution.
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "url/gurl.h" #include "url/gurl.h"
using AshChromeService = crosapi::mojom::AshChromeService;
namespace chromeos { namespace chromeos {
namespace { namespace {
using Crosapi = crosapi::mojom::Crosapi;
// Tests will set this to |true| which will make all crosapi functionality // Tests will set this to |true| which will make all crosapi functionality
// unavailable. // unavailable.
bool g_disable_all_crosapi_for_tests = false; bool g_disable_all_crosapi_for_tests = false;
...@@ -82,12 +82,12 @@ class LacrosChromeServiceNeverBlockingState ...@@ -82,12 +82,12 @@ class LacrosChromeServiceNeverBlockingState
initialized_.Signal(); initialized_.Signal();
} }
void RequestAshChromeServiceReceiver( void RequestCrosapiReceiver(
RequestAshChromeServiceReceiverCallback callback) override { RequestCrosapiReceiverCallback callback) override {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// TODO(hidehiko): Remove non-error logging from here. // TODO(hidehiko): Remove non-error logging from here.
LOG(WARNING) << "AshChromeServiceReceiver requested."; LOG(WARNING) << "CrosapiReceiver requested.";
std::move(callback).Run(std::move(pending_ash_chrome_service_receiver_)); std::move(callback).Run(std::move(pending_crosapi_receiver_));
} }
void NewWindow(NewWindowCallback callback) override { void NewWindow(NewWindowCallback callback) override {
...@@ -129,14 +129,13 @@ class LacrosChromeServiceNeverBlockingState ...@@ -129,14 +129,13 @@ class LacrosChromeServiceNeverBlockingState
// message pumping. // message pumping.
void WaitForInit() { initialized_.Wait(); } void WaitForInit() { initialized_.Wait(); }
// AshChromeService is the interface that lacros-chrome uses to message // Crosapi is the interface that lacros-chrome uses to message
// ash-chrome. This method binds the remote, which allows queuing of message // ash-chrome. This method binds the remote, which allows queuing of message
// to ash-chrome. The messages will not go through until // to ash-chrome. The messages will not go through until
// RequestAshChromeServiceReceiver() is invoked. // RequestCrosapiReceiver() is invoked.
void BindAshChromeServiceRemote() { void BindCrosapiRemote() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
pending_ash_chrome_service_receiver_ = pending_crosapi_receiver_ = crosapi_.BindNewPipeAndPassReceiver();
ash_chrome_service_.BindNewPipeAndPassReceiver();
} }
// BrowserService is the interface that ash-chrome uses to message // BrowserService is the interface that ash-chrome uses to message
...@@ -154,122 +153,119 @@ class LacrosChromeServiceNeverBlockingState ...@@ -154,122 +153,119 @@ class LacrosChromeServiceNeverBlockingState
void BindMessageCenterReceiver( void BindMessageCenterReceiver(
mojo::PendingReceiver<crosapi::mojom::MessageCenter> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::MessageCenter> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindMessageCenter(std::move(pending_receiver)); crosapi_->BindMessageCenter(std::move(pending_receiver));
} }
void BindSelectFileReceiver( void BindSelectFileReceiver(
mojo::PendingReceiver<crosapi::mojom::SelectFile> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::SelectFile> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindSelectFile(std::move(pending_receiver)); crosapi_->BindSelectFile(std::move(pending_receiver));
} }
void BindHidManagerReceiver( void BindHidManagerReceiver(
mojo::PendingReceiver<device::mojom::HidManager> pending_receiver) { mojo::PendingReceiver<device::mojom::HidManager> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindHidManager(std::move(pending_receiver)); crosapi_->BindHidManager(std::move(pending_receiver));
} }
void BindScreenManagerReceiver( void BindScreenManagerReceiver(
mojo::PendingReceiver<crosapi::mojom::ScreenManager> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::ScreenManager> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindScreenManager(std::move(pending_receiver)); crosapi_->BindScreenManager(std::move(pending_receiver));
} }
void BindKeystoreServiceReceiver( void BindKeystoreServiceReceiver(
mojo::PendingReceiver<crosapi::mojom::KeystoreService> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::KeystoreService> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindKeystoreService(std::move(pending_receiver)); crosapi_->BindKeystoreService(std::move(pending_receiver));
} }
void BindFeedbackReceiver( void BindFeedbackReceiver(
mojo::PendingReceiver<crosapi::mojom::Feedback> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::Feedback> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindFeedback(std::move(pending_receiver)); crosapi_->BindFeedback(std::move(pending_receiver));
} }
void BindCertDbReceiver( void BindCertDbReceiver(
mojo::PendingReceiver<crosapi::mojom::CertDatabase> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::CertDatabase> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindCertDatabase(std::move(pending_receiver)); crosapi_->BindCertDatabase(std::move(pending_receiver));
} }
void BindDeviceAttributesReceiver( void BindDeviceAttributesReceiver(
mojo::PendingReceiver<crosapi::mojom::DeviceAttributes> mojo::PendingReceiver<crosapi::mojom::DeviceAttributes>
pending_receiver) { pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindDeviceAttributes(std::move(pending_receiver)); crosapi_->BindDeviceAttributes(std::move(pending_receiver));
} }
void OnBrowserStartup(crosapi::mojom::BrowserInfoPtr browser_info) { void OnBrowserStartup(crosapi::mojom::BrowserInfoPtr browser_info) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->OnBrowserStartup(std::move(browser_info)); crosapi_->OnBrowserStartup(std::move(browser_info));
} }
void BindAccountManagerReceiver( void BindAccountManagerReceiver(
mojo::PendingReceiver<crosapi::mojom::AccountManager> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::AccountManager> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOG(1) << "Binding AccountManager"; DVLOG(1) << "Binding AccountManager";
ash_chrome_service_->BindAccountManager(std::move(pending_receiver)); crosapi_->BindAccountManager(std::move(pending_receiver));
} }
void BindFileManagerReceiver( void BindFileManagerReceiver(
mojo::PendingReceiver<crosapi::mojom::FileManager> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::FileManager> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindFileManager(std::move(pending_receiver)); crosapi_->BindFileManager(std::move(pending_receiver));
} }
void BindClipboardReceiver( void BindClipboardReceiver(
mojo::PendingReceiver<crosapi::mojom::Clipboard> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::Clipboard> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindClipboard(std::move(pending_receiver)); crosapi_->BindClipboard(std::move(pending_receiver));
} }
void BindMediaSessionAudioFocusReceiver( void BindMediaSessionAudioFocusReceiver(
mojo::PendingReceiver<media_session::mojom::AudioFocusManager> mojo::PendingReceiver<media_session::mojom::AudioFocusManager>
pending_receiver) { pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindMediaSessionAudioFocus( crosapi_->BindMediaSessionAudioFocus(std::move(pending_receiver));
std::move(pending_receiver));
} }
void BindMediaSessionAudioFocusDebugReceiver( void BindMediaSessionAudioFocusDebugReceiver(
mojo::PendingReceiver<media_session::mojom::AudioFocusManagerDebug> mojo::PendingReceiver<media_session::mojom::AudioFocusManagerDebug>
pending_receiver) { pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindMediaSessionAudioFocusDebug( crosapi_->BindMediaSessionAudioFocusDebug(std::move(pending_receiver));
std::move(pending_receiver));
} }
void BindMediaSessionControllerReceiver( void BindMediaSessionControllerReceiver(
mojo::PendingReceiver<media_session::mojom::MediaControllerManager> mojo::PendingReceiver<media_session::mojom::MediaControllerManager>
pending_receiver) { pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindMediaSessionController( crosapi_->BindMediaSessionController(std::move(pending_receiver));
std::move(pending_receiver));
} }
void BindMetricsReportingReceiver( void BindMetricsReportingReceiver(
mojo::PendingReceiver<crosapi::mojom::MetricsReporting> receiver) { mojo::PendingReceiver<crosapi::mojom::MetricsReporting> receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindMetricsReporting(std::move(receiver)); crosapi_->BindMetricsReporting(std::move(receiver));
} }
void BindPrefsReceiver( void BindPrefsReceiver(
mojo::PendingReceiver<crosapi::mojom::Prefs> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::Prefs> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindPrefs(std::move(pending_receiver)); crosapi_->BindPrefs(std::move(pending_receiver));
} }
void BindTestControllerReceiver( void BindTestControllerReceiver(
mojo::PendingReceiver<crosapi::mojom::TestController> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::TestController> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindTestController(std::move(pending_receiver)); crosapi_->BindTestController(std::move(pending_receiver));
} }
void BindUrlHandlerReceiver( void BindUrlHandlerReceiver(
mojo::PendingReceiver<crosapi::mojom::UrlHandler> pending_receiver) { mojo::PendingReceiver<crosapi::mojom::UrlHandler> pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ash_chrome_service_->BindUrlHandler(std::move(pending_receiver)); crosapi_->BindUrlHandler(std::move(pending_receiver));
} }
base::WeakPtr<LacrosChromeServiceNeverBlockingState> GetWeakPtr() { base::WeakPtr<LacrosChromeServiceNeverBlockingState> GetWeakPtr() {
...@@ -281,12 +277,11 @@ class LacrosChromeServiceNeverBlockingState ...@@ -281,12 +277,11 @@ class LacrosChromeServiceNeverBlockingState
mojo::Receiver<crosapi::mojom::BrowserService> receiver_{this}; mojo::Receiver<crosapi::mojom::BrowserService> receiver_{this};
// This remote allows lacros-chrome to send messages to ash-chrome. // This remote allows lacros-chrome to send messages to ash-chrome.
mojo::Remote<crosapi::mojom::AshChromeService> ash_chrome_service_; mojo::Remote<crosapi::mojom::Crosapi> crosapi_;
// This class holds onto the receiver for AshChromeService until ash-chrome // This class holds onto the receiver for Crosapi until ash-chrome
// is ready to bind it. // is ready to bind it.
mojo::PendingReceiver<crosapi::mojom::AshChromeService> mojo::PendingReceiver<crosapi::mojom::Crosapi> pending_crosapi_receiver_;
pending_ash_chrome_service_receiver_;
// This allows LacrosChromeServiceNeverBlockingState to route IPC messages // This allows LacrosChromeServiceNeverBlockingState to route IPC messages
// back to the affine thread on LacrosChromeServiceImpl. |owner_| is affine to // back to the affine thread on LacrosChromeServiceImpl. |owner_| is affine to
...@@ -345,9 +340,8 @@ LacrosChromeServiceImpl::LacrosChromeServiceImpl( ...@@ -345,9 +340,8 @@ LacrosChromeServiceImpl::LacrosChromeServiceImpl(
never_blocking_sequence_->PostTask( never_blocking_sequence_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(&LacrosChromeServiceNeverBlockingState::BindCrosapiRemote,
&LacrosChromeServiceNeverBlockingState::BindAshChromeServiceRemote, weak_sequenced_state_));
weak_sequenced_state_));
DCHECK(!g_instance); DCHECK(!g_instance);
g_instance = this; g_instance = this;
...@@ -514,44 +508,42 @@ void LacrosChromeServiceImpl::DisableCrosapiForTests() { ...@@ -514,44 +508,42 @@ void LacrosChromeServiceImpl::DisableCrosapiForTests() {
} }
bool LacrosChromeServiceImpl::IsMessageCenterAvailable() const { bool LacrosChromeServiceImpl::IsMessageCenterAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version &&
version.value() >= version.value() >=
AshChromeService::MethodMinVersions::kBindMessageCenterMinVersion; Crosapi::MethodMinVersions::kBindMessageCenterMinVersion;
} }
bool LacrosChromeServiceImpl::IsSelectFileAvailable() const { bool LacrosChromeServiceImpl::IsSelectFileAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version && version.value() >=
version.value() >= Crosapi::MethodMinVersions::kBindSelectFileMinVersion;
AshChromeService::MethodMinVersions::kBindSelectFileMinVersion;
} }
bool LacrosChromeServiceImpl::IsKeystoreServiceAvailable() const { bool LacrosChromeServiceImpl::IsKeystoreServiceAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && version.value() >= AshChromeService::MethodMinVersions:: return version &&
kBindKeystoreServiceMinVersion; version.value() >=
Crosapi::MethodMinVersions::kBindKeystoreServiceMinVersion;
} }
bool LacrosChromeServiceImpl::IsHidManagerAvailable() const { bool LacrosChromeServiceImpl::IsHidManagerAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version && version.value() >=
version.value() >= Crosapi::MethodMinVersions::kBindHidManagerMinVersion;
AshChromeService::MethodMinVersions::kBindHidManagerMinVersion;
} }
bool LacrosChromeServiceImpl::IsFeedbackAvailable() const { bool LacrosChromeServiceImpl::IsFeedbackAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version &&
version.value() >= version.value() >= Crosapi::MethodMinVersions::kBindFeedbackMinVersion;
AshChromeService::MethodMinVersions::kBindFeedbackMinVersion;
} }
bool LacrosChromeServiceImpl::IsAccountManagerAvailable() const { bool LacrosChromeServiceImpl::IsAccountManagerAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version &&
version.value() >= version.value() >=
AshChromeService::MethodMinVersions::kBindAccountManagerMinVersion; Crosapi::MethodMinVersions::kBindAccountManagerMinVersion;
} }
void LacrosChromeServiceImpl::BindAccountManagerReceiver( void LacrosChromeServiceImpl::BindAccountManagerReceiver(
...@@ -565,10 +557,9 @@ void LacrosChromeServiceImpl::BindAccountManagerReceiver( ...@@ -565,10 +557,9 @@ void LacrosChromeServiceImpl::BindAccountManagerReceiver(
} }
bool LacrosChromeServiceImpl::IsFileManagerAvailable() const { bool LacrosChromeServiceImpl::IsFileManagerAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version && version.value() >=
version.value() >= Crosapi::MethodMinVersions::kBindFileManagerMinVersion;
AshChromeService::MethodMinVersions::kBindFileManagerMinVersion;
} }
bool LacrosChromeServiceImpl::IsTestControllerAvailable() const { bool LacrosChromeServiceImpl::IsTestControllerAvailable() const {
...@@ -577,32 +568,31 @@ bool LacrosChromeServiceImpl::IsTestControllerAvailable() const { ...@@ -577,32 +568,31 @@ bool LacrosChromeServiceImpl::IsTestControllerAvailable() const {
// run on Linux. // run on Linux.
return false; return false;
#else #else
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version &&
version.value() >= version.value() >=
AshChromeService::MethodMinVersions::kBindTestControllerMinVersion; Crosapi::MethodMinVersions::kBindTestControllerMinVersion;
#endif #endif
} }
bool LacrosChromeServiceImpl::IsClipboardAvailable() const { bool LacrosChromeServiceImpl::IsClipboardAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version && version.value() >=
version.value() >= Crosapi::MethodMinVersions::kBindClipboardMinVersion;
AshChromeService::MethodMinVersions::kBindClipboardMinVersion;
} }
bool LacrosChromeServiceImpl::IsScreenManagerAvailable() const { bool LacrosChromeServiceImpl::IsScreenManagerAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version &&
version.value() >= version.value() >=
AshChromeService::MethodMinVersions::kBindScreenManagerMinVersion; Crosapi::MethodMinVersions::kBindScreenManagerMinVersion;
} }
bool LacrosChromeServiceImpl::IsMediaSessionAudioFocusAvailable() const { bool LacrosChromeServiceImpl::IsMediaSessionAudioFocusAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && version.value() >= return version &&
AshChromeService::MethodMinVersions:: version.value() >=
kBindMediaSessionAudioFocusMinVersion; Crosapi::MethodMinVersions::kBindMediaSessionAudioFocusMinVersion;
} }
void LacrosChromeServiceImpl::BindAudioFocusManager( void LacrosChromeServiceImpl::BindAudioFocusManager(
...@@ -617,9 +607,9 @@ void LacrosChromeServiceImpl::BindAudioFocusManager( ...@@ -617,9 +607,9 @@ void LacrosChromeServiceImpl::BindAudioFocusManager(
} }
bool LacrosChromeServiceImpl::IsMediaSessionAudioFocusDebugAvailable() const { bool LacrosChromeServiceImpl::IsMediaSessionAudioFocusDebugAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && version.value() >= return version && version.value() >=
AshChromeService::MethodMinVersions:: Crosapi::MethodMinVersions::
kBindMediaSessionAudioFocusDebugMinVersion; kBindMediaSessionAudioFocusDebugMinVersion;
} }
...@@ -636,10 +626,10 @@ void LacrosChromeServiceImpl::BindAudioFocusManagerDebug( ...@@ -636,10 +626,10 @@ void LacrosChromeServiceImpl::BindAudioFocusManagerDebug(
} }
bool LacrosChromeServiceImpl::IsMediaSessionControllerAvailable() const { bool LacrosChromeServiceImpl::IsMediaSessionControllerAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && version.value() >= return version &&
AshChromeService::MethodMinVersions:: version.value() >=
kBindMediaSessionControllerMinVersion; Crosapi::MethodMinVersions::kBindMediaSessionControllerMinVersion;
} }
void LacrosChromeServiceImpl::BindMediaControllerManager( void LacrosChromeServiceImpl::BindMediaControllerManager(
...@@ -655,9 +645,10 @@ void LacrosChromeServiceImpl::BindMediaControllerManager( ...@@ -655,9 +645,10 @@ void LacrosChromeServiceImpl::BindMediaControllerManager(
} }
bool LacrosChromeServiceImpl::IsMetricsReportingAvailable() const { bool LacrosChromeServiceImpl::IsMetricsReportingAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && version.value() >= AshChromeService::MethodMinVersions:: return version &&
kBindMetricsReportingMinVersion; version.value() >=
Crosapi::MethodMinVersions::kBindMetricsReportingMinVersion;
} }
void LacrosChromeServiceImpl::BindMetricsReporting( void LacrosChromeServiceImpl::BindMetricsReporting(
...@@ -671,37 +662,34 @@ void LacrosChromeServiceImpl::BindMetricsReporting( ...@@ -671,37 +662,34 @@ void LacrosChromeServiceImpl::BindMetricsReporting(
} }
bool LacrosChromeServiceImpl::IsCertDbAvailable() const { bool LacrosChromeServiceImpl::IsCertDbAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version && version.value() >=
version.value() >= Crosapi::MethodMinVersions::kBindCertDatabaseMinVersion;
AshChromeService::MethodMinVersions::kBindCertDatabaseMinVersion;
} }
bool LacrosChromeServiceImpl::IsDeviceAttributesAvailable() const { bool LacrosChromeServiceImpl::IsDeviceAttributesAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && version.value() >= AshChromeService::MethodMinVersions:: return version &&
kBindDeviceAttributesMinVersion; version.value() >=
Crosapi::MethodMinVersions::kBindDeviceAttributesMinVersion;
} }
bool LacrosChromeServiceImpl::IsPrefsAvailable() const { bool LacrosChromeServiceImpl::IsPrefsAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version &&
version.value() >= version.value() >= Crosapi::MethodMinVersions::kBindPrefsMinVersion;
AshChromeService::MethodMinVersions::kBindPrefsMinVersion;
} }
bool LacrosChromeServiceImpl::IsUrlHandlerAvailable() const { bool LacrosChromeServiceImpl::IsUrlHandlerAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version && version.value() >=
version.value() >= Crosapi::MethodMinVersions::kBindUrlHandlerMinVersion;
AshChromeService::MethodMinVersions::kBindUrlHandlerMinVersion;
} }
bool LacrosChromeServiceImpl::IsOnBrowserStartupAvailable() const { bool LacrosChromeServiceImpl::IsOnBrowserStartupAvailable() const {
base::Optional<uint32_t> version = AshChromeServiceVersion(); base::Optional<uint32_t> version = CrosapiVersion();
return version && return version && version.value() >=
version.value() >= Crosapi::MethodMinVersions::kOnBrowserStartupMinVersion;
AshChromeService::MethodMinVersions::kOnBrowserStartupMinVersion;
} }
int LacrosChromeServiceImpl::GetInterfaceVersion( int LacrosChromeServiceImpl::GetInterfaceVersion(
...@@ -763,12 +751,11 @@ void LacrosChromeServiceImpl::GetActiveTabUrlAffineSequence( ...@@ -763,12 +751,11 @@ void LacrosChromeServiceImpl::GetActiveTabUrlAffineSequence(
FROM_HERE, base::BindOnce(std::move(callback), std::move(url))); FROM_HERE, base::BindOnce(std::move(callback), std::move(url)));
} }
base::Optional<uint32_t> LacrosChromeServiceImpl::AshChromeServiceVersion() base::Optional<uint32_t> LacrosChromeServiceImpl::CrosapiVersion() const {
const {
if (g_disable_all_crosapi_for_tests) if (g_disable_all_crosapi_for_tests)
return base::nullopt; return base::nullopt;
DCHECK(did_bind_receiver_); DCHECK(did_bind_receiver_);
return init_params_->ash_chrome_service_version; return init_params_->crosapi_version;
} }
} // namespace chromeos } // namespace chromeos
...@@ -44,7 +44,7 @@ class LacrosChromeServiceNeverBlockingState; ...@@ -44,7 +44,7 @@ class LacrosChromeServiceNeverBlockingState;
// This class is responsible for receiving and routing mojo messages from // This class is responsible for receiving and routing mojo messages from
// ash-chrome via the mojo::Receiver |sequenced_state_.receiver_|. This class is // ash-chrome via the mojo::Receiver |sequenced_state_.receiver_|. This class is
// responsible for sending and routing messages to ash-chrome via the // responsible for sending and routing messages to ash-chrome via the
// mojo::Remote |sequenced_state_.ash_chrome_service_|. Messages are sent and // mojo::Remote |sequenced_state_.crosapi_|. Messages are sent and
// received on a dedicated, never-blocking sequence to avoid deadlocks. // received on a dedicated, never-blocking sequence to avoid deadlocks.
// //
// This object is constructed, destroyed, and mostly used on an "affine // This object is constructed, destroyed, and mostly used on an "affine
...@@ -270,8 +270,8 @@ class COMPONENT_EXPORT(CHROMEOS_LACROS) LacrosChromeServiceImpl { ...@@ -270,8 +270,8 @@ class COMPONENT_EXPORT(CHROMEOS_LACROS) LacrosChromeServiceImpl {
void BindAccountManagerReceiver( void BindAccountManagerReceiver(
mojo::PendingReceiver<crosapi::mojom::AccountManager> pending_receiver); mojo::PendingReceiver<crosapi::mojom::AccountManager> pending_receiver);
// OnLacrosStartup method of AshChromeService crosapi can only be called // OnLacrosStartup method of Crosapi can only be called if this method
// if this method returns true. // returns true.
bool IsOnBrowserStartupAvailable() const; bool IsOnBrowserStartupAvailable() const;
// Returns BrowserInitParams which is passed from ash-chrome. On launching // Returns BrowserInitParams which is passed from ash-chrome. On launching
...@@ -326,10 +326,10 @@ class COMPONENT_EXPORT(CHROMEOS_LACROS) LacrosChromeServiceImpl { ...@@ -326,10 +326,10 @@ class COMPONENT_EXPORT(CHROMEOS_LACROS) LacrosChromeServiceImpl {
scoped_refptr<base::TaskRunner> callback_task_runner, scoped_refptr<base::TaskRunner> callback_task_runner,
GetActiveTabUrlCallback callback); GetActiveTabUrlCallback callback);
// Returns ash's version of the AshChromeService mojo interface version. This // Returns ash's version of the Crosapi mojo interface version. This
// determines which interface methods are available. This is safe to call from // determines which interface methods are available. This is safe to call from
// any sequence. This can only be called after BindReceiver(). // any sequence. This can only be called after BindReceiver().
base::Optional<uint32_t> AshChromeServiceVersion() const; base::Optional<uint32_t> CrosapiVersion() const;
// Delegate instance to inject Chrome dependent code. Must only be used on the // Delegate instance to inject Chrome dependent code. Must only be used on the
// affine sequence. // affine sequence.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment