OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2017 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 #include "util/thread/thread.h" | 15 #include "util/misc/zlib.h" |
16 | 16 |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/strings/stringprintf.h" |
| 19 #include "third_party/zlib/zlib_crashpad.h" |
18 | 20 |
19 namespace crashpad { | 21 namespace crashpad { |
20 | 22 |
21 void Thread::Start() { | 23 int ZlibWindowBitsWithGzipWrapper(int window_bits) { |
22 DCHECK(!platform_thread_); | 24 // See the documentation for deflateInit2() and inflateInit2() in <zlib.h>. 0 |
23 int rv = pthread_create(&platform_thread_, nullptr, ThreadEntryThunk, this); | 25 // is only valid during decompression. |
24 PCHECK(0 == rv); | 26 |
| 27 DCHECK(window_bits == 0 || (window_bits >= 8 && window_bits <= 15)) |
| 28 << window_bits; |
| 29 |
| 30 return 16 + window_bits; |
25 } | 31 } |
26 | 32 |
27 void Thread::Join() { | 33 std::string ZlibErrorString(int zr) { |
28 DCHECK(platform_thread_); | 34 return base::StringPrintf("%s (%d)", zError(zr), zr); |
29 int rv = pthread_join(platform_thread_, nullptr); | |
30 PCHECK(0 == rv); | |
31 platform_thread_ = 0; | |
32 } | |
33 | |
34 // static | |
35 void* Thread::ThreadEntryThunk(void* argument) { | |
36 Thread* self = reinterpret_cast<Thread*>(argument); | |
37 self->ThreadMain(); | |
38 return nullptr; | |
39 } | 35 } |
40 | 36 |
41 } // namespace crashpad | 37 } // namespace crashpad |
OLD | NEW |