| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Common helper functions/classes used both in the host and device forwarder. | 5 // Common helper functions/classes used both in the host and device forwarder. |
| 6 | 6 |
| 7 #ifndef TOOLS_ANDROID_FORWARDER2_COMMON_H_ | 7 #ifndef TOOLS_ANDROID_FORWARDER2_COMMON_H_ |
| 8 #define TOOLS_ANDROID_FORWARDER2_COMMON_H_ | 8 #define TOOLS_ANDROID_FORWARDER2_COMMON_H_ |
| 9 | 9 |
| 10 #include <stdarg.h> | 10 #include <stdarg.h> |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #include <errno.h> | 12 #include <errno.h> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/eintr_wrapper.h" | |
| 17 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/posix/eintr_wrapper.h" |
| 18 | 18 |
| 19 // Preserving errno for Close() is important because the function is very often | 19 // Preserving errno for Close() is important because the function is very often |
| 20 // used in cleanup code, after an error occurred, and it is very easy to pass an | 20 // used in cleanup code, after an error occurred, and it is very easy to pass an |
| 21 // invalid file descriptor to close() in this context, or more rarely, a | 21 // invalid file descriptor to close() in this context, or more rarely, a |
| 22 // spurious signal might make close() return -1 + setting errno to EINTR, | 22 // spurious signal might make close() return -1 + setting errno to EINTR, |
| 23 // masking the real reason for the original error. This leads to very unpleasant | 23 // masking the real reason for the original error. This leads to very unpleasant |
| 24 // debugging sessions. | 24 // debugging sessions. |
| 25 #define PRESERVE_ERRNO_HANDLE_EINTR(Func) \ | 25 #define PRESERVE_ERRNO_HANDLE_EINTR(Func) \ |
| 26 do { \ | 26 do { \ |
| 27 int local_errno = errno; \ | 27 int local_errno = errno; \ |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 char* write_ptr_; | 80 char* write_ptr_; |
| 81 char buffer_[BufferSize]; | 81 char buffer_[BufferSize]; |
| 82 | 82 |
| 83 COMPILE_ASSERT(BufferSize >= 1, Size_of_buffer_must_be_at_least_one); | 83 COMPILE_ASSERT(BufferSize >= 1, Size_of_buffer_must_be_at_least_one); |
| 84 DISALLOW_COPY_AND_ASSIGN(FixedSizeStringBuilder); | 84 DISALLOW_COPY_AND_ASSIGN(FixedSizeStringBuilder); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } // namespace forwarder2 | 87 } // namespace forwarder2 |
| 88 | 88 |
| 89 #endif // TOOLS_ANDROID_FORWARDER2_COMMON_H_ | 89 #endif // TOOLS_ANDROID_FORWARDER2_COMMON_H_ |
| OLD | NEW |