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, this)); | 34 base::Bind(&AppShimHostManager::InitOnFileThread, |
| 35 base::Unretained(this))); |
35 } | 36 } |
36 | 37 |
37 AppShimHostManager::~AppShimHostManager() { | 38 AppShimHostManager::~AppShimHostManager() { |
38 apps::AppShimHandler::SetDefaultHandler(NULL); | 39 apps::AppShimHandler::SetDefaultHandler(NULL); |
39 } | 40 } |
40 | 41 |
41 void AppShimHostManager::InitOnFileThread() { | 42 void AppShimHostManager::InitOnFileThread() { |
42 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
43 base::FilePath user_data_dir; | 44 base::FilePath user_data_dir; |
44 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 45 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
45 LOG(ERROR) << "Couldn't get user data directory while creating App Shim " | 46 LOG(ERROR) << "Couldn't get user data directory while creating App Shim " |
46 << "Host manager."; | 47 << "Host manager."; |
47 return; | 48 return; |
48 } | 49 } |
49 base::FilePath socket_path = | 50 base::FilePath socket_path = |
50 user_data_dir.Append(app_mode::kAppShimSocketName); | 51 user_data_dir.Append(app_mode::kAppShimSocketName); |
51 factory_.reset(new IPC::ChannelFactory(socket_path, this)); | 52 factory_.reset(new IPC::ChannelFactory(socket_path, this)); |
52 BrowserThread::PostTask( | 53 BrowserThread::PostTask( |
53 BrowserThread::IO, FROM_HERE, | 54 BrowserThread::IO, FROM_HERE, |
54 base::Bind(&AppShimHostManager::ListenOnIOThread, this)); | 55 base::Bind(&AppShimHostManager::ListenOnIOThread, |
| 56 base::Unretained(this))); |
55 } | 57 } |
56 | 58 |
57 void AppShimHostManager::ListenOnIOThread() { | 59 void AppShimHostManager::ListenOnIOThread() { |
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
59 factory_->Listen(); | 61 factory_->Listen(); |
60 } | 62 } |
61 | 63 |
62 void AppShimHostManager::OnClientConnected( | 64 void AppShimHostManager::OnClientConnected( |
63 const IPC::ChannelHandle& handle) { | 65 const IPC::ChannelHandle& handle) { |
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
65 BrowserThread::PostTask( | 67 BrowserThread::PostTask( |
66 BrowserThread::UI, FROM_HERE, | 68 BrowserThread::UI, FROM_HERE, |
67 base::Bind(&CreateAppShimHost, handle)); | 69 base::Bind(&CreateAppShimHost, handle)); |
68 } | 70 } |
69 | 71 |
70 void AppShimHostManager::OnListenError() { | 72 void AppShimHostManager::OnListenError() { |
71 // TODO(jeremya): set a timeout and attempt to reconstruct the channel. | 73 // TODO(jeremya): set a timeout and attempt to reconstruct the channel. |
72 } | 74 } |
OLD | NEW |