Commit 4d18d1ab authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

Rename AppShimHostManager to AppShimListener

AppShimHostManager doesn't actually manage AppShimHosts (the
ExtensionAppShimHandler does, confusingly). Rather, it listens for
incoming connections from app shim processes. Rename the files and
structures to reflect this.

Bug: 982024
Change-Id: I0c1e7031da57157da7dfc5bd5dc0c6743a6a89bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1772356Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690794}
parent f706cf73
...@@ -76,11 +76,11 @@ class AppShimController : public chrome::mojom::AppShim { ...@@ -76,11 +76,11 @@ class AppShimController : public chrome::mojom::AppShim {
// Terminates the app shim process. // Terminates the app shim process.
void Close(); void Close();
// Returns the connection to the AppShimHostManager in the browser. Returns // Returns the connection to the AppShimListener in the browser. Returns
// an invalid endpoint if it is not available yet. // an invalid endpoint if it is not available yet.
mojo::PlatformChannelEndpoint GetBrowserEndpoint(); mojo::PlatformChannelEndpoint GetBrowserEndpoint();
// Sets up a connection to the AppShimHostManager at the given Mach // Sets up a connection to the AppShimListener at the given Mach
// endpoint name. // endpoint name.
static mojo::PlatformChannelEndpoint ConnectToBrowser( static mojo::PlatformChannelEndpoint ConnectToBrowser(
const mojo::NamedPlatformChannel::ServerName& server_name); const mojo::NamedPlatformChannel::ServerName& server_name);
...@@ -98,7 +98,7 @@ class AppShimController : public chrome::mojom::AppShim { ...@@ -98,7 +98,7 @@ class AppShimController : public chrome::mojom::AppShim {
base::scoped_nsobject<NSRunningApplication> FindChromeFromSingletonLock() base::scoped_nsobject<NSRunningApplication> FindChromeFromSingletonLock()
const; const;
// Check to see if Chrome's AppShimHostManager has been initialized. If it // Check to see if Chrome's AppShimListener has been initialized. If it
// has, then connect. // has, then connect.
void PollForChromeReady(const base::TimeDelta& time_until_timeout); void PollForChromeReady(const base::TimeDelta& time_until_timeout);
......
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
namespace { namespace {
// The maximum amount of time to wait for Chrome's AppShimHostManager to be // The maximum amount of time to wait for Chrome's AppShimListener to be
// ready. // ready.
constexpr base::TimeDelta kPollTimeoutSeconds = constexpr base::TimeDelta kPollTimeoutSeconds =
base::TimeDelta::FromSeconds(60); base::TimeDelta::FromSeconds(60);
// The period in between attempts to check of Chrome's AppShimHostManager is // The period in between attempts to check of Chrome's AppShimListener is
// ready. // ready.
constexpr base::TimeDelta kPollPeriodMsec = constexpr base::TimeDelta kPollPeriodMsec =
base::TimeDelta::FromMilliseconds(100); base::TimeDelta::FromMilliseconds(100);
......
...@@ -12,8 +12,8 @@ source_set("app_shim") { ...@@ -12,8 +12,8 @@ source_set("app_shim") {
"app_shim_host_bootstrap_mac.h", "app_shim_host_bootstrap_mac.h",
"app_shim_host_mac.cc", "app_shim_host_mac.cc",
"app_shim_host_mac.h", "app_shim_host_mac.h",
"app_shim_host_manager_mac.h", "app_shim_listener.h",
"app_shim_host_manager_mac.mm", "app_shim_listener.mm",
"app_shim_termination_manager.cc", "app_shim_termination_manager.cc",
"app_shim_termination_manager.h", "app_shim_termination_manager.h",
"extension_app_shim_handler_mac.cc", "extension_app_shim_handler_mac.cc",
......
specific_include_rules = { specific_include_rules = {
"app_shim_host_manager_browsertest_mac.mm": [ "app_shim_listener_browsertest_mac.mm": [
"+chrome/app_shim/app_shim_controller.h", "+chrome/app_shim/app_shim_controller.h",
], ],
"mach_bootstrap_acceptor_unittest.mm": [ "mach_bootstrap_acceptor_unittest.mm": [
......
...@@ -4,33 +4,12 @@ ...@@ -4,33 +4,12 @@
#include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h" #include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h"
#include <sys/socket.h>
#include <sys/un.h>
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "mojo/public/cpp/system/message_pipe.h" #include "mojo/public/cpp/system/message_pipe.h"
// static
void AppShimHostBootstrap::CreateForChannel(
mojo::PlatformChannelEndpoint endpoint) {
// AppShimHostBootstrap is initially owned by itself until it receives a
// LaunchApp message or a channel error. In LaunchApp, ownership is
// transferred to a unique_ptr.
DCHECK(endpoint.platform_handle().is_fd());
base::ProcessId pid;
socklen_t pid_size = sizeof(pid);
if (getsockopt(endpoint.platform_handle().GetFD().get(), SOL_LOCAL,
LOCAL_PEERPID, &pid, &pid_size)) {
LOG(ERROR) << "Failed to get peer pid for app shim.";
return;
}
(new AppShimHostBootstrap(pid))->ServeChannel(std::move(endpoint));
}
// static // static
void AppShimHostBootstrap::CreateForChannelAndPeerID( void AppShimHostBootstrap::CreateForChannelAndPeerID(
mojo::PlatformChannelEndpoint endpoint, mojo::PlatformChannelEndpoint endpoint,
...@@ -112,7 +91,7 @@ void AppShimHostBootstrap::LaunchApp( ...@@ -112,7 +91,7 @@ void AppShimHostBootstrap::LaunchApp(
apps::AppShimHandler* handler = GetHandler(); apps::AppShimHandler* handler = GetHandler();
if (handler) if (handler)
handler->OnShimProcessConnected(std::move(deleter)); handler->OnShimProcessConnected(std::move(deleter));
// |handler| can only be NULL after AppShimHostManager is destroyed. Since // |handler| can only be nullptr after AppShimListener is destroyed. Since
// this only happens at shutdown, do nothing here. // this only happens at shutdown, do nothing here.
} }
......
...@@ -20,11 +20,6 @@ ...@@ -20,11 +20,6 @@
class AppShimHostBootstrap : public chrome::mojom::AppShimHostBootstrap { class AppShimHostBootstrap : public chrome::mojom::AppShimHostBootstrap {
public: public:
// Creates a new server-side mojo channel at |endpoint|, which should contain
// a file descriptor of a channel created by an UnixDomainSocketAcceptor, and
// begins listening for messages on it.
static void CreateForChannel(mojo::PlatformChannelEndpoint endpoint);
// Creates a new server-side mojo channel at |endpoint|, which contains a // Creates a new server-side mojo channel at |endpoint|, which contains a
// a Mach port for a channel created by an MachBootstrapAcceptor, and // a Mach port for a channel created by an MachBootstrapAcceptor, and
// begins listening for messages on it. The PID of the sender of |endpoint| // begins listening for messages on it. The PID of the sender of |endpoint|
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/apps/app_shim/app_shim_handler_mac.h" #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h" #include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" #include "chrome/browser/apps/app_shim/app_shim_listener.h"
#include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h" #include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
...@@ -240,7 +240,7 @@ NSString* GetBundleID(const base::FilePath& shim_path) { ...@@ -240,7 +240,7 @@ NSString* GetBundleID(const base::FilePath& shim_path) {
bool HasAppShimHost(Profile* profile, const std::string& app_id) { bool HasAppShimHost(Profile* profile, const std::string& app_id) {
return g_browser_process->platform_part() return g_browser_process->platform_part()
->app_shim_host_manager() ->app_shim_listener()
->extension_app_shim_handler() ->extension_app_shim_handler()
->FindHost(profile, app_id); ->FindHost(profile, app_id);
} }
......
...@@ -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_APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_ #ifndef CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_LISTENER_H_
#define CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_ #define CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_LISTENER_H_
#include <memory> #include <memory>
...@@ -22,20 +22,20 @@ class FilePath; ...@@ -22,20 +22,20 @@ class FilePath;
} }
namespace test { namespace test {
class AppShimHostManagerTestApi; class AppShimListenerTestApi;
} }
// The AppShimHostManager receives connections from app shims on a Mach // The AppShimListener receives connections from app shims on a Mach
// bootstrap namespace entry (mach_acceptor_) and creates a helper object // bootstrap namespace entry (mach_acceptor_) and creates a helper object
// to manage the connection. // to manage the connection.
class AppShimHostManager : public apps::MachBootstrapAcceptor::Delegate, class AppShimListener : public apps::MachBootstrapAcceptor::Delegate,
public base::RefCountedThreadSafe< public base::RefCountedThreadSafe<
AppShimHostManager, AppShimListener,
content::BrowserThread::DeleteOnUIThread> { content::BrowserThread::DeleteOnUIThread> {
public: public:
AppShimHostManager(); AppShimListener();
// Init passes this AppShimHostManager to PostTask which requires it to have // Init passes this AppShimListener to PostTask which requires it to have
// a non-zero refcount. Therefore, Init cannot be called in the constructor // a non-zero refcount. Therefore, Init cannot be called in the constructor
// since the refcount is zero at that point. // since the refcount is zero at that point.
void Init(); void Init();
...@@ -45,12 +45,12 @@ class AppShimHostManager : public apps::MachBootstrapAcceptor::Delegate, ...@@ -45,12 +45,12 @@ class AppShimHostManager : public apps::MachBootstrapAcceptor::Delegate,
} }
private: private:
friend class base::RefCountedThreadSafe<AppShimHostManager>; friend class base::RefCountedThreadSafe<AppShimListener>;
friend struct content::BrowserThread::DeleteOnThread< friend struct content::BrowserThread::DeleteOnThread<
content::BrowserThread::UI>; content::BrowserThread::UI>;
friend class base::DeleteHelper<AppShimHostManager>; friend class base::DeleteHelper<AppShimListener>;
friend class test::AppShimHostManagerTestApi; friend class test::AppShimListenerTestApi;
virtual ~AppShimHostManager(); virtual ~AppShimListener();
// MachBootstrapAcceptor::Delegate: // MachBootstrapAcceptor::Delegate:
void OnClientConnected(mojo::PlatformChannelEndpoint endpoint, void OnClientConnected(mojo::PlatformChannelEndpoint endpoint,
...@@ -66,7 +66,7 @@ class AppShimHostManager : public apps::MachBootstrapAcceptor::Delegate, ...@@ -66,7 +66,7 @@ class AppShimHostManager : public apps::MachBootstrapAcceptor::Delegate,
std::unique_ptr<apps::ExtensionAppShimHandler> extension_app_shim_handler_; std::unique_ptr<apps::ExtensionAppShimHandler> extension_app_shim_handler_;
DISALLOW_COPY_AND_ASSIGN(AppShimHostManager); DISALLOW_COPY_AND_ASSIGN(AppShimListener);
}; };
#endif // CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HOST_MANAGER_MAC_H_ #endif // CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_LISTENER_H_
...@@ -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/apps/app_shim/app_shim_host_manager_mac.h" #include "chrome/browser/apps/app_shim/app_shim_listener.h"
#include <unistd.h> #include <unistd.h>
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
AppShimHostManager::AppShimHostManager() {} AppShimListener::AppShimListener() {}
void AppShimHostManager::Init() { void AppShimListener::Init() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(!extension_app_shim_handler_); DCHECK(!extension_app_shim_handler_);
extension_app_shim_handler_.reset(new apps::ExtensionAppShimHandler()); extension_app_shim_handler_.reset(new apps::ExtensionAppShimHandler());
...@@ -41,14 +41,14 @@ void AppShimHostManager::Init() { ...@@ -41,14 +41,14 @@ void AppShimHostManager::Init() {
base::PostTask( base::PostTask(
FROM_HERE, FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE}, {base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::BindOnce(&AppShimHostManager::InitOnBackgroundThread, this)); base::BindOnce(&AppShimListener::InitOnBackgroundThread, this));
} }
AppShimHostManager::~AppShimHostManager() { AppShimListener::~AppShimListener() {
base::CreateSingleThreadTaskRunner({content::BrowserThread::IO}) base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})
->DeleteSoon(FROM_HERE, std::move(mach_acceptor_)); ->DeleteSoon(FROM_HERE, std::move(mach_acceptor_));
// The AppShimHostManager is only initialized if the Chrome process // The AppShimListener is only initialized if the Chrome process
// successfully took the singleton lock. If it was not initialized, do not // successfully took the singleton lock. If it was not initialized, do not
// delete existing app shim socket files as they belong to another process. // delete existing app shim socket files as they belong to another process.
if (!extension_app_shim_handler_) if (!extension_app_shim_handler_)
...@@ -70,7 +70,7 @@ AppShimHostManager::~AppShimHostManager() { ...@@ -70,7 +70,7 @@ AppShimHostManager::~AppShimHostManager() {
} }
} }
void AppShimHostManager::InitOnBackgroundThread() { void AppShimListener::InitOnBackgroundThread() {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK); base::BlockingType::MAY_BLOCK);
base::FilePath user_data_dir; base::FilePath user_data_dir;
...@@ -94,9 +94,8 @@ void AppShimHostManager::InitOnBackgroundThread() { ...@@ -94,9 +94,8 @@ void AppShimHostManager::InitOnBackgroundThread() {
version_path); version_path);
} }
void AppShimHostManager::OnClientConnected( void AppShimListener::OnClientConnected(mojo::PlatformChannelEndpoint endpoint,
mojo::PlatformChannelEndpoint endpoint, base::ProcessId peer_pid) {
base::ProcessId peer_pid) {
base::CreateSingleThreadTaskRunner({content::BrowserThread::UI}) base::CreateSingleThreadTaskRunner({content::BrowserThread::UI})
->PostTask( ->PostTask(
FROM_HERE, FROM_HERE,
...@@ -104,7 +103,7 @@ void AppShimHostManager::OnClientConnected( ...@@ -104,7 +103,7 @@ void AppShimHostManager::OnClientConnected(
std::move(endpoint), peer_pid)); std::move(endpoint), peer_pid));
} }
void AppShimHostManager::OnServerChannelCreateError() { void AppShimListener::OnServerChannelCreateError() {
// TODO(https://crbug.com/272577): Set a timeout and attempt to reconstruct // TODO(https://crbug.com/272577): Set a timeout and attempt to reconstruct
// the channel. Until cases where the error could occur are better known, // the channel. Until cases where the error could occur are better known,
// just reset the acceptor to allow failure to be communicated via the test // just reset the acceptor to allow failure to be communicated via the test
......
...@@ -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/apps/app_shim/app_shim_host_manager_mac.h" #include "chrome/browser/apps/app_shim/app_shim_listener.h"
#include <unistd.h> #include <unistd.h>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "chrome/app_shim/app_shim_controller.h" #include "chrome/app_shim/app_shim_controller.h"
#include "chrome/browser/apps/app_shim/app_shim_handler_mac.h" #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h" #include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h"
#include "chrome/browser/apps/app_shim/test/app_shim_host_manager_test_api_mac.h" #include "chrome/browser/apps/app_shim/test/app_shim_listener_test_api_mac.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -103,12 +103,12 @@ TestShimClient::TestShimClient() ...@@ -103,12 +103,12 @@ TestShimClient::TestShimClient()
chrome::mojom::AppShimHostBootstrapPtrInfo(std::move(message_pipe), 0)); chrome::mojom::AppShimHostBootstrapPtrInfo(std::move(message_pipe), 0));
} }
// Browser Test for AppShimHostManager to test IPC interactions. // Browser Test for AppShimListener to test IPC interactions.
class AppShimHostManagerBrowserTest : public InProcessBrowserTest, class AppShimListenerBrowserTest : public InProcessBrowserTest,
public apps::AppShimHandler, public apps::AppShimHandler,
public chrome::mojom::AppShimHost { public chrome::mojom::AppShimHost {
public: public:
AppShimHostManagerBrowserTest() : binding_(this) {} AppShimListenerBrowserTest() : binding_(this) {}
protected: protected:
// Wait for OnShimProcessConnected, then send a quit, and wait for the // Wait for OnShimProcessConnected, then send a quit, and wait for the
...@@ -155,10 +155,10 @@ class AppShimHostManagerBrowserTest : public InProcessBrowserTest, ...@@ -155,10 +155,10 @@ class AppShimHostManagerBrowserTest : public InProcessBrowserTest,
int launch_count_ = 0; int launch_count_ = 0;
int quit_count_ = 0; int quit_count_ = 0;
DISALLOW_COPY_AND_ASSIGN(AppShimHostManagerBrowserTest); DISALLOW_COPY_AND_ASSIGN(AppShimListenerBrowserTest);
}; };
void AppShimHostManagerBrowserTest::RunAndExitGracefully() { void AppShimListenerBrowserTest::RunAndExitGracefully() {
runner_ = std::make_unique<base::RunLoop>(); runner_ = std::make_unique<base::RunLoop>();
EXPECT_EQ(0, launch_count_); EXPECT_EQ(0, launch_count_);
runner_->Run(); // Will stop in OnShimProcessConnected(). runner_->Run(); // Will stop in OnShimProcessConnected().
...@@ -173,16 +173,16 @@ void AppShimHostManagerBrowserTest::RunAndExitGracefully() { ...@@ -173,16 +173,16 @@ void AppShimHostManagerBrowserTest::RunAndExitGracefully() {
test_client_.reset(); test_client_.reset();
} }
void AppShimHostManagerBrowserTest::SetUpOnMainThread() { void AppShimListenerBrowserTest::SetUpOnMainThread() {
// Can't do this in the constructor, it needs a BrowserProcess. // Can't do this in the constructor, it needs a BrowserProcess.
apps::AppShimHandler::Set(this); apps::AppShimHandler::Set(this);
} }
void AppShimHostManagerBrowserTest::TearDownOnMainThread() { void AppShimListenerBrowserTest::TearDownOnMainThread() {
apps::AppShimHandler::Set(nullptr); apps::AppShimHandler::Set(nullptr);
} }
void AppShimHostManagerBrowserTest::OnShimProcessConnected( void AppShimListenerBrowserTest::OnShimProcessConnected(
std::unique_ptr<AppShimHostBootstrap> bootstrap) { std::unique_ptr<AppShimHostBootstrap> bootstrap) {
++launch_count_; ++launch_count_;
binding_.Bind(bootstrap->GetLaunchAppShimHostRequest()); binding_.Bind(bootstrap->GetLaunchAppShimHostRequest());
...@@ -194,7 +194,7 @@ void AppShimHostManagerBrowserTest::OnShimProcessConnected( ...@@ -194,7 +194,7 @@ void AppShimHostManagerBrowserTest::OnShimProcessConnected(
} }
// Test regular launch, which would ask Chrome to launch the app. // Test regular launch, which would ask Chrome to launch the app.
IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTest, LaunchNormal) { IN_PROC_BROWSER_TEST_F(AppShimListenerBrowserTest, LaunchNormal) {
test_client_.reset(new TestShimClient()); test_client_.reset(new TestShimClient());
test_client_->host_bootstrap()->LaunchApp( test_client_->host_bootstrap()->LaunchApp(
test_client_->GetHostRequest(), browser()->profile()->GetPath(), test_client_->GetHostRequest(), browser()->profile()->GetPath(),
...@@ -207,7 +207,7 @@ IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTest, LaunchNormal) { ...@@ -207,7 +207,7 @@ IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTest, LaunchNormal) {
} }
// Test register-only launch, used when Chrome has already launched the app. // Test register-only launch, used when Chrome has already launched the app.
IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTest, LaunchRegisterOnly) { IN_PROC_BROWSER_TEST_F(AppShimListenerBrowserTest, LaunchRegisterOnly) {
test_client_.reset(new TestShimClient()); test_client_.reset(new TestShimClient());
test_client_->host_bootstrap()->LaunchApp( test_client_->host_bootstrap()->LaunchApp(
test_client_->GetHostRequest(), browser()->profile()->GetPath(), test_client_->GetHostRequest(), browser()->profile()->GetPath(),
...@@ -220,27 +220,24 @@ IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTest, LaunchRegisterOnly) { ...@@ -220,27 +220,24 @@ IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTest, LaunchRegisterOnly) {
} }
// Ensure bootstrap name registers. // Ensure bootstrap name registers.
IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTest, IN_PROC_BROWSER_TEST_F(AppShimListenerBrowserTest, PRE_ReCreate) {
PRE_ReCreate) { test::AppShimListenerTestApi test_api(
test::AppShimHostManagerTestApi test_api( g_browser_process->platform_part()->app_shim_listener());
g_browser_process->platform_part()->app_shim_host_manager());
EXPECT_TRUE(test_api.mach_acceptor()); EXPECT_TRUE(test_api.mach_acceptor());
} }
// Ensure the bootstrap name can be re-created after a prior browser process has // Ensure the bootstrap name can be re-created after a prior browser process has
// quit. // quit.
IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTest, IN_PROC_BROWSER_TEST_F(AppShimListenerBrowserTest, ReCreate) {
ReCreate) { test::AppShimListenerTestApi test_api(
test::AppShimHostManagerTestApi test_api( g_browser_process->platform_part()->app_shim_listener());
g_browser_process->platform_part()->app_shim_host_manager());
EXPECT_TRUE(test_api.mach_acceptor()); EXPECT_TRUE(test_api.mach_acceptor());
} }
// Tests for the files created by AppShimHostManager. // Tests for the files created by AppShimListener.
class AppShimHostManagerBrowserTestSymlink class AppShimListenerBrowserTestSymlink : public AppShimListenerBrowserTest {
: public AppShimHostManagerBrowserTest {
public: public:
AppShimHostManagerBrowserTestSymlink() {} AppShimListenerBrowserTestSymlink() {}
protected: protected:
base::FilePath version_path_; base::FilePath version_path_;
...@@ -249,11 +246,11 @@ class AppShimHostManagerBrowserTestSymlink ...@@ -249,11 +246,11 @@ class AppShimHostManagerBrowserTestSymlink
bool SetUpUserDataDirectory() override; bool SetUpUserDataDirectory() override;
void TearDownInProcessBrowserTestFixture() override; void TearDownInProcessBrowserTestFixture() override;
DISALLOW_COPY_AND_ASSIGN(AppShimHostManagerBrowserTestSymlink); DISALLOW_COPY_AND_ASSIGN(AppShimListenerBrowserTestSymlink);
}; };
bool AppShimHostManagerBrowserTestSymlink::SetUpUserDataDirectory() { bool AppShimListenerBrowserTestSymlink::SetUpUserDataDirectory() {
// Create an existing symlink. It should be replaced by AppShimHostManager. // Create an existing symlink. It should be replaced by AppShimListener.
base::FilePath user_data_dir; base::FilePath user_data_dir;
EXPECT_TRUE(base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); EXPECT_TRUE(base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
...@@ -262,16 +259,15 @@ bool AppShimHostManagerBrowserTestSymlink::SetUpUserDataDirectory() { ...@@ -262,16 +259,15 @@ bool AppShimHostManagerBrowserTestSymlink::SetUpUserDataDirectory() {
user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName); user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName);
EXPECT_TRUE(base::CreateSymbolicLink(base::FilePath("invalid_version"), EXPECT_TRUE(base::CreateSymbolicLink(base::FilePath("invalid_version"),
version_path_)); version_path_));
return AppShimHostManagerBrowserTest::SetUpUserDataDirectory(); return AppShimListenerBrowserTest::SetUpUserDataDirectory();
} }
void AppShimHostManagerBrowserTestSymlink:: void AppShimListenerBrowserTestSymlink::TearDownInProcessBrowserTestFixture() {
TearDownInProcessBrowserTestFixture() {
// Check that created files have been deleted. // Check that created files have been deleted.
EXPECT_FALSE(base::PathExists(version_path_)); EXPECT_FALSE(base::PathExists(version_path_));
} }
IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTestSymlink, IN_PROC_BROWSER_TEST_F(AppShimListenerBrowserTestSymlink,
RunningChromeVersionCorrectlyWritten) { RunningChromeVersionCorrectlyWritten) {
// Check that the RunningChromeVersion file is correctly written. // Check that the RunningChromeVersion file is correctly written.
base::FilePath version; base::FilePath version;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h" #include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_host_mac.h" #include "chrome/browser/apps/app_shim/app_shim_host_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" #include "chrome/browser/apps/app_shim/app_shim_listener.h"
#include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h" #include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
...@@ -55,8 +55,9 @@ class AppShimQuitTest : public PlatformAppBrowserTest { ...@@ -55,8 +55,9 @@ class AppShimQuitTest : public PlatformAppBrowserTest {
ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
ASSERT_EQ(1u, [[NSApp windows] count]); ASSERT_EQ(1u, [[NSApp windows] count]);
handler_ = g_browser_process->platform_part()->app_shim_host_manager()-> handler_ = g_browser_process->platform_part()
extension_app_shim_handler(); ->app_shim_listener()
->extension_app_shim_handler();
// Attach a host for the app. // Attach a host for the app.
extensions::ExtensionRegistry* registry = extensions::ExtensionRegistry* registry =
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h" #include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_host_mac.h" #include "chrome/browser/apps/app_shim/app_shim_host_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" #include "chrome/browser/apps/app_shim/app_shim_listener.h"
#include "chrome/browser/apps/app_shim/app_shim_termination_manager.h" #include "chrome/browser/apps/app_shim/app_shim_termination_manager.h"
#include "chrome/browser/apps/launch_service/launch_service.h" #include "chrome/browser/apps/launch_service/launch_service.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
...@@ -378,7 +378,7 @@ ExtensionAppShimHandler::ExtensionAppShimHandler() ...@@ -378,7 +378,7 @@ ExtensionAppShimHandler::ExtensionAppShimHandler()
: delegate_(new Delegate), : delegate_(new Delegate),
weak_factory_(this) { weak_factory_(this) {
// This is instantiated in BrowserProcessImpl::PreMainMessageLoopRun with // This is instantiated in BrowserProcessImpl::PreMainMessageLoopRun with
// AppShimHostManager. Since PROFILE_CREATED is not fired until // AppShimListener. Since PROFILE_CREATED is not fired until
// ProfileManager::GetLastUsedProfile/GetLastOpenedProfiles, this should catch // ProfileManager::GetLastUsedProfile/GetLastOpenedProfiles, this should catch
// notifications for all profiles. // notifications for all profiles.
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED, registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED,
...@@ -610,7 +610,7 @@ ExtensionAppShimHandler* ExtensionAppShimHandler::Get() { ...@@ -610,7 +610,7 @@ ExtensionAppShimHandler* ExtensionAppShimHandler::Get() {
// This will only return nullptr in certain unit tests that do not initialize // This will only return nullptr in certain unit tests that do not initialize
// the app shim host manager. // the app shim host manager.
auto* shim_host_manager = auto* shim_host_manager =
g_browser_process->platform_part()->app_shim_host_manager(); g_browser_process->platform_part()->app_shim_listener();
if (shim_host_manager) if (shim_host_manager)
return shim_host_manager->extension_app_shim_handler(); return shim_host_manager->extension_app_shim_handler();
return nullptr; return nullptr;
......
...@@ -2,36 +2,35 @@ ...@@ -2,36 +2,35 @@
// 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/apps/app_shim/test/app_shim_host_manager_test_api_mac.h" #include "chrome/browser/apps/app_shim/test/app_shim_listener_test_api_mac.h"
#include "apps/app_lifetime_monitor_factory.h" #include "apps/app_lifetime_monitor_factory.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" #include "chrome/browser/apps/app_shim/app_shim_listener.h"
#include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
namespace test { namespace test {
AppShimHostManagerTestApi::AppShimHostManagerTestApi( AppShimListenerTestApi::AppShimListenerTestApi(AppShimListener* listener)
AppShimHostManager* host_manager) : listener_(listener) {
: host_manager_(host_manager) { DCHECK(listener_);
DCHECK(host_manager_);
} }
apps::MachBootstrapAcceptor* AppShimHostManagerTestApi::mach_acceptor() { apps::MachBootstrapAcceptor* AppShimListenerTestApi::mach_acceptor() {
return host_manager_->mach_acceptor_.get(); return listener_->mach_acceptor_.get();
} }
const base::FilePath& AppShimHostManagerTestApi::directory_in_tmp() { const base::FilePath& AppShimListenerTestApi::directory_in_tmp() {
return host_manager_->directory_in_tmp_; return listener_->directory_in_tmp_;
} }
void AppShimHostManagerTestApi::SetExtensionAppShimHandler( void AppShimListenerTestApi::SetExtensionAppShimHandler(
std::unique_ptr<apps::ExtensionAppShimHandler> handler) { std::unique_ptr<apps::ExtensionAppShimHandler> handler) {
apps::AppShimHandler::Set(nullptr); apps::AppShimHandler::Set(nullptr);
apps::AppShimHandler::Set(handler.get()); apps::AppShimHandler::Set(handler.get());
host_manager_->extension_app_shim_handler_.swap(handler); listener_->extension_app_shim_handler_.swap(handler);
// Remove old handler from all AppLifetimeMonitors. Usually this is done at // Remove old handler from all AppLifetimeMonitors. Usually this is done at
// profile destruction. // profile destruction.
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// 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_APPS_APP_SHIM_TEST_APP_SHIM_HOST_MANAGER_TEST_API_MAC_H_ #ifndef CHROME_BROWSER_APPS_APP_SHIM_TEST_APP_SHIM_LISTENER_TEST_API_MAC_H_
#define CHROME_BROWSER_APPS_APP_SHIM_TEST_APP_SHIM_HOST_MANAGER_TEST_API_MAC_H_ #define CHROME_BROWSER_APPS_APP_SHIM_TEST_APP_SHIM_LISTENER_TEST_API_MAC_H_
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
class AppShimHostManager; class AppShimListener;
namespace base { namespace base {
class FilePath; class FilePath;
...@@ -18,13 +18,13 @@ class FilePath; ...@@ -18,13 +18,13 @@ class FilePath;
namespace apps { namespace apps {
class ExtensionAppShimHandler; class ExtensionAppShimHandler;
class MachBootstrapAcceptor; class MachBootstrapAcceptor;
} } // namespace apps
namespace test { namespace test {
class AppShimHostManagerTestApi { class AppShimListenerTestApi {
public: public:
explicit AppShimHostManagerTestApi(AppShimHostManager* host_manager); explicit AppShimListenerTestApi(AppShimListener* listener);
apps::MachBootstrapAcceptor* mach_acceptor(); apps::MachBootstrapAcceptor* mach_acceptor();
...@@ -34,11 +34,11 @@ class AppShimHostManagerTestApi { ...@@ -34,11 +34,11 @@ class AppShimHostManagerTestApi {
std::unique_ptr<apps::ExtensionAppShimHandler> handler); std::unique_ptr<apps::ExtensionAppShimHandler> handler);
private: private:
AppShimHostManager* host_manager_; // Not owned. AppShimListener* listener_; // Not owned.
DISALLOW_COPY_AND_ASSIGN(AppShimHostManagerTestApi); DISALLOW_COPY_AND_ASSIGN(AppShimListenerTestApi);
}; };
} // namespace test } // namespace test
#endif // CHROME_BROWSER_APPS_APP_SHIM_TEST_APP_SHIM_HOST_MANAGER_TEST_API_MAC_H_ #endif // CHROME_BROWSER_APPS_APP_SHIM_TEST_APP_SHIM_LISTENER_TEST_API_MAC_H_
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" #include "chrome/browser/apps/app_shim/app_shim_listener.h"
#include "chrome/browser/browser_process_platform_part_base.h" #include "chrome/browser/browser_process_platform_part_base.h"
class BrowserProcessPlatformPart : public BrowserProcessPlatformPartBase { class BrowserProcessPlatformPart : public BrowserProcessPlatformPartBase {
...@@ -22,11 +22,11 @@ class BrowserProcessPlatformPart : public BrowserProcessPlatformPartBase { ...@@ -22,11 +22,11 @@ class BrowserProcessPlatformPart : public BrowserProcessPlatformPartBase {
void AttemptExit(bool try_to_quit_application) override; void AttemptExit(bool try_to_quit_application) override;
void PreMainMessageLoopRun() override; void PreMainMessageLoopRun() override;
AppShimHostManager* app_shim_host_manager(); AppShimListener* app_shim_listener();
private: private:
// Hosts the IPC channel factory that App Shims connect to on Mac. // Hosts the IPC channel factory that App Shims connect to on Mac.
scoped_refptr<AppShimHostManager> app_shim_host_manager_; scoped_refptr<AppShimListener> app_shim_listener_;
DISALLOW_COPY_AND_ASSIGN(BrowserProcessPlatformPart); DISALLOW_COPY_AND_ASSIGN(BrowserProcessPlatformPart);
}; };
......
...@@ -15,7 +15,7 @@ BrowserProcessPlatformPart::~BrowserProcessPlatformPart() { ...@@ -15,7 +15,7 @@ BrowserProcessPlatformPart::~BrowserProcessPlatformPart() {
} }
void BrowserProcessPlatformPart::StartTearDown() { void BrowserProcessPlatformPart::StartTearDown() {
app_shim_host_manager_ = NULL; app_shim_listener_ = nullptr;
} }
void BrowserProcessPlatformPart::AttemptExit(bool try_to_quit_application) { void BrowserProcessPlatformPart::AttemptExit(bool try_to_quit_application) {
...@@ -42,12 +42,12 @@ void BrowserProcessPlatformPart::AttemptExit(bool try_to_quit_application) { ...@@ -42,12 +42,12 @@ void BrowserProcessPlatformPart::AttemptExit(bool try_to_quit_application) {
} }
void BrowserProcessPlatformPart::PreMainMessageLoopRun() { void BrowserProcessPlatformPart::PreMainMessageLoopRun() {
// AppShimHostManager can not simply be reset, otherwise destroying the old // AppShimListener can not simply be reset, otherwise destroying the old
// domain socket will cause the just-created socket to be unlinked. // domain socket will cause the just-created socket to be unlinked.
DCHECK(!app_shim_host_manager_.get()); DCHECK(!app_shim_listener_.get());
app_shim_host_manager_ = new AppShimHostManager; app_shim_listener_ = new AppShimListener;
} }
AppShimHostManager* BrowserProcessPlatformPart::app_shim_host_manager() { AppShimListener* BrowserProcessPlatformPart::app_shim_listener() {
return app_shim_host_manager_.get(); return app_shim_listener_.get();
} }
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#import "chrome/browser/app_controller_mac.h" #import "chrome/browser/app_controller_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" #include "chrome/browser/apps/app_shim/app_shim_listener.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#import "chrome/browser/chrome_browser_application_mac.h" #import "chrome/browser/chrome_browser_application_mac.h"
#include "chrome/browser/first_run/first_run.h" #include "chrome/browser/first_run/first_run.h"
...@@ -477,7 +477,7 @@ void ChromeBrowserMainPartsMac::PreProfileInit() { ...@@ -477,7 +477,7 @@ void ChromeBrowserMainPartsMac::PreProfileInit() {
// This is called here so that the app shim socket is only created after // This is called here so that the app shim socket is only created after
// taking the singleton lock. // taking the singleton lock.
g_browser_process->platform_part()->app_shim_host_manager()->Init(); g_browser_process->platform_part()->app_shim_listener()->Init();
} }
void ChromeBrowserMainPartsMac::PostProfileInit() { void ChromeBrowserMainPartsMac::PostProfileInit() {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h" #include "chrome/browser/apps/app_shim/app_shim_host_bootstrap_mac.h"
#include "chrome/browser/apps/app_shim/app_shim_host_mac.h" #include "chrome/browser/apps/app_shim/app_shim_host_mac.h"
#include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
#include "chrome/browser/apps/app_shim/test/app_shim_host_manager_test_api_mac.h" #include "chrome/browser/apps/app_shim/test/app_shim_listener_test_api_mac.h"
#include "chrome/browser/apps/launch_service/launch_service.h" #include "chrome/browser/apps/launch_service/launch_service.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h" #include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
...@@ -177,8 +177,8 @@ class MockExtensionAppShimHandler : public apps::ExtensionAppShimHandler { ...@@ -177,8 +177,8 @@ class MockExtensionAppShimHandler : public apps::ExtensionAppShimHandler {
// Test Hide/Show and Hide/ShowWithApp() behavior when shims are enabled. // Test Hide/Show and Hide/ShowWithApp() behavior when shims are enabled.
IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest,
HideShowWithAppWithShim) { HideShowWithAppWithShim) {
test::AppShimHostManagerTestApi test_api( test::AppShimListenerTestApi test_api(
g_browser_process->platform_part()->app_shim_host_manager()); g_browser_process->platform_part()->app_shim_listener());
MockExtensionAppShimHandler* mock = new MockExtensionAppShimHandler(); MockExtensionAppShimHandler* mock = new MockExtensionAppShimHandler();
test_api.SetExtensionAppShimHandler( test_api.SetExtensionAppShimHandler(
std::unique_ptr<apps::ExtensionAppShimHandler>( std::unique_ptr<apps::ExtensionAppShimHandler>(
......
...@@ -775,9 +775,9 @@ if (!is_android) { ...@@ -775,9 +775,9 @@ if (!is_android) {
"../browser/accessibility/image_annotation_browsertest.cc", "../browser/accessibility/image_annotation_browsertest.cc",
"../browser/accessibility/interstitial_accessibility_browsertest.cc", "../browser/accessibility/interstitial_accessibility_browsertest.cc",
"../browser/app_controller_mac_browsertest.mm", "../browser/app_controller_mac_browsertest.mm",
"../browser/apps/app_shim/app_shim_host_manager_browsertest_mac.mm", "../browser/apps/app_shim/app_shim_listener_browsertest_mac.mm",
"../browser/apps/app_shim/test/app_shim_host_manager_test_api_mac.cc", "../browser/apps/app_shim/test/app_shim_listener_test_api_mac.cc",
"../browser/apps/app_shim/test/app_shim_host_manager_test_api_mac.h", "../browser/apps/app_shim/test/app_shim_listener_test_api_mac.h",
"../browser/apps/guest_view/app_view_browsertest.cc", "../browser/apps/guest_view/app_view_browsertest.cc",
"../browser/apps/guest_view/web_view_browsertest.cc", "../browser/apps/guest_view/web_view_browsertest.cc",
"../browser/apps/platform_apps/app_browsertest.cc", "../browser/apps/platform_apps/app_browsertest.cc",
......
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