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

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

Issue 2022983003: Roll base to 5e00da80f6adb7082d1c0e88d3274cf87cc43bc5 and tonic to f7acabb8fa6c91124486a41194eac3cd… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 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
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 #include "sandbox/linux/services/thread_helpers.h" 5 #include "sandbox/linux/services/thread_helpers.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 bool ChangeThreadStateAndWatchProcFS( 114 bool ChangeThreadStateAndWatchProcFS(
115 int proc_fd, base::Thread* thread, ThreadAction action) { 115 int proc_fd, base::Thread* thread, ThreadAction action) {
116 DCHECK_LE(0, proc_fd); 116 DCHECK_LE(0, proc_fd);
117 DCHECK(thread); 117 DCHECK(thread);
118 DCHECK(action == ThreadAction::Start || action == ThreadAction::Stop); 118 DCHECK(action == ThreadAction::Start || action == ThreadAction::Stop);
119 119
120 base::Callback<bool(void)> cb; 120 base::Callback<bool(void)> cb;
121 const char* message; 121 const char* message;
122 122
123 if (action == ThreadAction::Start) { 123 if (action == ThreadAction::Start) {
124 // Should start the thread before calling thread_id(). 124 // Should start the thread before calling GetThreadId().
125 if (!thread->Start()) 125 if (!thread->Start())
126 return false; 126 return false;
127 } 127 }
128 128
129 const base::PlatformThreadId thread_id = thread->thread_id(); 129 const base::PlatformThreadId thread_id = thread->GetThreadId();
130 const std::string thread_id_dir_str = 130 const std::string thread_id_dir_str =
131 "self/task/" + base::IntToString(thread_id) + "/"; 131 "self/task/" + base::IntToString(thread_id) + "/";
132 132
133 if (action == ThreadAction::Stop) { 133 if (action == ThreadAction::Stop) {
134 // The target thread should exist in /proc. 134 // The target thread should exist in /proc.
135 DCHECK(IsThreadPresentInProcFS(proc_fd, thread_id_dir_str)); 135 DCHECK(IsThreadPresentInProcFS(proc_fd, thread_id_dir_str));
136 thread->Stop(); 136 thread->Stop();
137 } 137 }
138 138
139 // The kernel is at liberty to wake the thread id futex before updating 139 // The kernel is at liberty to wake the thread id futex before updating
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 base::Thread* thread) { 191 base::Thread* thread) {
192 return ChangeThreadStateAndWatchProcFS(proc_fd, thread, ThreadAction::Stop); 192 return ChangeThreadStateAndWatchProcFS(proc_fd, thread, ThreadAction::Stop);
193 } 193 }
194 194
195 // static 195 // static
196 const char* ThreadHelpers::GetAssertSingleThreadedErrorMessageForTests() { 196 const char* ThreadHelpers::GetAssertSingleThreadedErrorMessageForTests() {
197 return kAssertSingleThreadedError; 197 return kAssertSingleThreadedError;
198 } 198 }
199 199
200 } // namespace sandbox 200 } // namespace sandbox
OLDNEW
« no previous file with comments | « mojo/android/system/src/org/chromium/mojo/system/impl/CoreImpl.java ('k') | services/http_server/http_request_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698