Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (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 | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 #ifndef CRASHPAD_UTIL_WIN_EXCEPTION_HANDLER_SERVER_H_ | |
| 16 #define CRASHPAD_UTIL_WIN_EXCEPTION_HANDLER_SERVER_H_ | |
| 17 | |
| 18 #include <map> | |
| 19 #include <set> | |
| 20 #include <string> | |
| 21 | |
| 22 #include "base/basictypes.h" | |
| 23 #include "base/synchronization/lock.h" | |
| 24 #include "util/win/address_types.h" | |
| 25 #include "util/win/scoped_handle.h" | |
| 26 | |
| 27 namespace crashpad { | |
| 28 | |
| 29 namespace internal { | |
| 30 class ClientData; | |
| 31 } // namespace internal | |
| 32 | |
| 33 //! \brief Runs the main exception-handling server in Crashpad's handler | |
| 34 //! process. | |
| 35 class ExceptionHandlerServer { | |
| 36 public: | |
| 37 class Delegate { | |
| 38 public: | |
| 39 virtual ~Delegate(); | |
| 40 | |
| 41 virtual void OnStarted() = 0; | |
|
Mark Mentovai
2015/08/26 21:40:28
I like to name interface methods according to thei
scottmg
2015/08/27 01:04:38
Done.
| |
| 42 virtual void OnException(HANDLE process, | |
| 43 WinVMAddress exception_information_address) = 0; | |
| 44 virtual void OnShutdown() = 0; | |
| 45 }; | |
| 46 | |
| 47 //! \brief Constructs the exception handling server. | |
| 48 //! | |
| 49 //! \param[in] delegate The interface to which the exceptions are delegated | |
| 50 //! when they are caught in Run(). Ownership is not transferred and it | |
| 51 //! must outlive this object. | |
| 52 explicit ExceptionHandlerServer(Delegate* delegate); | |
| 53 ~ExceptionHandlerServer(); | |
| 54 | |
| 55 //! \brief Runs the exception-handling server. | |
| 56 //! | |
| 57 //! \param[in] pipe_name The name of the pipe to listen on. Must be of the | |
| 58 //! form "\\.\pipe\<some_name>". | |
| 59 void Run(const std::string& pipe_name); | |
| 60 | |
| 61 //! \brief Stops the exception-handling server. Returns immediately. The | |
| 62 //! object must not be destroyed until Run() returns. | |
| 63 void Stop(); | |
| 64 | |
| 65 private: | |
| 66 static DWORD __stdcall PipeServiceProc(void* ctx); | |
| 67 static void __stdcall OnDumpEvent(void* ctx, BOOLEAN); | |
| 68 static void __stdcall OnProcessEnd(void* ctx, BOOLEAN); | |
| 69 | |
| 70 Delegate* delegate_; // Weak. | |
| 71 ScopedKernelHANDLE port_; | |
| 72 | |
| 73 base::Lock clients_lock_; | |
| 74 std::set<internal::ClientData*> clients_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); | |
| 77 }; | |
| 78 | |
| 79 } // namespace crashpad | |
| 80 | |
| 81 #endif // CRASHPAD_UTIL_WIN_EXCEPTION_HANDLER_SERVER_H_ | |
| OLD | NEW |