Chromium Code Reviews| Index: handler/win/registrar.h |
| diff --git a/handler/win/registrar.h b/handler/win/registrar.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0ee9774b8c29702f7a07cfa43088cdb06ad4ba65 |
| --- /dev/null |
| +++ b/handler/win/registrar.h |
| @@ -0,0 +1,102 @@ |
| +// Copyright 2015 The Crashpad Authors. All rights reserved. |
| +// |
| +// Licensed under the Apache License, Version 2.0 (the "License"); |
| +// you may not use this file except in compliance with the License. |
| +// You may obtain a copy of the License at |
| +// |
| +// http://www.apache.org/licenses/LICENSE-2.0 |
| +// |
| +// Unless required by applicable law or agreed to in writing, software |
| +// distributed under the License is distributed on an "AS IS" BASIS, |
| +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| +// See the License for the specific language governing permissions and |
| +// limitations under the License. |
| + |
| +#ifndef CRASHPAD_HANDLER_WIN_REGISTRAR_H_ |
| +#define CRASHPAD_HANDLER_WIN_REGISTRAR_H_ |
| + |
| +#include <windows.h> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "util/stdlib/pointer_container.h" |
| +#include "util/win/scoped_handle.h" |
| + |
| +namespace crashpad { |
| + |
| +//! \brief Registers, tracks, and dispatches crash reporting requests for client |
| +//! processes. This class is multi-threaded and thread-safe. The |
| +//! constructor, destructor, and public methods may be invoked from any |
| +//! thread. |
| +class Registrar { |
| + public: |
| + //! \brief Handles crash reporting requests. The delegate may be invoked or |
| + //! destroyed on any thread. |
| + class Delegate { |
| + public: |
| + virtual ~Delegate() {} |
| + |
| + //! \brief Generates a crash report. Must complete synchronously. Must not |
| + //! re-enter the Registrar instance. May be invoked concurrently on |
| + //! multiple threads. |
| + //! |
| + //! \param client_process A handle to the process to report on. |
| + virtual void GenerateReportForClient(HANDLE client_process) = 0; |
| + }; |
| + |
| + //! \brief Instantiates a Registrar. |
| + //! \param delegate The delegate that will handle crash reporting requests. |
| + explicit Registrar(scoped_ptr<Delegate> delegate); |
| + |
| + //! \brief Destroys the registrar. Blocks until all background operations |
| + //! (including report generation operations) complete. |
| + ~Registrar(); |
| + |
| + //! \brief Registers a process for crash reporting. The process remains |
| + //! registered until it exits or the registrar is destroyed. |
| + //! \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
|
| + //! \param request_report_event Receives a HANDLE, valid in the client |
| + //! process, to an event that should be signaled to request a report. |
| + //! \param report_complete_event Receives a HANDLE, valid in the client |
| + //! process, to an event that will be signaled when the report is |
| + //! generated. |
| + //! \return True if successful. |
| + bool RegisterProcess(ScopedKernelHANDLE client_process, |
| + HANDLE* request_report_event, |
| + HANDLE* report_complete_event); |
| + |
| + private: |
| + // Stores per-registration state. |
| + struct Entry; |
| + |
| + // Forwards a report request to the Delegate instance. |
| + void OnRequestReport(Entry* entry); |
| + |
| + // Unregisters a client process that has exited. |
| + void OnProcessExit(Entry* entry); |
| + |
| + // Registers ReportRequestCallback and ProcessExitCallback for |entry|. |
| + // Returns the wait handles (which must eventually be freed with |
| + // UnregisterWaitEx) and true if successful. |
| + static bool RegisterWaits(Entry* entry, |
| + HANDLE* request_report_event_wait_handle, |
| + HANDLE* process_exit_wait_handle); |
| + |
| + // Static callbacks that forward to OnRequestReport and OnProcessExit. |
| + static VOID CALLBACK |
| + ReportRequestCallback(PVOID lpParameter, BOOLEAN /* TimerOrWaitFired */); |
| + static VOID CALLBACK |
| + ProcessExitCallback(PVOID lpParameter, BOOLEAN /* TimerOrWaitFired */); |
| + |
| + scoped_ptr<Delegate> delegate_; |
| + |
| + // Protects |entries_|. |
| + ScopedKernelHANDLE mutex_; |
| + PointerVector<Entry> entries_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Registrar); |
| +}; |
| + |
| +} // namespace crashpad |
| + |
| +#endif // CRASHPAD_HANDLER_WIN_REGISTRAR_H_ |