OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 #include "util/win/registration_protocol_win.h" | 29 #include "util/win/registration_protocol_win.h" |
30 #include "util/win/scoped_handle.h" | 30 #include "util/win/scoped_handle.h" |
31 | 31 |
32 namespace crashpad { | 32 namespace crashpad { |
33 namespace test { | 33 namespace test { |
34 namespace { | 34 namespace { |
35 | 35 |
36 // Runs the ExceptionHandlerServer on a background thread. | 36 // Runs the ExceptionHandlerServer on a background thread. |
37 class RunServerThread : public Thread { | 37 class RunServerThread : public Thread { |
38 public: | 38 public: |
39 // Instantiates a thread which will invoke server->Run(delegate). | 39 // Instantiates a thread which will invoke server->Run(delegate, pipe_name). |
40 RunServerThread(ExceptionHandlerServer* server, | 40 RunServerThread(ExceptionHandlerServer* server, |
41 ExceptionHandlerServer::Delegate* delegate) | 41 ExceptionHandlerServer::Delegate* delegate, |
42 : server_(server), delegate_(delegate) {} | 42 const std::string& pipe_name) |
| 43 : server_(server), delegate_(delegate), pipe_name_(pipe_name) {} |
43 ~RunServerThread() override {} | 44 ~RunServerThread() override {} |
44 | 45 |
45 private: | 46 private: |
46 // Thread: | 47 // Thread: |
47 void ThreadMain() override { server_->Run(delegate_); } | 48 void ThreadMain() override { server_->Run(delegate_, pipe_name_); } |
48 | 49 |
49 ExceptionHandlerServer* server_; | 50 ExceptionHandlerServer* server_; |
50 ExceptionHandlerServer::Delegate* delegate_; | 51 ExceptionHandlerServer::Delegate* delegate_; |
| 52 std::string pipe_name_; |
51 | 53 |
52 DISALLOW_COPY_AND_ASSIGN(RunServerThread); | 54 DISALLOW_COPY_AND_ASSIGN(RunServerThread); |
53 }; | 55 }; |
54 | 56 |
55 class TestDelegate : public ExceptionHandlerServer::Delegate { | 57 class TestDelegate : public ExceptionHandlerServer::Delegate { |
56 public: | 58 public: |
57 explicit TestDelegate(HANDLE server_ready) : server_ready_(server_ready) {} | 59 explicit TestDelegate(HANDLE server_ready) : server_ready_(server_ready) {} |
58 ~TestDelegate() override {} | 60 ~TestDelegate() override {} |
59 | 61 |
60 void ExceptionHandlerServerStarted() override { | 62 void ExceptionHandlerServerStarted() override { |
(...skipping 15 matching lines...) Expand all Loading... |
76 DISALLOW_COPY_AND_ASSIGN(TestDelegate); | 78 DISALLOW_COPY_AND_ASSIGN(TestDelegate); |
77 }; | 79 }; |
78 | 80 |
79 class ExceptionHandlerServerTest : public testing::Test { | 81 class ExceptionHandlerServerTest : public testing::Test { |
80 public: | 82 public: |
81 ExceptionHandlerServerTest() | 83 ExceptionHandlerServerTest() |
82 : pipe_name_("\\\\.\\pipe\\exception_handler_server_test_pipe_" + | 84 : pipe_name_("\\\\.\\pipe\\exception_handler_server_test_pipe_" + |
83 base::StringPrintf("%08x", GetCurrentProcessId())), | 85 base::StringPrintf("%08x", GetCurrentProcessId())), |
84 server_ready_(CreateEvent(nullptr, false, false, nullptr)), | 86 server_ready_(CreateEvent(nullptr, false, false, nullptr)), |
85 delegate_(server_ready_.get()), | 87 delegate_(server_ready_.get()), |
86 server_(pipe_name_), | 88 server_(), |
87 server_thread_(&server_, &delegate_) {} | 89 server_thread_(&server_, &delegate_, pipe_name_) {} |
88 | 90 |
89 TestDelegate& delegate() { return delegate_; } | 91 TestDelegate& delegate() { return delegate_; } |
90 ExceptionHandlerServer& server() { return server_; } | 92 ExceptionHandlerServer& server() { return server_; } |
91 Thread& server_thread() { return server_thread_; } | 93 Thread& server_thread() { return server_thread_; } |
92 const std::string& pipe_name() const { return pipe_name_; } | 94 const std::string& pipe_name() const { return pipe_name_; } |
93 | 95 |
94 private: | 96 private: |
95 std::string pipe_name_; | 97 std::string pipe_name_; |
96 ScopedKernelHANDLE server_ready_; | 98 ScopedKernelHANDLE server_ready_; |
97 TestDelegate delegate_; | 99 TestDelegate delegate_; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 201 |
200 ASSERT_EQ("OK", ReadString(handles_3->read.get())); | 202 ASSERT_EQ("OK", ReadString(handles_3->read.get())); |
201 ASSERT_EQ("OK", ReadString(handles_2->read.get())); | 203 ASSERT_EQ("OK", ReadString(handles_2->read.get())); |
202 ASSERT_EQ("OK", ReadString(handles_1->read.get())); | 204 ASSERT_EQ("OK", ReadString(handles_1->read.get())); |
203 } | 205 } |
204 } | 206 } |
205 | 207 |
206 } // namespace | 208 } // namespace |
207 } // namespace test | 209 } // namespace test |
208 } // namespace crashpad | 210 } // namespace crashpad |
OLD | NEW |