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 "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" | 5 #include "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 if (!directory_in_tmp.empty()) | 52 if (!directory_in_tmp.empty()) |
53 base::DeleteFile(directory_in_tmp, true); | 53 base::DeleteFile(directory_in_tmp, true); |
54 } | 54 } |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 AppShimHostManager::AppShimHostManager() | 58 AppShimHostManager::AppShimHostManager() |
59 : did_init_(false) {} | 59 : did_init_(false) {} |
60 | 60 |
61 void AppShimHostManager::Init() { | 61 void AppShimHostManager::Init() { |
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 62 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
63 DCHECK(!did_init_); | 63 DCHECK(!did_init_); |
64 did_init_ = true; | 64 did_init_ = true; |
65 apps::AppShimHandler::SetDefaultHandler(&extension_app_shim_handler_); | 65 apps::AppShimHandler::SetDefaultHandler(&extension_app_shim_handler_); |
66 BrowserThread::PostTask( | 66 BrowserThread::PostTask( |
67 BrowserThread::FILE, FROM_HERE, | 67 BrowserThread::FILE, FROM_HERE, |
68 base::Bind(&AppShimHostManager::InitOnFileThread, this)); | 68 base::Bind(&AppShimHostManager::InitOnFileThread, this)); |
69 } | 69 } |
70 | 70 |
71 AppShimHostManager::~AppShimHostManager() { | 71 AppShimHostManager::~AppShimHostManager() { |
72 acceptor_.reset(); | 72 acceptor_.reset(); |
(...skipping 10 matching lines...) Expand all Loading... |
83 user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName); | 83 user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName); |
84 } | 84 } |
85 BrowserThread::PostTask( | 85 BrowserThread::PostTask( |
86 BrowserThread::FILE, | 86 BrowserThread::FILE, |
87 FROM_HERE, | 87 FROM_HERE, |
88 base::Bind( | 88 base::Bind( |
89 &DeleteSocketFiles, directory_in_tmp_, symlink_path, version_path)); | 89 &DeleteSocketFiles, directory_in_tmp_, symlink_path, version_path)); |
90 } | 90 } |
91 | 91 |
92 void AppShimHostManager::InitOnFileThread() { | 92 void AppShimHostManager::InitOnFileThread() { |
93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 93 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
94 base::FilePath user_data_dir; | 94 base::FilePath user_data_dir; |
95 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | 95 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) |
96 return; | 96 return; |
97 | 97 |
98 // The socket path must be shorter than 104 chars (IPC::kMaxSocketNameLength). | 98 // The socket path must be shorter than 104 chars (IPC::kMaxSocketNameLength). |
99 // To accommodate this, we use a short path in /tmp/ that is generated from a | 99 // To accommodate this, we use a short path in /tmp/ that is generated from a |
100 // hash of the user data dir. | 100 // hash of the user data dir. |
101 std::string directory_string = | 101 std::string directory_string = |
102 GetDirectoryInTmpTemplate(user_data_dir).value(); | 102 GetDirectoryInTmpTemplate(user_data_dir).value(); |
103 | 103 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 base::DeleteFile(version_path, false); | 137 base::DeleteFile(version_path, false); |
138 base::CreateSymbolicLink(base::FilePath(chrome::VersionInfo().Version()), | 138 base::CreateSymbolicLink(base::FilePath(chrome::VersionInfo().Version()), |
139 version_path); | 139 version_path); |
140 | 140 |
141 BrowserThread::PostTask( | 141 BrowserThread::PostTask( |
142 BrowserThread::IO, FROM_HERE, | 142 BrowserThread::IO, FROM_HERE, |
143 base::Bind(&AppShimHostManager::ListenOnIOThread, this)); | 143 base::Bind(&AppShimHostManager::ListenOnIOThread, this)); |
144 } | 144 } |
145 | 145 |
146 void AppShimHostManager::ListenOnIOThread() { | 146 void AppShimHostManager::ListenOnIOThread() { |
147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 147 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
148 if (!acceptor_->Listen()) { | 148 if (!acceptor_->Listen()) { |
149 BrowserThread::PostTask( | 149 BrowserThread::PostTask( |
150 BrowserThread::UI, FROM_HERE, | 150 BrowserThread::UI, FROM_HERE, |
151 base::Bind(&AppShimHostManager::OnListenError, this)); | 151 base::Bind(&AppShimHostManager::OnListenError, this)); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 void AppShimHostManager::OnClientConnected( | 155 void AppShimHostManager::OnClientConnected( |
156 const IPC::ChannelHandle& handle) { | 156 const IPC::ChannelHandle& handle) { |
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 157 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
158 BrowserThread::PostTask( | 158 BrowserThread::PostTask( |
159 BrowserThread::UI, FROM_HERE, | 159 BrowserThread::UI, FROM_HERE, |
160 base::Bind(&CreateAppShimHost, handle)); | 160 base::Bind(&CreateAppShimHost, handle)); |
161 } | 161 } |
162 | 162 |
163 void AppShimHostManager::OnListenError() { | 163 void AppShimHostManager::OnListenError() { |
164 // TODO(tapted): Set a timeout and attempt to reconstruct the channel. Until | 164 // TODO(tapted): Set a timeout and attempt to reconstruct the channel. Until |
165 // cases where the error could occur are better known, just reset the acceptor | 165 // cases where the error could occur are better known, just reset the acceptor |
166 // to allow failure to be communicated via the test API. | 166 // to allow failure to be communicated via the test API. |
167 acceptor_.reset(); | 167 acceptor_.reset(); |
168 } | 168 } |
OLD | NEW |