 Chromium Code Reviews
 Chromium Code Reviews Issue 1213723004:
  Implement a Windows crash client registrar.  (Closed) 
  Base URL: https://chromium.googlesource.com/crashpad/crashpad@child_process
    
  
    Issue 1213723004:
  Implement a Windows crash client registrar.  (Closed) 
  Base URL: https://chromium.googlesource.com/crashpad/crashpad@child_process| 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_HANDLER_WIN_REGISTRAR_H_ | |
| 16 #define CRASHPAD_HANDLER_WIN_REGISTRAR_H_ | |
| 17 | |
| 18 #include <windows.h> | |
| 19 | |
| 20 #include "base/basictypes.h" | |
| 21 #include "base/memory/scoped_ptr.h" | |
| 22 #include "util/stdlib/pointer_container.h" | |
| 23 #include "util/win/scoped_handle.h" | |
| 24 | |
| 25 namespace crashpad { | |
| 26 | |
| 27 //! \brief Registers, tracks, and dispatches crash reporting requests for client | |
| 28 //! processes. This class is multi-threaded and thread-safe. The | |
| 29 //! constructor, destructor, and public methods may be invoked from any | |
| 30 //! thread. | |
| 31 class Registrar { | |
| 32 public: | |
| 33 //! \brief Handles crash reporting requests. The delegate may be invoked or | |
| 34 //! destroyed on any thread. | |
| 35 class Delegate { | |
| 36 public: | |
| 37 virtual ~Delegate() {} | |
| 38 | |
| 39 //! \brief Generates a crash report. Must complete synchronously. Must not | |
| 40 //! re-enter the Registrar instance. May be invoked concurrently on | |
| 41 //! multiple threads. | |
| 42 //! | |
| 43 //! \param client_process A handle to the process to report on. | |
| 44 virtual void GenerateReportForClient(HANDLE client_process) = 0; | |
| 45 }; | |
| 46 | |
| 47 //! \brief Instantiates a Registrar. | |
| 48 //! \param delegate The delegate that will handle crash reporting requests. | |
| 49 explicit Registrar(scoped_ptr<Delegate> delegate); | |
| 50 | |
| 51 //! \brief Destroys the registrar. Blocks until all background operations | |
| 52 //! (including report generation operations) complete. | |
| 53 ~Registrar(); | |
| 54 | |
| 55 //! \brief Registers a process for crash reporting. The process remains | |
| 56 //! registered until it exits or the registrar is destroyed. | |
| 57 //! \param client_process The client to register. | |
| 
scottmg
2015/06/29 20:29:05
I think it needs a \n before \param line here.
 
scottmg
2015/06/29 20:29:05
\param lines are one of \param[in], \param[out], o
 | |
| 58 //! \param request_report_event Receives a HANDLE, valid in the client | |
| 59 //! process, to an event that should be signaled to request a report. | |
| 60 //! \param report_complete_event Receives a HANDLE, valid in the client | |
| 61 //! process, to an event that will be signaled when the report is | |
| 62 //! generated. | |
| 63 //! \return True if successful. | |
| 64 bool RegisterProcess(ScopedKernelHANDLE client_process, | |
| 65 HANDLE* request_report_event, | |
| 66 HANDLE* report_complete_event); | |
| 67 | |
| 68 private: | |
| 69 // Stores per-registration state. | |
| 70 struct Entry; | |
| 71 | |
| 72 // Forwards a report request to the Delegate instance. | |
| 73 void OnRequestReport(Entry* entry); | |
| 74 | |
| 75 // Unregisters a client process that has exited. | |
| 76 void OnProcessExit(Entry* entry); | |
| 77 | |
| 78 // Registers ReportRequestCallback and ProcessExitCallback for |entry|. | |
| 79 // Returns the wait handles (which must eventually be freed with | |
| 80 // UnregisterWaitEx) and true if successful. | |
| 81 static bool RegisterWaits(Entry* entry, | |
| 82 HANDLE* request_report_event_wait_handle, | |
| 83 HANDLE* process_exit_wait_handle); | |
| 84 | |
| 85 // Static callbacks that forward to OnRequestReport and OnProcessExit. | |
| 86 static VOID CALLBACK | |
| 87 ReportRequestCallback(PVOID lpParameter, BOOLEAN /* TimerOrWaitFired */); | |
| 88 static VOID CALLBACK | |
| 89 ProcessExitCallback(PVOID lpParameter, BOOLEAN /* TimerOrWaitFired */); | |
| 90 | |
| 91 scoped_ptr<Delegate> delegate_; | |
| 92 | |
| 93 // Protects |entries_|. | |
| 94 ScopedKernelHANDLE mutex_; | |
| 95 PointerVector<Entry> entries_; | |
| 96 | |
| 97 DISALLOW_COPY_AND_ASSIGN(Registrar); | |
| 98 }; | |
| 99 | |
| 100 } // namespace crashpad | |
| 101 | |
| 102 #endif // CRASHPAD_HANDLER_WIN_REGISTRAR_H_ | |
| OLD | NEW |