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

Side by Side Diff: handler/crash_report_upload_thread.h

Issue 1295363002: Port CrashReportUploadThread to Windows (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: build_config Created 5 years, 4 months 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
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_HANDLER_MAC_CRASH_REPORT_UPLOAD_THREAD_H_ 15 #ifndef CRASHPAD_HANDLER_CRASH_REPORT_UPLOAD_THREAD_H_
16 #define CRASHPAD_HANDLER_MAC_CRASH_REPORT_UPLOAD_THREAD_H_ 16 #define CRASHPAD_HANDLER_CRASH_REPORT_UPLOAD_THREAD_H_
17 17
18 #include "base/basictypes.h" 18 #include "base/basictypes.h"
19 19
20 #include <pthread.h>
21
22 #include <string> 20 #include <string>
23 21
22 #include "base/memory/scoped_ptr.h"
24 #include "client/crash_report_database.h" 23 #include "client/crash_report_database.h"
25 #include "util/synchronization/semaphore.h" 24 #include "util/synchronization/semaphore.h"
26 25
27 namespace crashpad { 26 namespace crashpad {
28 27
28 class HelperThread;
Mark Mentovai 2015/08/18 21:38:12 Since this is just in namespace crashpad, you shou
scottmg 2015/08/18 22:21:40 Done.
29
29 //! \brief A thread that processes pending crash reports in a 30 //! \brief A thread that processes pending crash reports in a
30 //! CrashReportDatabase by uploading them or marking them as completed 31 //! CrashReportDatabase by uploading them or marking them as completed
31 //! without upload, as desired. 32 //! without upload, as desired.
32 //! 33 //!
33 //! A producer of crash reports should notify an object of this class that a new 34 //! A producer of crash reports should notify an object of this class that a new
34 //! report has been added to the database by calling ReportPending(). 35 //! report has been added to the database by calling ReportPending().
35 //! 36 //!
36 //! Independently of being triggered by ReportPending(), objects of this class 37 //! Independently of being triggered by ReportPending(), objects of this class
37 //! periodically examine the database for pending reports. This allows failed 38 //! periodically examine the database for pending reports. This allows failed
38 //! upload attempts for reports left in the pending state to be retried. It also 39 //! upload attempts for reports left in the pending state to be retried. It also
(...skipping 30 matching lines...) Expand all
69 //! It is expected to only be called from the same thread that called Start(). 70 //! It is expected to only be called from the same thread that called Start().
70 void Stop(); 71 void Stop();
71 72
72 //! \brief Informs the upload thread that a new pending report has been added 73 //! \brief Informs the upload thread that a new pending report has been added
73 //! to the database. 74 //! to the database.
74 //! 75 //!
75 //! This method may be called from any thread. 76 //! This method may be called from any thread.
76 void ReportPending(); 77 void ReportPending();
77 78
78 private: 79 private:
80 friend class HelperThread;
81
79 //! \brief The result code from UploadReport(). 82 //! \brief The result code from UploadReport().
80 enum class UploadResult { 83 enum class UploadResult {
81 //! \brief The crash report was uploaded successfully. 84 //! \brief The crash report was uploaded successfully.
82 kSuccess, 85 kSuccess,
83 86
84 //! \brief The crash report upload failed in such a way that recovery is 87 //! \brief The crash report upload failed in such a way that recovery is
85 //! impossible. 88 //! impossible.
86 //! 89 //!
87 //! No further upload attempts should be made for the report. 90 //! No further upload attempts should be made for the report.
88 kPermanentFailure, 91 kPermanentFailure,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 //! CrashReportDatabase::RecordUploadAttempt() after calling this method. 129 //! CrashReportDatabase::RecordUploadAttempt() after calling this method.
127 //! \param[out] response_body If the upload attempt is successful, this will 130 //! \param[out] response_body If the upload attempt is successful, this will
128 //! be set to the response body sent by the server. Breakpad-type servers 131 //! be set to the response body sent by the server. Breakpad-type servers
129 //! provide the crash ID assigned by the server in the response body. 132 //! provide the crash ID assigned by the server in the response body.
130 //! 133 //!
131 //! \return A member of UploadResult indicating the result of the upload 134 //! \return A member of UploadResult indicating the result of the upload
132 //! attempt. 135 //! attempt.
133 UploadResult UploadReport(const CrashReportDatabase::Report* report, 136 UploadResult UploadReport(const CrashReportDatabase::Report* report,
134 std::string* response_body); 137 std::string* response_body);
135 138
136 //! \brief Cals ThreadMain().
137 //!
138 //! \param[in] arg A pointer to the object on which to invoke ThreadMain().
139 //!
140 //! \return `nullptr`.
141 static void* RunThreadMain(void* arg);
142
143 std::string url_; 139 std::string url_;
144 CrashReportDatabase* database_; // weak 140 CrashReportDatabase* database_; // weak
145 Semaphore semaphore_; // TODO(mark): Use a condition variable instead? 141 Semaphore semaphore_; // TODO(mark): Use a condition variable instead?
146 pthread_t thread_; 142 scoped_ptr<HelperThread> thread_;
147 bool running_; 143 bool running_;
148 }; 144 };
149 145
150 } // namespace crashpad 146 } // namespace crashpad
151 147
152 #endif // CRASHPAD_HANDLER_MAC_CRASH_REPORT_UPLOAD_THREAD_H_ 148 #endif // CRASHPAD_HANDLER_CRASH_REPORT_UPLOAD_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | handler/crash_report_upload_thread.cc » ('j') | handler/crash_report_upload_thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698