Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / sandbox / linux / services / thread_helpers.h
blob377742a539acd4abb169ca400c0dcfabc3a74c37
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
3 // found in the LICENSE file.
5 #ifndef SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_
6 #define SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_
8 #include "base/basictypes.h"
9 #include "sandbox/sandbox_export.h"
11 namespace base { class Thread; }
13 namespace sandbox {
15 class SANDBOX_EXPORT ThreadHelpers {
16 public:
17 // Check whether the current process is single threaded. |proc_self_tasks|
18 // can be a file descriptor to /proc/self/task/ and remains owned by the
19 // caller or -1.
20 // If |proc_self_tasks| is -1, this method will open /proc/self/task/ and
21 // crash if it cannot.
22 static bool IsSingleThreaded(int proc_self_task);
24 // Stop |thread| and ensure that it does not have an entry in
25 // /proc/self/task/ from the point of view of the current thread. This is
26 // the way to stop threads before calling IsSingleThreaded().
27 static bool StopThreadAndWatchProcFS(int proc_self_tasks,
28 base::Thread* thread);
30 private:
31 DISALLOW_IMPLICIT_CONSTRUCTORS(ThreadHelpers);
34 } // namespace sandbox
36 #endif // SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_