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

Side by Side Diff: ppapi/tests/test_broker.cc

Issue 100253002: Don't HANDLE_EINTR(close). Either IGNORE_EINTR(close) or just close. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years 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
« no previous file with comments | « ppapi/proxy/plugin_dispatcher.cc ('k') | printing/pdf_metafile_skia.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ppapi/tests/test_broker.h" 5 #include "ppapi/tests/test_broker.h"
6 6
7 #if defined(_MSC_VER) 7 #if defined(_MSC_VER)
8 #define OS_WIN 1 8 #define OS_WIN 1
9 #include <windows.h> 9 #include <windows.h>
10 #else 10 #else
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 PlatformFile IntToPlatformFile(int32_t handle) { 52 PlatformFile IntToPlatformFile(int32_t handle) {
53 #if defined(OS_WIN) 53 #if defined(OS_WIN)
54 return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle)); 54 return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle));
55 #elif defined(OS_POSIX) 55 #elif defined(OS_POSIX)
56 return handle; 56 return handle;
57 #endif 57 #endif
58 } 58 }
59 59
60 #if defined(OS_POSIX) 60 #if defined(OS_POSIX)
61
61 #define HANDLE_EINTR(x) ({ \ 62 #define HANDLE_EINTR(x) ({ \
62 typeof(x) __eintr_result__; \ 63 typeof(x) eintr_wrapper_result; \
63 do { \ 64 do { \
64 __eintr_result__ = x; \ 65 eintr_wrapper_result = (x); \
65 } while (__eintr_result__ == -1 && errno == EINTR); \ 66 } while (eintr_wrapper_result == -1 && errno == EINTR); \
66 __eintr_result__;\ 67 eintr_wrapper_result; \
67 }) 68 })
69
70 #define IGNORE_EINTR(x) ({ \
71 typeof(x) eintr_wrapper_result; \
72 do { \
73 eintr_wrapper_result = (x); \
74 if (eintr_wrapper_result == -1 && errno == EINTR) { \
75 eintr_wrapper_result = 0; \
76 } \
77 } while (0); \
78 eintr_wrapper_result; \
79 })
80
68 #endif 81 #endif
69 82
70 bool ReadMessage(PlatformFile file, size_t message_len, char* message) { 83 bool ReadMessage(PlatformFile file, size_t message_len, char* message) {
71 #if defined(OS_WIN) 84 #if defined(OS_WIN)
72 assert(message_len < std::numeric_limits<DWORD>::max()); 85 assert(message_len < std::numeric_limits<DWORD>::max());
73 DWORD read = 0; 86 DWORD read = 0;
74 const DWORD size = static_cast<DWORD>(message_len); 87 const DWORD size = static_cast<DWORD>(message_len);
75 return ::ReadFile(file, message, size, &read, NULL) && read == size; 88 return ::ReadFile(file, message, size, &read, NULL) && read == size;
76 #elif defined(OS_POSIX) 89 #elif defined(OS_POSIX)
77 assert(message_len < 90 assert(message_len <
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 bool success = ReadMessage(file, message_len, message_received) && 127 bool success = ReadMessage(file, message_len, message_received) &&
115 !::strcmp(message_received, message); 128 !::strcmp(message_received, message);
116 delete [] message_received; 129 delete [] message_received;
117 return success; 130 return success;
118 } 131 }
119 132
120 bool ClosePlatformFile(PlatformFile file) { 133 bool ClosePlatformFile(PlatformFile file) {
121 #if defined(OS_WIN) 134 #if defined(OS_WIN)
122 return !!::CloseHandle(file); 135 return !!::CloseHandle(file);
123 #elif defined(OS_POSIX) 136 #elif defined(OS_POSIX)
124 return !HANDLE_EINTR(::close(file)); 137 return !IGNORE_EINTR(::close(file));
125 #endif 138 #endif
126 } 139 }
127 140
128 bool VerifyIsUnsandboxed() { 141 bool VerifyIsUnsandboxed() {
129 #if defined(OS_WIN) 142 #if defined(OS_WIN)
130 FILE* file = NULL; 143 FILE* file = NULL;
131 wchar_t temp_path[MAX_PATH] = {'\0'}; 144 wchar_t temp_path[MAX_PATH] = {'\0'};
132 wchar_t file_name[MAX_PATH] = {'\0'}; 145 wchar_t file_name[MAX_PATH] = {'\0'};
133 if (!::GetTempPath(MAX_PATH, temp_path) || 146 if (!::GetTempPath(MAX_PATH, temp_path) ||
134 !::GetTempFileName(temp_path, L"test_pepper_broker", 0, file_name) || 147 !::GetTempFileName(temp_path, L"test_pepper_broker", 0, file_name) ||
135 ::_wfopen_s(&file, file_name, L"w")) 148 ::_wfopen_s(&file, file_name, L"w"))
136 return false; 149 return false;
137 150
138 if (::fclose(file)) { 151 if (::fclose(file)) {
139 ::DeleteFile(file_name); 152 ::DeleteFile(file_name);
140 return false; 153 return false;
141 } 154 }
142 155
143 return !!::DeleteFile(file_name); 156 return !!::DeleteFile(file_name);
144 #elif defined(OS_POSIX) 157 #elif defined(OS_POSIX)
145 char file_name[] = "/tmp/test_pepper_broker_XXXXXX"; 158 char file_name[] = "/tmp/test_pepper_broker_XXXXXX";
146 int fd = ::mkstemp(file_name); 159 int fd = ::mkstemp(file_name);
147 if (-1 == fd) 160 if (-1 == fd)
148 return false; 161 return false;
149 162
150 if (HANDLE_EINTR(::close(fd))) { 163 if (IGNORE_EINTR(::close(fd))) {
151 ::remove(file_name); 164 ::remove(file_name);
152 return false; 165 return false;
153 } 166 }
154 167
155 return !::remove(file_name); 168 return !::remove(file_name);
156 #endif 169 #endif
157 } 170 }
158 171
159 // Callback in the broker when a new broker connection occurs. 172 // Callback in the broker when a new broker connection occurs.
160 int32_t OnInstanceConnected(PP_Instance instance, int32_t handle) { 173 int32_t OnInstanceConnected(PP_Instance instance, int32_t handle) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 343 }
331 344
332 std::string TestBroker::TestIsAllowedPermissionGranted() { 345 std::string TestBroker::TestIsAllowedPermissionGranted() {
333 PP_Resource broker = broker_interface_->CreateTrusted( 346 PP_Resource broker = broker_interface_->CreateTrusted(
334 instance_->pp_instance()); 347 instance_->pp_instance());
335 ASSERT_TRUE(broker); 348 ASSERT_TRUE(broker);
336 ASSERT_EQ(PP_TRUE, broker_interface_->IsAllowed(broker)); 349 ASSERT_EQ(PP_TRUE, broker_interface_->IsAllowed(broker));
337 350
338 PASS(); 351 PASS();
339 } 352 }
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_dispatcher.cc ('k') | printing/pdf_metafile_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698