Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: apps/app_shim/app_shim_host_manager_mac.mm

Issue 305973002: Rename IPC::ChannelFactory to ChannelHandleAcceptor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <unistd.h> 7 #include <unistd.h>
8 8
9 #include "apps/app_shim/app_shim_handler_mac.h" 9 #include "apps/app_shim/app_shim_handler_mac.h"
10 #include "apps/app_shim/app_shim_host_mac.h" 10 #include "apps/app_shim/app_shim_host_mac.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 DCHECK(!did_init_); 58 DCHECK(!did_init_);
59 did_init_ = true; 59 did_init_ = true;
60 apps::AppShimHandler::SetDefaultHandler(&extension_app_shim_handler_); 60 apps::AppShimHandler::SetDefaultHandler(&extension_app_shim_handler_);
61 BrowserThread::PostTask( 61 BrowserThread::PostTask(
62 BrowserThread::FILE, FROM_HERE, 62 BrowserThread::FILE, FROM_HERE,
63 base::Bind(&AppShimHostManager::InitOnFileThread, this)); 63 base::Bind(&AppShimHostManager::InitOnFileThread, this));
64 } 64 }
65 65
66 AppShimHostManager::~AppShimHostManager() { 66 AppShimHostManager::~AppShimHostManager() {
67 factory_.reset(); 67 acceptor_.reset();
68 if (!did_init_) 68 if (!did_init_)
69 return; 69 return;
70 70
71 apps::AppShimHandler::SetDefaultHandler(NULL); 71 apps::AppShimHandler::SetDefaultHandler(NULL);
72 base::FilePath symlink_path; 72 base::FilePath symlink_path;
73 if (PathService::Get(chrome::DIR_USER_DATA, &symlink_path)) 73 if (PathService::Get(chrome::DIR_USER_DATA, &symlink_path))
74 symlink_path = symlink_path.Append(app_mode::kAppShimSocketSymlinkName); 74 symlink_path = symlink_path.Append(app_mode::kAppShimSocketSymlinkName);
75 BrowserThread::PostTask( 75 BrowserThread::PostTask(
76 BrowserThread::FILE, 76 BrowserThread::FILE,
77 FROM_HERE, 77 FROM_HERE,
(...skipping 20 matching lines...) Expand all
98 98
99 directory_in_tmp_ = base::FilePath(directory_string); 99 directory_in_tmp_ = base::FilePath(directory_string);
100 // Check that the directory was created with the correct permissions. 100 // Check that the directory was created with the correct permissions.
101 int dir_mode = 0; 101 int dir_mode = 0;
102 if (!base::GetPosixFilePermissions(directory_in_tmp_, &dir_mode) || 102 if (!base::GetPosixFilePermissions(directory_in_tmp_, &dir_mode) ||
103 dir_mode != base::FILE_PERMISSION_USER_MASK) { 103 dir_mode != base::FILE_PERMISSION_USER_MASK) {
104 NOTREACHED(); 104 NOTREACHED();
105 return; 105 return;
106 } 106 }
107 107
108 // IPC::ChannelFactory creates the socket immediately. 108 // UnixDomainSocketAcceptor creates the socket immediately.
109 base::FilePath socket_path = 109 base::FilePath socket_path =
110 directory_in_tmp_.Append(app_mode::kAppShimSocketShortName); 110 directory_in_tmp_.Append(app_mode::kAppShimSocketShortName);
111 factory_.reset(new IPC::ChannelFactory(socket_path, this)); 111 acceptor_.reset(new apps::UnixDomainSocketAcceptor(socket_path, this));
112 112
113 // Create a symlink to the socket in the user data dir. This lets the shim 113 // Create a symlink to the socket in the user data dir. This lets the shim
114 // process started from Finder find the actual socket path by following the 114 // process started from Finder find the actual socket path by following the
115 // symlink with ::readlink(). 115 // symlink with ::readlink().
116 base::FilePath symlink_path = 116 base::FilePath symlink_path =
117 user_data_dir.Append(app_mode::kAppShimSocketSymlinkName); 117 user_data_dir.Append(app_mode::kAppShimSocketSymlinkName);
118 base::DeleteFile(symlink_path, false); 118 base::DeleteFile(symlink_path, false);
119 base::CreateSymbolicLink(socket_path, symlink_path); 119 base::CreateSymbolicLink(socket_path, symlink_path);
120 120
121 BrowserThread::PostTask( 121 BrowserThread::PostTask(
122 BrowserThread::IO, FROM_HERE, 122 BrowserThread::IO, FROM_HERE,
123 base::Bind(&AppShimHostManager::ListenOnIOThread, this)); 123 base::Bind(&AppShimHostManager::ListenOnIOThread, this));
124 } 124 }
125 125
126 void AppShimHostManager::ListenOnIOThread() { 126 void AppShimHostManager::ListenOnIOThread() {
127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
128 if (!factory_->Listen()) { 128 if (!acceptor_->Listen()) {
129 BrowserThread::PostTask( 129 BrowserThread::PostTask(
130 BrowserThread::UI, FROM_HERE, 130 BrowserThread::UI, FROM_HERE,
131 base::Bind(&AppShimHostManager::OnListenError, this)); 131 base::Bind(&AppShimHostManager::OnListenError, this));
132 } 132 }
133 } 133 }
134 134
135 void AppShimHostManager::OnClientConnected( 135 void AppShimHostManager::OnClientConnected(
136 const IPC::ChannelHandle& handle) { 136 const IPC::ChannelHandle& handle) {
137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
138 BrowserThread::PostTask( 138 BrowserThread::PostTask(
139 BrowserThread::UI, FROM_HERE, 139 BrowserThread::UI, FROM_HERE,
140 base::Bind(&CreateAppShimHost, handle)); 140 base::Bind(&CreateAppShimHost, handle));
141 } 141 }
142 142
143 void AppShimHostManager::OnListenError() { 143 void AppShimHostManager::OnListenError() {
144 // TODO(tapted): Set a timeout and attempt to reconstruct the channel. Until 144 // TODO(tapted): Set a timeout and attempt to reconstruct the channel. Until
145 // cases where the error could occur are better known, just reset the factory 145 // cases where the error could occur are better known, just reset the acceptor
146 // to allow failure to be communicated via the test API. 146 // to allow failure to be communicated via the test API.
147 factory_.reset(); 147 acceptor_.reset();
148 } 148 }
OLDNEW
« no previous file with comments | « apps/app_shim/app_shim_host_manager_mac.h ('k') | apps/app_shim/test/app_shim_host_manager_test_api_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698