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