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

Side by Side Diff: content/public/common/zygote_fork_delegate_linux.h

Issue 24449002: NaCl: Clean up how FDs are passed to nacl_helper instances on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup: move constants Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ 5 #ifndef CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_
6 #define CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ 6 #define CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_
7 7
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 25 matching lines...) Expand all
36 virtual void InitialUMA(std::string* uma_name, 36 virtual void InitialUMA(std::string* uma_name,
37 int* uma_sample, 37 int* uma_sample,
38 int* uma_boundary_value) = 0; 38 int* uma_boundary_value) = 0;
39 39
40 // Returns 'true' if the delegate would like to handle a given fork 40 // Returns 'true' if the delegate would like to handle a given fork
41 // request. Otherwise returns false. Optionally, fills in uma_name et al 41 // request. Otherwise returns false. Optionally, fills in uma_name et al
42 // with a report the helper wants to make via UMA_HISTOGRAM_ENUMERATION. 42 // with a report the helper wants to make via UMA_HISTOGRAM_ENUMERATION.
43 virtual bool CanHelp(const std::string& process_type, std::string* uma_name, 43 virtual bool CanHelp(const std::string& process_type, std::string* uma_name,
44 int* uma_sample, int* uma_boundary_value) = 0; 44 int* uma_sample, int* uma_boundary_value) = 0;
45 45
46 // Indexes of FDs in the vector passed to Fork().
47 enum {
48 // Used to pass in the descriptor for talking to the Browser
49 kBrowserFDIndex = 0,
50 // The next two are used in the protocol for discovering the
51 // child processes real PID from within the SUID sandbox. See
52 // http://code.google.com/p/chromium/wiki/LinuxZygote
53 kDummyFDIndex = 1,
54 kParentFDIndex = 2
jln (very slow on Chromium) 2013/10/07 18:12:06 With MACRO_STYLE, in Chromium, it's typical to hav
Mark Seaborn 2013/10/08 18:31:06 Added kNumPassedFds.
55 };
56
46 // Delegate forks, returning a -1 on failure. Outside the 57 // Delegate forks, returning a -1 on failure. Outside the
47 // suid sandbox, Fork() returns the Linux process ID. 58 // suid sandbox, Fork() returns the Linux process ID.
48 // This method is not aware of any potential pid namespaces, so it'll 59 // This method is not aware of any potential pid namespaces, so it'll
49 // return a raw pid just like fork() would. 60 // return a raw pid just like fork() would.
50 virtual pid_t Fork(const std::vector<int>& fds) = 0; 61 virtual pid_t Fork(const std::vector<int>& fds) = 0;
51 62
52 // After a successful fork, signal the child to indicate that 63 // After a successful fork, signal the child to indicate that
53 // the child's PID has been received. Also communicate the 64 // the child's PID has been received. Also communicate the
54 // channel switch as a part of acknowledgement message. 65 // channel switch as a part of acknowledgement message.
55 virtual bool AckChild(int fd, const std::string& channel_switch) = 0; 66 virtual bool AckChild(int fd, const std::string& channel_switch) = 0;
56 67
57 // The fork delegate must also assume the role of waiting for its children 68 // The fork delegate must also assume the role of waiting for its children
58 // since the caller will not be their parents and cannot do it. |pid| here 69 // since the caller will not be their parents and cannot do it. |pid| here
59 // should be a pid that has been returned by the Fork() method. i.e. This 70 // should be a pid that has been returned by the Fork() method. i.e. This
60 // method is completely unaware of eventual PID namespaces due to sandboxing. 71 // method is completely unaware of eventual PID namespaces due to sandboxing.
61 // |known_dead| indicates that the process is already dead and that a 72 // |known_dead| indicates that the process is already dead and that a
62 // blocking wait() should be performed. In this case, GetTerminationStatus() 73 // blocking wait() should be performed. In this case, GetTerminationStatus()
63 // will send a SIGKILL to the target process first. 74 // will send a SIGKILL to the target process first.
64 virtual bool GetTerminationStatus(pid_t pid, bool known_dead, 75 virtual bool GetTerminationStatus(pid_t pid, bool known_dead,
65 base::TerminationStatus* status, 76 base::TerminationStatus* status,
66 int* exit_code) = 0; 77 int* exit_code) = 0;
67 }; 78 };
68 79
69 } // namespace content 80 } // namespace content
70 81
71 #endif // CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_ 82 #endif // CONTENT_PUBLIC_COMMON_ZYGOTE_FORK_DELEGATE_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698