Chromium Code Reviews| Index: apps/app_shim/chrome_main_app_mode_mac.mm |
| diff --git a/apps/app_shim/chrome_main_app_mode_mac.mm b/apps/app_shim/chrome_main_app_mode_mac.mm |
| index 2c13ba23c29ec3de0afd7e68c465542fb17e6ced..9f01afdc180bcee7884489fe751e5bdad0c9c6ab 100644 |
| --- a/apps/app_shim/chrome_main_app_mode_mac.mm |
| +++ b/apps/app_shim/chrome_main_app_mode_mac.mm |
| @@ -109,6 +109,11 @@ class AppShimController : public IPC::Listener { |
| // Connects to Chrome and sends a LaunchApp message. |
| void Init(); |
| + // Create a channel from |socket_path| and send a LaunchApp message. |
| + // This may be called multiple times at startup to try to connect to different |
| + // paths. |
| + void CreateChannelAndSendLaunchApp(const base::FilePath& socket_path); |
| + |
| // Builds main menu bar items. |
| void SetUpMenu(); |
| @@ -140,6 +145,8 @@ class AppShimController : public IPC::Listener { |
| // Terminates the app shim process. |
| void Close(); |
| + base::FilePath user_data_dir_; |
| + bool should_try_long_socket_path; |
| IPC::ChannelProxy* channel_; |
| base::scoped_nsobject<AppShimDelegate> delegate_; |
| bool launch_app_done_; |
| @@ -149,7 +156,8 @@ class AppShimController : public IPC::Listener { |
| }; |
| AppShimController::AppShimController() |
| - : channel_(NULL), |
| + : should_try_long_socket_path(true), |
| + channel_(NULL), |
| delegate_([[AppShimDelegate alloc] init]), |
| launch_app_done_(false), |
| ping_chrome_reply_received_(false) { |
| @@ -189,12 +197,15 @@ void AppShimController::Init() { |
| // The user_data_dir for shims actually contains the app_data_path. |
| // I.e. <user_data_dir>/<profile_dir>/Web Applications/_crx_extensionid/ |
| - base::FilePath user_data_dir = |
| - g_info->user_data_dir.DirName().DirName().DirName(); |
| - CHECK(!user_data_dir.empty()); |
| + user_data_dir_ = g_info->user_data_dir.DirName().DirName().DirName(); |
| + CHECK(!user_data_dir_.empty()); |
| + |
| + // Connect to the short socket path first. |
| + CreateChannelAndSendLaunchApp(app_mode::GetShortSocketPath(user_data_dir_)); |
| +} |
| - base::FilePath socket_path = |
| - user_data_dir.Append(app_mode::kAppShimSocketName); |
| +void AppShimController::CreateChannelAndSendLaunchApp( |
| + const base::FilePath& socket_path) { |
|
tapted
2013/11/22 03:29:43
nit: indenting
jackhou1
2013/11/22 04:25:00
Done.
|
| IPC::ChannelHandle handle(socket_path.value()); |
| channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT, |
|
tapted
2013/11/22 03:29:43
ooh - this is not refcounted/scoped. Should we mak
jackhou1
2013/11/22 04:25:00
Done.
|
| this, g_io_thread->message_loop_proxy().get()); |
| @@ -278,10 +289,21 @@ bool AppShimController::OnMessageReceived(const IPC::Message& message) { |
| } |
| void AppShimController::OnChannelError() { |
| + // On failure, try to connect to the long socket path. |
|
tapted
2013/11/22 03:29:43
nit: maybe a TODO - remove this around m35?
jackhou1
2013/11/22 04:25:00
Done.
|
| + if (should_try_long_socket_path) { |
| + should_try_long_socket_path = false; |
| + base::FilePath udd_plus_socket_name = |
| + user_data_dir_.Append(app_mode::kAppShimSocketName); |
| + CreateChannelAndSendLaunchApp(udd_plus_socket_name); |
| + return; |
| + } |
| + |
| Close(); |
| } |
| void AppShimController::OnLaunchAppDone(apps::AppShimLaunchResult result) { |
| + should_try_long_socket_path = false; |
| + |
| if (result != apps::APP_SHIM_LAUNCH_SUCCESS) { |
| Close(); |
| return; |