OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/crash/content/browser/crash_handler_host_linux.h" | 5 #include "components/crash/content/browser/crash_handler_host_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 CrashHandlerHostLinux::CrashHandlerHostLinux(const std::string& process_type, | 94 CrashHandlerHostLinux::CrashHandlerHostLinux(const std::string& process_type, |
95 const base::FilePath& dumps_path, | 95 const base::FilePath& dumps_path, |
96 bool upload) | 96 bool upload) |
97 : process_type_(process_type), | 97 : process_type_(process_type), |
98 dumps_path_(dumps_path), | 98 dumps_path_(dumps_path), |
99 #if !defined(OS_ANDROID) | 99 #if !defined(OS_ANDROID) |
100 upload_(upload), | 100 upload_(upload), |
101 #endif | 101 #endif |
102 shutting_down_(false), | 102 shutting_down_(false), |
103 worker_pool_token_(base::SequencedWorkerPool::GetSequenceToken()) { | 103 worker_pool_token_(base::SequencedWorkerPool::GetSequenceToken()) { |
| 104 write_dump_file_sequence_checker_.DetachFromSequence(); |
| 105 |
104 int fds[2]; | 106 int fds[2]; |
105 // We use SOCK_SEQPACKET rather than SOCK_DGRAM to prevent the process from | 107 // We use SOCK_SEQPACKET rather than SOCK_DGRAM to prevent the process from |
106 // sending datagrams to other sockets on the system. The sandbox may prevent | 108 // sending datagrams to other sockets on the system. The sandbox may prevent |
107 // the process from calling socket() to create new sockets, but it'll still | 109 // the process from calling socket() to create new sockets, but it'll still |
108 // inherit some sockets. With PF_UNIX+SOCK_DGRAM, it can call sendmsg to send | 110 // inherit some sockets. With PF_UNIX+SOCK_DGRAM, it can call sendmsg to send |
109 // a datagram to any (abstract) socket on the same system. With | 111 // a datagram to any (abstract) socket on the same system. With |
110 // SOCK_SEQPACKET, this is prevented. | 112 // SOCK_SEQPACKET, this is prevented. |
111 CHECK_EQ(0, socketpair(AF_UNIX, SOCK_SEQPACKET, 0, fds)); | 113 CHECK_EQ(0, socketpair(AF_UNIX, SOCK_SEQPACKET, 0, fds)); |
112 static const int on = 1; | 114 static const int on = 1; |
113 | 115 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 base::Passed(&info), | 396 base::Passed(&info), |
395 base::Passed(&crash_context), | 397 base::Passed(&crash_context), |
396 crashing_pid, | 398 crashing_pid, |
397 signal_fd)); | 399 signal_fd)); |
398 } | 400 } |
399 | 401 |
400 void CrashHandlerHostLinux::WriteDumpFile(std::unique_ptr<BreakpadInfo> info, | 402 void CrashHandlerHostLinux::WriteDumpFile(std::unique_ptr<BreakpadInfo> info, |
401 std::unique_ptr<char[]> crash_context, | 403 std::unique_ptr<char[]> crash_context, |
402 pid_t crashing_pid, | 404 pid_t crashing_pid, |
403 int signal_fd) { | 405 int signal_fd) { |
404 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 406 DCHECK(write_dump_file_sequence_checker_.CalledOnValidSequence()); |
405 worker_pool_token_)); | |
406 | 407 |
407 // Set |info->distro| here because base::GetLinuxDistro() needs to run on a | 408 // Set |info->distro| here because base::GetLinuxDistro() needs to run on a |
408 // blocking thread. | 409 // blocking thread. |
409 std::string distro = base::GetLinuxDistro(); | 410 std::string distro = base::GetLinuxDistro(); |
410 info->distro_length = distro.length(); | 411 info->distro_length = distro.length(); |
411 // Freed in CrashDumpTask(). | 412 // Freed in CrashDumpTask(). |
412 char* distro_str = new char[info->distro_length + 1]; | 413 char* distro_str = new char[info->distro_length + 1]; |
413 distro.copy(distro_str, info->distro_length); | 414 distro.copy(distro_str, info->distro_length); |
414 distro_str[info->distro_length] = '\0'; | 415 distro_str[info->distro_length] = '\0'; |
415 info->distro = distro_str; | 416 info->distro = distro_str; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 // no-ops. | 492 // no-ops. |
492 shutting_down_ = true; | 493 shutting_down_ = true; |
493 uploader_thread_->Stop(); | 494 uploader_thread_->Stop(); |
494 } | 495 } |
495 | 496 |
496 bool CrashHandlerHostLinux::IsShuttingDown() const { | 497 bool CrashHandlerHostLinux::IsShuttingDown() const { |
497 return shutting_down_; | 498 return shutting_down_; |
498 } | 499 } |
499 | 500 |
500 } // namespace breakpad | 501 } // namespace breakpad |
OLD | NEW |