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