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

Side by Side Diff: snapshot/win/exception_snapshot_win_test.cc

Issue 1409073013: mac: Make crashpad_handler get its receive right from its client (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « handler/main.cc ('k') | util/mach/child_port_handshake.h » ('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 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 23 matching lines...) Expand all
34 34
35 namespace crashpad { 35 namespace crashpad {
36 namespace test { 36 namespace test {
37 namespace { 37 namespace {
38 38
39 // Runs the ExceptionHandlerServer on a background thread. 39 // Runs the ExceptionHandlerServer on a background thread.
40 class RunServerThread : public Thread { 40 class RunServerThread : public Thread {
41 public: 41 public:
42 // Instantiates a thread which will invoke server->Run(delegate, pipe_name); 42 // Instantiates a thread which will invoke server->Run(delegate, pipe_name);
43 RunServerThread(ExceptionHandlerServer* server, 43 RunServerThread(ExceptionHandlerServer* server,
44 ExceptionHandlerServer::Delegate* delegate) 44 ExceptionHandlerServer::Delegate* delegate,
45 : server_(server), delegate_(delegate) {} 45 const std::string& pipe_name)
46 : server_(server), delegate_(delegate), pipe_name_(pipe_name) {}
46 ~RunServerThread() override {} 47 ~RunServerThread() override {}
47 48
48 private: 49 private:
49 // Thread: 50 // Thread:
50 void ThreadMain() override { server_->Run(delegate_); } 51 void ThreadMain() override { server_->Run(delegate_, pipe_name_); }
51 52
52 ExceptionHandlerServer* server_; 53 ExceptionHandlerServer* server_;
53 ExceptionHandlerServer::Delegate* delegate_; 54 ExceptionHandlerServer::Delegate* delegate_;
55 std::string pipe_name_;
54 56
55 DISALLOW_COPY_AND_ASSIGN(RunServerThread); 57 DISALLOW_COPY_AND_ASSIGN(RunServerThread);
56 }; 58 };
57 59
58 // During destruction, ensures that the server is stopped and the background 60 // During destruction, ensures that the server is stopped and the background
59 // thread joined. 61 // thread joined.
60 class ScopedStopServerAndJoinThread { 62 class ScopedStopServerAndJoinThread {
61 public: 63 public:
62 ScopedStopServerAndJoinThread(ExceptionHandlerServer* server, Thread* thread) 64 ScopedStopServerAndJoinThread(ExceptionHandlerServer* server, Thread* thread)
63 : server_(server), thread_(thread) {} 65 : server_(server), thread_(thread) {}
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 }; 123 };
122 124
123 void TestCrashingChild(const base::string16& directory_modification) { 125 void TestCrashingChild(const base::string16& directory_modification) {
124 // Set up the registration server on a background thread. 126 // Set up the registration server on a background thread.
125 std::string pipe_name = "\\\\.\\pipe\\handler_test_pipe_" + 127 std::string pipe_name = "\\\\.\\pipe\\handler_test_pipe_" +
126 base::StringPrintf("%08x", GetCurrentProcessId()); 128 base::StringPrintf("%08x", GetCurrentProcessId());
127 ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr)); 129 ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr));
128 ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr)); 130 ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr));
129 CrashingDelegate delegate(server_ready.get(), completed.get()); 131 CrashingDelegate delegate(server_ready.get(), completed.get());
130 132
131 ExceptionHandlerServer exception_handler_server(pipe_name); 133 ExceptionHandlerServer exception_handler_server;
132 RunServerThread server_thread(&exception_handler_server, &delegate); 134 RunServerThread server_thread(
135 &exception_handler_server, &delegate, pipe_name);
133 server_thread.Start(); 136 server_thread.Start();
134 ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread( 137 ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread(
135 &exception_handler_server, &server_thread); 138 &exception_handler_server, &server_thread);
136 139
137 WaitForSingleObject(server_ready.get(), INFINITE); 140 WaitForSingleObject(server_ready.get(), INFINITE);
138 141
139 // Spawn a child process, passing it the pipe name to connect to. 142 // Spawn a child process, passing it the pipe name to connect to.
140 base::FilePath test_executable = Paths::Executable(); 143 base::FilePath test_executable = Paths::Executable();
141 std::wstring child_test_executable = 144 std::wstring child_test_executable =
142 test_executable.DirName() 145 test_executable.DirName()
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 226
224 void TestDumpWithoutCrashingChild( 227 void TestDumpWithoutCrashingChild(
225 const base::string16& directory_modification) { 228 const base::string16& directory_modification) {
226 // Set up the registration server on a background thread. 229 // Set up the registration server on a background thread.
227 std::string pipe_name = "\\\\.\\pipe\\handler_test_pipe_" + 230 std::string pipe_name = "\\\\.\\pipe\\handler_test_pipe_" +
228 base::StringPrintf("%08x", GetCurrentProcessId()); 231 base::StringPrintf("%08x", GetCurrentProcessId());
229 ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr)); 232 ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr));
230 ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr)); 233 ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr));
231 SimulateDelegate delegate(server_ready.get(), completed.get()); 234 SimulateDelegate delegate(server_ready.get(), completed.get());
232 235
233 ExceptionHandlerServer exception_handler_server(pipe_name); 236 ExceptionHandlerServer exception_handler_server;
234 RunServerThread server_thread(&exception_handler_server, &delegate); 237 RunServerThread server_thread(
238 &exception_handler_server, &delegate, pipe_name);
235 server_thread.Start(); 239 server_thread.Start();
236 ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread( 240 ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread(
237 &exception_handler_server, &server_thread); 241 &exception_handler_server, &server_thread);
238 242
239 WaitForSingleObject(server_ready.get(), INFINITE); 243 WaitForSingleObject(server_ready.get(), INFINITE);
240 244
241 // Spawn a child process, passing it the pipe name to connect to. 245 // Spawn a child process, passing it the pipe name to connect to.
242 base::FilePath test_executable = Paths::Executable(); 246 base::FilePath test_executable = Paths::Executable();
243 std::wstring child_test_executable = 247 std::wstring child_test_executable =
244 test_executable.DirName() 248 test_executable.DirName()
(...skipping 25 matching lines...) Expand all
270 TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Debug")); 274 TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Debug"));
271 #else 275 #else
272 TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Release")); 276 TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Release"));
273 #endif 277 #endif
274 } 278 }
275 #endif // ARCH_CPU_64_BITS 279 #endif // ARCH_CPU_64_BITS
276 280
277 } // namespace 281 } // namespace
278 } // namespace test 282 } // namespace test
279 } // namespace crashpad 283 } // namespace crashpad
OLDNEW
« no previous file with comments | « handler/main.cc ('k') | util/mach/child_port_handshake.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698