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

Side by Side Diff: third_party/crashpad/crashpad/handler/crash_report_upload_thread.cc

Issue 2710663006: Update Crashpad to 4a2043ea65e2641ef1a921801c0aaa15ada02fc7 (Closed)
Patch Set: Update Crashpad to 4a2043ea65e2 Created 3 years, 9 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,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 CrashReportDatabase* database_; // weak 132 CrashReportDatabase* database_; // weak
133 const CrashReportDatabase::Report* report_; // weak 133 const CrashReportDatabase::Report* report_; // weak
134 134
135 DISALLOW_COPY_AND_ASSIGN(CallRecordUploadAttempt); 135 DISALLOW_COPY_AND_ASSIGN(CallRecordUploadAttempt);
136 }; 136 };
137 137
138 } // namespace 138 } // namespace
139 139
140 CrashReportUploadThread::CrashReportUploadThread(CrashReportDatabase* database, 140 CrashReportUploadThread::CrashReportUploadThread(CrashReportDatabase* database,
141 const std::string& url, 141 const std::string& url,
142 bool rate_limit) 142 bool rate_limit,
143 bool upload_gzip)
143 : url_(url), 144 : url_(url),
144 // Check for pending reports every 15 minutes, even in the absence of a 145 // Check for pending reports every 15 minutes, even in the absence of a
145 // signal from the handler thread. This allows for failed uploads to be 146 // signal from the handler thread. This allows for failed uploads to be
146 // retried periodically, and for pending reports written by other 147 // retried periodically, and for pending reports written by other
147 // processes to be recognized. 148 // processes to be recognized.
148 thread_(15 * 60, this), 149 thread_(15 * 60, this),
149 database_(database), 150 database_(database),
150 rate_limit_(rate_limit) { 151 rate_limit_(rate_limit),
152 upload_gzip_(upload_gzip) {
151 } 153 }
152 154
153 CrashReportUploadThread::~CrashReportUploadThread() { 155 CrashReportUploadThread::~CrashReportUploadThread() {
154 } 156 }
155 157
156 void CrashReportUploadThread::Start() { 158 void CrashReportUploadThread::Start() {
157 thread_.Start(0); 159 thread_.Start(0);
158 } 160 }
159 161
160 void CrashReportUploadThread::Stop() { 162 void CrashReportUploadThread::Stop() {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 303 }
302 304
303 // If the minidump file could be opened, ignore any errors that might occur 305 // If the minidump file could be opened, ignore any errors that might occur
304 // when attempting to interpret it. This may result in its being uploaded 306 // when attempting to interpret it. This may result in its being uploaded
305 // with few or no parameters, but as long as there’s a dump file, the server 307 // with few or no parameters, but as long as there’s a dump file, the server
306 // can decide what to do with it. 308 // can decide what to do with it.
307 parameters = BreakpadHTTPFormParametersFromMinidump(&minidump_file_reader); 309 parameters = BreakpadHTTPFormParametersFromMinidump(&minidump_file_reader);
308 } 310 }
309 311
310 HTTPMultipartBuilder http_multipart_builder; 312 HTTPMultipartBuilder http_multipart_builder;
313 http_multipart_builder.SetGzipEnabled(upload_gzip_);
311 314
312 const char kMinidumpKey[] = "upload_file_minidump"; 315 const char kMinidumpKey[] = "upload_file_minidump";
313 316
314 for (const auto& kv : parameters) { 317 for (const auto& kv : parameters) {
315 if (kv.first == kMinidumpKey) { 318 if (kv.first == kMinidumpKey) {
316 LOG(WARNING) << "reserved key " << kv.first << ", discarding value " 319 LOG(WARNING) << "reserved key " << kv.first << ", discarding value "
317 << kv.second; 320 << kv.second;
318 } else { 321 } else {
319 http_multipart_builder.SetFormData(kv.first, kv.second); 322 http_multipart_builder.SetFormData(kv.first, kv.second);
320 } 323 }
321 } 324 }
322 325
323 http_multipart_builder.SetFileAttachment( 326 http_multipart_builder.SetFileAttachment(
324 kMinidumpKey, 327 kMinidumpKey,
325 #if defined(OS_WIN) 328 #if defined(OS_WIN)
326 base::UTF16ToUTF8(report->file_path.BaseName().value()), 329 base::UTF16ToUTF8(report->file_path.BaseName().value()),
327 #else 330 #else
328 report->file_path.BaseName().value(), 331 report->file_path.BaseName().value(),
329 #endif 332 #endif
330 report->file_path, 333 report->file_path,
331 "application/octet-stream"); 334 "application/octet-stream");
332 335
333 std::unique_ptr<HTTPTransport> http_transport(HTTPTransport::Create()); 336 std::unique_ptr<HTTPTransport> http_transport(HTTPTransport::Create());
334 http_transport->SetURL(url_); 337 http_transport->SetURL(url_);
335 HTTPHeaders::value_type content_type = 338 HTTPHeaders content_headers;
336 http_multipart_builder.GetContentType(); 339 http_multipart_builder.PopulateContentHeaders(&content_headers);
337 http_transport->SetHeader(content_type.first, content_type.second); 340 for (const auto& content_header : content_headers) {
341 http_transport->SetHeader(content_header.first, content_header.second);
342 }
338 http_transport->SetBodyStream(http_multipart_builder.GetBodyStream()); 343 http_transport->SetBodyStream(http_multipart_builder.GetBodyStream());
339 // TODO(mark): The timeout should be configurable by the client. 344 // TODO(mark): The timeout should be configurable by the client.
340 http_transport->SetTimeout(60.0); // 1 minute. 345 http_transport->SetTimeout(60.0); // 1 minute.
341 346
342 if (!http_transport->ExecuteSynchronously(response_body)) { 347 if (!http_transport->ExecuteSynchronously(response_body)) {
343 return UploadResult::kRetry; 348 return UploadResult::kRetry;
344 } 349 }
345 350
346 return UploadResult::kSuccess; 351 return UploadResult::kSuccess;
347 } 352 }
348 353
349 void CrashReportUploadThread::DoWork(const WorkerThread* thread) { 354 void CrashReportUploadThread::DoWork(const WorkerThread* thread) {
350 ProcessPendingReports(); 355 ProcessPendingReports();
351 } 356 }
352 357
353 } // namespace crashpad 358 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698