Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(790)

Side by Side Diff: util/win/exception_handler_server.h

Issue 1432563003: win: crashpad_handler should create its own pipe name in ephemeral mode (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: --help Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « util/win/command_line_test.cc ('k') | util/win/exception_handler_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #ifndef CRASHPAD_UTIL_WIN_EXCEPTION_HANDLER_SERVER_H_ 15 #ifndef CRASHPAD_UTIL_WIN_EXCEPTION_HANDLER_SERVER_H_
16 #define CRASHPAD_UTIL_WIN_EXCEPTION_HANDLER_SERVER_H_ 16 #define CRASHPAD_UTIL_WIN_EXCEPTION_HANDLER_SERVER_H_
17 17
18 #include <set> 18 #include <set>
19 #include <string> 19 #include <string>
20 20
21 #include "base/basictypes.h" 21 #include "base/basictypes.h"
22 #include "base/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
23 #include "util/file/file_io.h"
23 #include "util/win/address_types.h" 24 #include "util/win/address_types.h"
24 #include "util/win/scoped_handle.h" 25 #include "util/win/scoped_handle.h"
25 26
26 namespace crashpad { 27 namespace crashpad {
27 28
28 namespace internal { 29 namespace internal {
29 class PipeServiceContext; 30 class PipeServiceContext;
30 class ClientData; 31 class ClientData;
31 } // namespace internal 32 } // namespace internal
32 33
(...skipping 22 matching lines...) Expand all
55 //! \return The exit code that should be used when terminating the client 56 //! \return The exit code that should be used when terminating the client
56 //! process. 57 //! process.
57 virtual unsigned int ExceptionHandlerServerException( 58 virtual unsigned int ExceptionHandlerServerException(
58 HANDLE process, 59 HANDLE process,
59 WinVMAddress exception_information_address, 60 WinVMAddress exception_information_address,
60 WinVMAddress debug_critical_section_address) = 0; 61 WinVMAddress debug_critical_section_address) = 0;
61 }; 62 };
62 63
63 //! \brief Constructs the exception handling server. 64 //! \brief Constructs the exception handling server.
64 //! 65 //!
65 //! \param[in] pipe_name The name of the pipe to listen on. Must be of the
66 //! form "\\.\pipe\<some_name>".
67 //! \param[in] persistent `true` if Run() should not return until Stop() is 66 //! \param[in] persistent `true` if Run() should not return until Stop() is
68 //! called. If `false`, Run() will return when all clients have exited, 67 //! called. If `false`, Run() will return when all clients have exited,
69 //! although Run() will always wait for the first client to connect. 68 //! although Run() will always wait for the first client to connect.
70 ExceptionHandlerServer(const std::string& pipe_name, bool persistent); 69 explicit ExceptionHandlerServer(bool persistent);
71 70
72 ~ExceptionHandlerServer(); 71 ~ExceptionHandlerServer();
73 72
73 //! \brief Sets the pipe name to listen for client registrations on.
74 //!
75 //! Either this method or CreatePipe(), but not both, must be called before
76 //! Run().
77 //!
78 //! \param[in] pipe_name The name of the pipe to listen on. Must be of the
79 //! form "\\.\pipe\<some_name>".
80 void SetPipeName(const std::wstring& pipe_name);
81
82 //! \brief Creates a randomized pipe name to listen for client registrations
83 //! on and returns its name.
84 //!
85 //! Either this method or CreatePipe(), but not both, must be called before
86 //! Run().
87 //!
88 //! \return The pipe name that will be listened on.
89 std::wstring CreatePipe();
90
74 //! \brief Runs the exception-handling server. 91 //! \brief Runs the exception-handling server.
75 //! 92 //!
76 //! \param[in] delegate The interface to which the exceptions are delegated 93 //! \param[in] delegate The interface to which the exceptions are delegated
77 //! when they are caught in Run(). Ownership is not transferred. 94 //! when they are caught in Run(). Ownership is not transferred.
78 void Run(Delegate* delegate); 95 void Run(Delegate* delegate);
79 96
80 //! \brief Stops the exception-handling server. Returns immediately. The 97 //! \brief Stops the exception-handling server. Returns immediately. The
81 //! object must not be destroyed until Run() returns. 98 //! object must not be destroyed until Run() returns.
82 void Stop(); 99 void Stop();
83 100
84 private: 101 private:
85 static bool ServiceClientConnection( 102 static bool ServiceClientConnection(
86 const internal::PipeServiceContext& service_context); 103 const internal::PipeServiceContext& service_context);
87 static DWORD __stdcall PipeServiceProc(void* ctx); 104 static DWORD __stdcall PipeServiceProc(void* ctx);
88 static void __stdcall OnCrashDumpEvent(void* ctx, BOOLEAN); 105 static void __stdcall OnCrashDumpEvent(void* ctx, BOOLEAN);
89 static void __stdcall OnNonCrashDumpEvent(void* ctx, BOOLEAN); 106 static void __stdcall OnNonCrashDumpEvent(void* ctx, BOOLEAN);
90 static void __stdcall OnProcessEnd(void* ctx, BOOLEAN); 107 static void __stdcall OnProcessEnd(void* ctx, BOOLEAN);
91 108
92 std::string pipe_name_; 109 std::wstring pipe_name_;
93 ScopedKernelHANDLE port_; 110 ScopedKernelHANDLE port_;
111 ScopedFileHandle first_pipe_instance_;
94 112
95 base::Lock clients_lock_; 113 base::Lock clients_lock_;
96 std::set<internal::ClientData*> clients_; 114 std::set<internal::ClientData*> clients_;
97 115
98 bool persistent_; 116 bool persistent_;
99 117
100 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); 118 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer);
101 }; 119 };
102 120
103 } // namespace crashpad 121 } // namespace crashpad
104 122
105 #endif // CRASHPAD_UTIL_WIN_EXCEPTION_HANDLER_SERVER_H_ 123 #endif // CRASHPAD_UTIL_WIN_EXCEPTION_HANDLER_SERVER_H_
OLDNEW
« no previous file with comments | « util/win/command_line_test.cc ('k') | util/win/exception_handler_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698