| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_ | 5 #ifndef SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_ |
| 6 #define SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_ | 6 #define SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 | 9 |
| 10 namespace base { class Thread; } | 10 namespace base { class Thread; } |
| 11 | 11 |
| 12 namespace sandbox { | 12 namespace sandbox { |
| 13 | 13 |
| 14 class ThreadHelpers { | 14 class ThreadHelpers { |
| 15 public: | 15 public: |
| 16 // Check whether the current process is single threaded. |proc_self_tasks| | 16 // Check whether the current process is single threaded. |proc_self_tasks| |
| 17 // should be a file descriptor to /proc/self/task/ and remains owned by the | 17 // can be a file descriptor to /proc/self/task/ and remains owned by the |
| 18 // caller. | 18 // caller or -1. |
| 19 // If |proc_self_tasks| is -1, this method will open /proc/self/task/ and |
| 20 // crash if it cannot. |
| 19 static bool IsSingleThreaded(int proc_self_task); | 21 static bool IsSingleThreaded(int proc_self_task); |
| 20 | 22 |
| 21 // Stop |thread| and ensure that it does not have an entry in | 23 // Stop |thread| and ensure that it does not have an entry in |
| 22 // /proc/self/task/ from the point of view of the current thread. This is | 24 // /proc/self/task/ from the point of view of the current thread. This is |
| 23 // the way to stop threads before calling IsSingleThreaded(). | 25 // the way to stop threads before calling IsSingleThreaded(). |
| 24 static bool StopThreadAndWatchProcFS(int proc_self_tasks, | 26 static bool StopThreadAndWatchProcFS(int proc_self_tasks, |
| 25 base::Thread* thread); | 27 base::Thread* thread); |
| 26 | 28 |
| 27 private: | 29 private: |
| 28 DISALLOW_IMPLICIT_CONSTRUCTORS(ThreadHelpers); | 30 DISALLOW_IMPLICIT_CONSTRUCTORS(ThreadHelpers); |
| 29 }; | 31 }; |
| 30 | 32 |
| 31 } // namespace content | 33 } // namespace content |
| 32 | 34 |
| 33 #endif // SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_ | 35 #endif // SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_ |
| OLD | NEW |