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

Side by Side Diff: sandbox/linux/services/thread_helpers.h

Issue 938223004: Linux sandbox: better APIs with /proc/ arguments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix invalid proc_fd_ usage. Created 5 years, 10 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
« no previous file with comments | « sandbox/linux/services/proc_util_unittest.cc ('k') | sandbox/linux/services/thread_helpers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "sandbox/sandbox_export.h" 9 #include "sandbox/sandbox_export.h"
10 10
11 namespace base { class Thread; } 11 namespace base { class Thread; }
12 12
13 namespace sandbox { 13 namespace sandbox {
14 14
15 class SANDBOX_EXPORT ThreadHelpers { 15 class SANDBOX_EXPORT ThreadHelpers {
16 public: 16 public:
17 // Check whether the current process is single threaded. |proc_self_tasks| 17 // Check whether the current process is single threaded. |proc_fd|
18 // must be a file descriptor to /proc/self/task/ and remains owned by the 18 // must be a file descriptor to /proc/ and remains owned by the
19 // caller. 19 // caller.
20 static bool IsSingleThreaded(int proc_self_task); 20 static bool IsSingleThreaded(int proc_fd);
21 static bool IsSingleThreaded(); 21 static bool IsSingleThreaded();
22 22
23 // Crash if the current process is not single threaded. This will wait 23 // Crash if the current process is not single threaded. This will wait
24 // on /proc to be updated. In the case where this doesn't crash, this will 24 // on /proc to be updated. In the case where this doesn't crash, this will
25 // return promptly. In the case where this does crash, this will first wait 25 // return promptly. In the case where this does crash, this will first wait
26 // for a few ms in Debug mode, a few seconds in Release mode. 26 // for a few ms in Debug mode, a few seconds in Release mode.
27 static void AssertSingleThreaded(int proc_self_task); 27 static void AssertSingleThreaded(int proc_fd);
28 static void AssertSingleThreaded(); 28 static void AssertSingleThreaded();
29 29
30 // Stop |thread| and ensure that it does not have an entry in 30 // Stop |thread| and ensure that it does not have an entry in
31 // /proc/self/task/ from the point of view of the current thread. This is 31 // /proc/self/task/ from the point of view of the current thread. This is
32 // the way to stop threads before calling IsSingleThreaded(). 32 // the way to stop threads before calling IsSingleThreaded().
33 static bool StopThreadAndWatchProcFS(int proc_self_task, 33 static bool StopThreadAndWatchProcFS(int proc_fd, base::Thread* thread);
34 base::Thread* thread);
35 34
36 static const char* GetAssertSingleThreadedErrorMessageForTests(); 35 static const char* GetAssertSingleThreadedErrorMessageForTests();
37 36
38 private: 37 private:
39 DISALLOW_IMPLICIT_CONSTRUCTORS(ThreadHelpers); 38 DISALLOW_IMPLICIT_CONSTRUCTORS(ThreadHelpers);
40 }; 39 };
41 40
42 } // namespace sandbox 41 } // namespace sandbox
43 42
44 #endif // SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_ 43 #endif // SANDBOX_LINUX_SERVICES_THREAD_HELPERS_H_
OLDNEW
« no previous file with comments | « sandbox/linux/services/proc_util_unittest.cc ('k') | sandbox/linux/services/thread_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698