| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "apps/app_shim/app_shim_host_manager_mac.h" | 5 #include "apps/app_shim/app_shim_host_manager_mac.h" |
| 6 | 6 |
| 7 #include "apps/app_shim/app_shim_handler_mac.h" | 7 #include "apps/app_shim/app_shim_handler_mac.h" |
| 8 #include "apps/app_shim/app_shim_host_mac.h" | 8 #include "apps/app_shim/app_shim_host_mac.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 (new AppShimHost)->ServeChannel(handle); | 24 (new AppShimHost)->ServeChannel(handle); |
| 25 } | 25 } |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 AppShimHostManager::AppShimHostManager() { | 29 AppShimHostManager::AppShimHostManager() { |
| 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 31 apps::AppShimHandler::SetDefaultHandler(&extension_app_shim_handler_); | 31 apps::AppShimHandler::SetDefaultHandler(&extension_app_shim_handler_); |
| 32 BrowserThread::PostTask( | 32 BrowserThread::PostTask( |
| 33 BrowserThread::FILE, FROM_HERE, | 33 BrowserThread::FILE, FROM_HERE, |
| 34 base::Bind(&AppShimHostManager::InitOnFileThread, | 34 base::Bind(&AppShimHostManager::InitOnFileThread, this)); |
| 35 base::Unretained(this))); | |
| 36 } | 35 } |
| 37 | 36 |
| 38 AppShimHostManager::~AppShimHostManager() { | 37 AppShimHostManager::~AppShimHostManager() { |
| 39 apps::AppShimHandler::SetDefaultHandler(NULL); | 38 apps::AppShimHandler::SetDefaultHandler(NULL); |
| 40 } | 39 } |
| 41 | 40 |
| 42 void AppShimHostManager::InitOnFileThread() { | 41 void AppShimHostManager::InitOnFileThread() { |
| 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 44 base::FilePath user_data_dir; | 43 base::FilePath user_data_dir; |
| 45 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 44 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
| 46 LOG(ERROR) << "Couldn't get user data directory while creating App Shim " | 45 LOG(ERROR) << "Couldn't get user data directory while creating App Shim " |
| 47 << "Host manager."; | 46 << "Host manager."; |
| 48 return; | 47 return; |
| 49 } | 48 } |
| 50 base::FilePath socket_path = | 49 base::FilePath socket_path = |
| 51 user_data_dir.Append(app_mode::kAppShimSocketName); | 50 user_data_dir.Append(app_mode::kAppShimSocketName); |
| 52 factory_.reset(new IPC::ChannelFactory(socket_path, this)); | 51 factory_.reset(new IPC::ChannelFactory(socket_path, this)); |
| 53 BrowserThread::PostTask( | 52 BrowserThread::PostTask( |
| 54 BrowserThread::IO, FROM_HERE, | 53 BrowserThread::IO, FROM_HERE, |
| 55 base::Bind(&AppShimHostManager::ListenOnIOThread, | 54 base::Bind(&AppShimHostManager::ListenOnIOThread, this)); |
| 56 base::Unretained(this))); | |
| 57 } | 55 } |
| 58 | 56 |
| 59 void AppShimHostManager::ListenOnIOThread() { | 57 void AppShimHostManager::ListenOnIOThread() { |
| 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 61 factory_->Listen(); | 59 factory_->Listen(); |
| 62 } | 60 } |
| 63 | 61 |
| 64 void AppShimHostManager::OnClientConnected( | 62 void AppShimHostManager::OnClientConnected( |
| 65 const IPC::ChannelHandle& handle) { | 63 const IPC::ChannelHandle& handle) { |
| 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 67 BrowserThread::PostTask( | 65 BrowserThread::PostTask( |
| 68 BrowserThread::UI, FROM_HERE, | 66 BrowserThread::UI, FROM_HERE, |
| 69 base::Bind(&CreateAppShimHost, handle)); | 67 base::Bind(&CreateAppShimHost, handle)); |
| 70 } | 68 } |
| 71 | 69 |
| 72 void AppShimHostManager::OnListenError() { | 70 void AppShimHostManager::OnListenError() { |
| 73 // TODO(jeremya): set a timeout and attempt to reconstruct the channel. | 71 // TODO(jeremya): set a timeout and attempt to reconstruct the channel. |
| 74 } | 72 } |
| OLD | NEW |