Commit e36b86e5 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

Rename OnShimLaunch to OnShimProcessConnected

The previous name was no longer reflective of the behavior. Updated
comments as well.

TBR=dominickn

Change-Id: Id8791c8e4272e51f86ac84c93f94ed06a49f2de7
Reviewed-on: https://chromium-review.googlesource.com/c/1373733Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615862}
parent 1bf6ef78
...@@ -46,12 +46,11 @@ class AppShimHandler { ...@@ -46,12 +46,11 @@ class AppShimHandler {
// running. // running.
static bool ShouldRestoreSession(); static bool ShouldRestoreSession();
// Invoked by the shim host when the shim process is launched. The handler // Invoked by the AppShimHostBootstrap when a shim process has connected to
// must call OnAppLaunchComplete to inform the shim of the result. // the browser process. This will connect to (creating, if needed) an
// |launch_type| indicates the type of launch. // AppShimHost. |bootstrap| must have OnLaunchAppSucceeded or
// |files|, if non-empty, holds an array of files paths given as arguments, or // OnLaunchAppFailed called on it to inform the shim of the result.
// dragged onto the app bundle or dock icon. virtual void OnShimProcessConnected(
virtual void OnShimLaunch(
std::unique_ptr<AppShimHostBootstrap> bootstrap) = 0; std::unique_ptr<AppShimHostBootstrap> bootstrap) = 0;
// Invoked by the shim host when the connection to the shim process is closed. // Invoked by the shim host when the connection to the shim process is closed.
......
...@@ -86,7 +86,7 @@ void AppShimHostBootstrap::LaunchApp( ...@@ -86,7 +86,7 @@ void AppShimHostBootstrap::LaunchApp(
// |handler| takes ownership of |this| now. // |handler| takes ownership of |this| now.
apps::AppShimHandler* handler = GetHandler(); apps::AppShimHandler* handler = GetHandler();
if (handler) if (handler)
handler->OnShimLaunch(std::move(deleter)); handler->OnShimProcessConnected(std::move(deleter));
// |handler| can only be NULL after AppShimHostManager is destroyed. Since // |handler| can only be NULL after AppShimHostManager is destroyed. Since
// this only happens at shutdown, do nothing here. // this only happens at shutdown, do nothing here.
} }
......
...@@ -31,7 +31,12 @@ class AppShimHostBootstrap : public chrome::mojom::AppShimHostBootstrap { ...@@ -31,7 +31,12 @@ class AppShimHostBootstrap : public chrome::mojom::AppShimHostBootstrap {
chrome::mojom::AppShimHostRequest GetLaunchAppShimHostRequest(); chrome::mojom::AppShimHostRequest GetLaunchAppShimHostRequest();
const std::string& GetAppId() const { return app_id_; } const std::string& GetAppId() const { return app_id_; }
const base::FilePath& GetProfilePath() const { return profile_path_; } const base::FilePath& GetProfilePath() const { return profile_path_; }
// Indicates the type of launch (by Chrome or from the app).
apps::AppShimLaunchType GetLaunchType() const { return launch_type_; } apps::AppShimLaunchType GetLaunchType() const { return launch_type_; }
// If non-empty, holds an array of file paths given as arguments, or dragged
// onto the app bundle or dock icon.
const std::vector<base::FilePath>& GetLaunchFiles() const { return files_; } const std::vector<base::FilePath>& GetLaunchFiles() const { return files_; }
protected: protected:
......
...@@ -139,7 +139,8 @@ class AppShimHostTest : public testing::Test, ...@@ -139,7 +139,8 @@ class AppShimHostTest : public testing::Test,
void SimulateDisconnect() { host_ptr_.reset(); } void SimulateDisconnect() { host_ptr_.reset(); }
protected: protected:
void OnShimLaunch(std::unique_ptr<AppShimHostBootstrap> bootstrap) override { void OnShimProcessConnected(
std::unique_ptr<AppShimHostBootstrap> bootstrap) override {
++launch_count_; ++launch_count_;
if (bootstrap->GetLaunchType() == apps::APP_SHIM_LAUNCH_NORMAL) if (bootstrap->GetLaunchType() == apps::APP_SHIM_LAUNCH_NORMAL)
++launch_now_count_; ++launch_now_count_;
......
...@@ -107,8 +107,8 @@ class AppShimHostManagerBrowserTest : public InProcessBrowserTest, ...@@ -107,8 +107,8 @@ class AppShimHostManagerBrowserTest : public InProcessBrowserTest,
AppShimHostManagerBrowserTest() : binding_(this) {} AppShimHostManagerBrowserTest() : binding_(this) {}
protected: protected:
// Wait for OnShimLaunch, then send a quit, and wait for the response. Used to // Wait for OnShimProcessConnected, then send a quit, and wait for the
// test launch behavior. // response. Used to test launch behavior.
void RunAndExitGracefully(); void RunAndExitGracefully();
// InProcessBrowserTest overrides: // InProcessBrowserTest overrides:
...@@ -116,7 +116,8 @@ class AppShimHostManagerBrowserTest : public InProcessBrowserTest, ...@@ -116,7 +116,8 @@ class AppShimHostManagerBrowserTest : public InProcessBrowserTest,
void TearDownOnMainThread() override; void TearDownOnMainThread() override;
// AppShimHandler overrides: // AppShimHandler overrides:
void OnShimLaunch(std::unique_ptr<AppShimHostBootstrap> bootstrap) override; void OnShimProcessConnected(
std::unique_ptr<AppShimHostBootstrap> bootstrap) override;
void OnShimClose(::AppShimHost* host) override {} void OnShimClose(::AppShimHost* host) override {}
void OnShimFocus(::AppShimHost* host, void OnShimFocus(::AppShimHost* host,
apps::AppShimFocusType focus_type, apps::AppShimFocusType focus_type,
...@@ -151,7 +152,7 @@ class AppShimHostManagerBrowserTest : public InProcessBrowserTest, ...@@ -151,7 +152,7 @@ class AppShimHostManagerBrowserTest : public InProcessBrowserTest,
void AppShimHostManagerBrowserTest::RunAndExitGracefully() { void AppShimHostManagerBrowserTest::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 OnShimLaunch(). runner_->Run(); // Will stop in OnShimProcessConnected().
EXPECT_EQ(1, launch_count_); EXPECT_EQ(1, launch_count_);
runner_ = std::make_unique<base::RunLoop>(); runner_ = std::make_unique<base::RunLoop>();
...@@ -172,7 +173,7 @@ void AppShimHostManagerBrowserTest::TearDownOnMainThread() { ...@@ -172,7 +173,7 @@ void AppShimHostManagerBrowserTest::TearDownOnMainThread() {
apps::AppShimHandler::RemoveHandler(kTestAppMode); apps::AppShimHandler::RemoveHandler(kTestAppMode);
} }
void AppShimHostManagerBrowserTest::OnShimLaunch( void AppShimHostManagerBrowserTest::OnShimProcessConnected(
std::unique_ptr<AppShimHostBootstrap> bootstrap) { std::unique_ptr<AppShimHostBootstrap> bootstrap) {
++launch_count_; ++launch_count_;
binding_.Bind(bootstrap->GetLaunchAppShimHostRequest()); binding_.Bind(bootstrap->GetLaunchAppShimHostRequest());
......
...@@ -103,11 +103,12 @@ class WindowedAppShimLaunchObserver : public apps::AppShimHandler { ...@@ -103,11 +103,12 @@ class WindowedAppShimLaunchObserver : public apps::AppShimHandler {
} }
// AppShimHandler overrides: // AppShimHandler overrides:
void OnShimLaunch(std::unique_ptr<AppShimHostBootstrap> bootstrap) override { void OnShimProcessConnected(
std::unique_ptr<AppShimHostBootstrap> bootstrap) override {
// Remove self and pass through to the default handler. // Remove self and pass through to the default handler.
apps::AppShimHandler::RemoveHandler(app_mode_id_); apps::AppShimHandler::RemoveHandler(app_mode_id_);
apps::AppShimHandler::GetForAppMode(app_mode_id_) apps::AppShimHandler::GetForAppMode(app_mode_id_)
->OnShimLaunch(std::move(bootstrap)); ->OnShimProcessConnected(std::move(bootstrap));
observed_ = true; observed_ = true;
if (run_loop_.get()) if (run_loop_.get())
run_loop_->Quit(); run_loop_->Quit();
......
...@@ -17,7 +17,8 @@ class AppsPageShimHandler : public apps::AppShimHandler { ...@@ -17,7 +17,8 @@ class AppsPageShimHandler : public apps::AppShimHandler {
AppsPageShimHandler() {} AppsPageShimHandler() {}
// AppShimHandler: // AppShimHandler:
void OnShimLaunch(std::unique_ptr<AppShimHostBootstrap> bootstrap) override; void OnShimProcessConnected(
std::unique_ptr<AppShimHostBootstrap> bootstrap) override;
void OnShimClose(AppShimHost* host) override; void OnShimClose(AppShimHost* host) override;
void OnShimFocus(AppShimHost* host, void OnShimFocus(AppShimHost* host,
apps::AppShimFocusType focus_type, apps::AppShimFocusType focus_type,
......
...@@ -53,7 +53,7 @@ void OpenAppsPage(Profile* fallback_profile) { ...@@ -53,7 +53,7 @@ void OpenAppsPage(Profile* fallback_profile) {
} // namespace } // namespace
void AppsPageShimHandler::OnShimLaunch( void AppsPageShimHandler::OnShimProcessConnected(
std::unique_ptr<AppShimHostBootstrap> bootstrap) { std::unique_ptr<AppShimHostBootstrap> bootstrap) {
AppController* controller = AppController* controller =
base::mac::ObjCCastStrict<AppController>([NSApp delegate]); base::mac::ObjCCastStrict<AppController>([NSApp delegate]);
......
...@@ -422,7 +422,7 @@ void ExtensionAppShimHandler::OnChromeWillHide() { ...@@ -422,7 +422,7 @@ void ExtensionAppShimHandler::OnChromeWillHide() {
entry.second->OnAppHide(); entry.second->OnAppHide();
} }
void ExtensionAppShimHandler::OnShimLaunch( void ExtensionAppShimHandler::OnShimProcessConnected(
std::unique_ptr<AppShimHostBootstrap> bootstrap) { std::unique_ptr<AppShimHostBootstrap> bootstrap) {
const std::string& app_id = bootstrap->GetAppId(); const std::string& app_id = bootstrap->GetAppId();
AppShimLaunchType launch_type = bootstrap->GetLaunchType(); AppShimLaunchType launch_type = bootstrap->GetLaunchType();
......
...@@ -129,7 +129,8 @@ class ExtensionAppShimHandler : public AppShimHandler, ...@@ -129,7 +129,8 @@ class ExtensionAppShimHandler : public AppShimHandler,
void OnChromeWillHide(); void OnChromeWillHide();
// AppShimHandler overrides: // AppShimHandler overrides:
void OnShimLaunch(std::unique_ptr<AppShimHostBootstrap> bootstrap) override; void OnShimProcessConnected(
std::unique_ptr<AppShimHostBootstrap> bootstrap) override;
void OnShimClose(AppShimHost* host) override; void OnShimClose(AppShimHost* host) override;
void OnShimFocus(AppShimHost* host, void OnShimFocus(AppShimHost* host,
AppShimFocusType focus_type, AppShimFocusType focus_type,
......
...@@ -542,9 +542,9 @@ TEST_F(ExtensionAppShimHandlerTest, RegisterOnly) { ...@@ -542,9 +542,9 @@ TEST_F(ExtensionAppShimHandlerTest, RegisterOnly) {
} }
TEST_F(ExtensionAppShimHandlerTest, LoadProfile) { TEST_F(ExtensionAppShimHandlerTest, LoadProfile) {
// If the profile is not loaded when an OnShimLaunch arrives, return false // If the profile is not loaded when an OnShimProcessConnected arrives, return
// and load the profile asynchronously. Launch the app when the profile is // false and load the profile asynchronously. Launch the app when the profile
// ready. // is ready.
EXPECT_CALL(*delegate_, ProfileForPath(profile_path_a_)) EXPECT_CALL(*delegate_, ProfileForPath(profile_path_a_))
.WillOnce(Return(static_cast<Profile*>(NULL))) .WillOnce(Return(static_cast<Profile*>(NULL)))
.WillRepeatedly(Return(&profile_a_)); .WillRepeatedly(Return(&profile_a_));
......
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