| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "mojo/edk/embedder/named_platform_handle_utils.h" | 5 #include "mojo/edk/embedder/named_platform_handle_utils.h" |
| 6 | 6 |
| 7 #include <sddl.h> | 7 #include <sddl.h> |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const DWORD kDesiredAccess = GENERIC_READ | GENERIC_WRITE; | 42 const DWORD kDesiredAccess = GENERIC_READ | GENERIC_WRITE; |
| 43 // The SECURITY_ANONYMOUS flag means that the server side cannot impersonate | 43 // The SECURITY_ANONYMOUS flag means that the server side cannot impersonate |
| 44 // the client. | 44 // the client. |
| 45 const DWORD kFlags = | 45 const DWORD kFlags = |
| 46 SECURITY_SQOS_PRESENT | SECURITY_ANONYMOUS | FILE_FLAG_OVERLAPPED; | 46 SECURITY_SQOS_PRESENT | SECURITY_ANONYMOUS | FILE_FLAG_OVERLAPPED; |
| 47 ScopedPlatformHandle handle( | 47 ScopedPlatformHandle handle( |
| 48 PlatformHandle(CreateFileW(pipe_name.c_str(), kDesiredAccess, | 48 PlatformHandle(CreateFileW(pipe_name.c_str(), kDesiredAccess, |
| 49 0, // No sharing. | 49 0, // No sharing. |
| 50 nullptr, OPEN_EXISTING, kFlags, | 50 nullptr, OPEN_EXISTING, kFlags, |
| 51 nullptr))); // No template file. | 51 nullptr))); // No template file. |
| 52 PCHECK(handle.is_valid()); | 52 // The server may have stopped accepting a connection between the |
| 53 // WaitNamedPipe() and CreateFile(). If this occurs, an invalid handle is |
| 54 // returned. |
| 55 DPLOG_IF(ERROR, !handle.is_valid()) |
| 56 << "Named pipe " << named_handle.pipe_name() |
| 57 << " could not be opened after WaitNamedPipe succeeded"; |
| 53 return handle; | 58 return handle; |
| 54 } | 59 } |
| 55 | 60 |
| 56 ScopedPlatformHandle CreateServerHandle( | 61 ScopedPlatformHandle CreateServerHandle( |
| 57 const NamedPlatformHandle& named_handle, | 62 const NamedPlatformHandle& named_handle, |
| 58 const CreateServerHandleOptions& options) { | 63 const CreateServerHandleOptions& options) { |
| 59 if (!named_handle.is_valid()) | 64 if (!named_handle.is_valid()) |
| 60 return ScopedPlatformHandle(); | 65 return ScopedPlatformHandle(); |
| 61 | 66 |
| 62 PSECURITY_DESCRIPTOR security_desc = nullptr; | 67 PSECURITY_DESCRIPTOR security_desc = nullptr; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 81 4096, // Out buffer size. | 86 4096, // Out buffer size. |
| 82 4096, // In buffer size. | 87 4096, // In buffer size. |
| 83 5000, // Timeout in milliseconds. | 88 5000, // Timeout in milliseconds. |
| 84 &security_attributes)); | 89 &security_attributes)); |
| 85 handle.needs_connection = true; | 90 handle.needs_connection = true; |
| 86 return ScopedPlatformHandle(handle); | 91 return ScopedPlatformHandle(handle); |
| 87 } | 92 } |
| 88 | 93 |
| 89 } // namespace edk | 94 } // namespace edk |
| 90 } // namespace mojo | 95 } // namespace mojo |
| OLD | NEW |