OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/unix_domain_socket_acceptor.h" | 5 #include "chrome/browser/apps/app_shim/unix_domain_socket_acceptor.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "mojo/edk/embedder/named_platform_handle_utils.h" | 10 #include "mojo/edk/embedder/named_platform_handle_utils.h" |
11 #include "mojo/edk/embedder/platform_channel_utils_posix.h" | 11 #include "mojo/edk/embedder/platform_channel_utils_posix.h" |
12 | 12 |
13 namespace apps { | 13 namespace apps { |
14 | 14 |
15 UnixDomainSocketAcceptor::UnixDomainSocketAcceptor(const base::FilePath& path, | 15 UnixDomainSocketAcceptor::UnixDomainSocketAcceptor(const base::FilePath& path, |
16 Delegate* delegate) | 16 Delegate* delegate) |
17 : named_pipe_(path.value()), | 17 : named_pipe_(path.value()), |
18 delegate_(delegate), | 18 delegate_(delegate), |
19 listen_handle_(mojo::edk::CreateServerHandle(named_pipe_, false)) { | 19 listen_handle_(mojo::edk::CreateServerHandle(named_pipe_)) { |
20 DCHECK(delegate_); | 20 DCHECK(delegate_); |
21 } | 21 } |
22 | 22 |
23 UnixDomainSocketAcceptor::~UnixDomainSocketAcceptor() { | 23 UnixDomainSocketAcceptor::~UnixDomainSocketAcceptor() { |
24 Close(); | 24 Close(); |
25 } | 25 } |
26 | 26 |
27 bool UnixDomainSocketAcceptor::Listen() { | 27 bool UnixDomainSocketAcceptor::Listen() { |
28 if (!listen_handle_.is_valid()) | 28 if (!listen_handle_.is_valid()) |
29 return false; | 29 return false; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 return; | 65 return; |
66 listen_handle_.reset(); | 66 listen_handle_.reset(); |
67 if (unlink(named_pipe_.name.c_str()) < 0) | 67 if (unlink(named_pipe_.name.c_str()) < 0) |
68 PLOG(ERROR) << "unlink"; | 68 PLOG(ERROR) << "unlink"; |
69 | 69 |
70 // Unregister libevent for the listening socket and close it. | 70 // Unregister libevent for the listening socket and close it. |
71 server_listen_connection_watcher_.StopWatchingFileDescriptor(); | 71 server_listen_connection_watcher_.StopWatchingFileDescriptor(); |
72 } | 72 } |
73 | 73 |
74 } // namespace apps | 74 } // namespace apps |
OLD | NEW |