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

Side by Side Diff: content/browser/zygote_host_impl_linux.h

Issue 10388013: Move the Linux zygote stuff into its own per-process directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
« no previous file with comments | « content/app/content_main_runner.cc ('k') | content/browser/zygote_host_impl_linux.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 (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_BROWSER_ZYGOTE_HOST_IMPL_LINUX_H_ 5 #ifndef CONTENT_BROWSER_ZYGOTE_HOST_IMPL_LINUX_H_
6 #define CONTENT_BROWSER_ZYGOTE_HOST_IMPL_LINUX_H_ 6 #define CONTENT_BROWSER_ZYGOTE_HOST_IMPL_LINUX_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/global_descriptors_posix.h" 12 #include "base/global_descriptors_posix.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "content/public/browser/zygote_host_linux.h" 15 #include "content/public/browser/zygote_host_linux.h"
16 16
17 template<typename Type> 17 template<typename Type>
18 struct DefaultSingletonTraits; 18 struct DefaultSingletonTraits;
19 19
20 static const char kZygoteMagic[] = "ZYGOTE_OK";
21
22 class CONTENT_EXPORT ZygoteHostImpl : public content::ZygoteHost { 20 class CONTENT_EXPORT ZygoteHostImpl : public content::ZygoteHost {
23 public: 21 public:
24 // Returns the singleton instance. 22 // Returns the singleton instance.
25 static ZygoteHostImpl* GetInstance(); 23 static ZygoteHostImpl* GetInstance();
26 24
27 void Init(const std::string& sandbox_cmd); 25 void Init(const std::string& sandbox_cmd);
28 26
29 // Tries to start a process of type indicated by process_type. 27 // Tries to start a process of type indicated by process_type.
30 // Returns its pid on success, otherwise 28 // Returns its pid on success, otherwise
31 // base::kNullProcessHandle; 29 // base::kNullProcessHandle;
32 pid_t ForkRequest(const std::vector<std::string>& command_line, 30 pid_t ForkRequest(const std::vector<std::string>& command_line,
33 const base::GlobalDescriptors::Mapping& mapping, 31 const base::GlobalDescriptors::Mapping& mapping,
34 const std::string& process_type); 32 const std::string& process_type);
35 void EnsureProcessTerminated(pid_t process); 33 void EnsureProcessTerminated(pid_t process);
36 34
37 // Get the termination status (and, optionally, the exit code) of 35 // Get the termination status (and, optionally, the exit code) of
38 // the process. |exit_code| is set to the exit code of the child 36 // the process. |exit_code| is set to the exit code of the child
39 // process. (|exit_code| may be NULL.) 37 // process. (|exit_code| may be NULL.)
40 base::TerminationStatus GetTerminationStatus(base::ProcessHandle handle, 38 base::TerminationStatus GetTerminationStatus(base::ProcessHandle handle,
41 int* exit_code); 39 int* exit_code);
42 40
43 // These are the command codes used on the wire between the browser and the
44 // zygote.
45 enum {
46 kCmdFork = 0, // Fork off a new renderer.
47 kCmdReap = 1, // Reap a renderer child.
48 kCmdGetTerminationStatus = 2, // Check what happend to a child process.
49 kCmdGetSandboxStatus = 3, // Read a bitmask of kSandbox*
50 };
51
52 // ZygoteHost implementation: 41 // ZygoteHost implementation:
53 virtual pid_t GetPid() const OVERRIDE; 42 virtual pid_t GetPid() const OVERRIDE;
54 virtual pid_t GetSandboxHelperPid() const OVERRIDE; 43 virtual pid_t GetSandboxHelperPid() const OVERRIDE;
55 virtual int GetSandboxStatus() const OVERRIDE; 44 virtual int GetSandboxStatus() const OVERRIDE;
56 virtual void AdjustRendererOOMScore(base::ProcessHandle process_handle, 45 virtual void AdjustRendererOOMScore(base::ProcessHandle process_handle,
57 int score) OVERRIDE; 46 int score) OVERRIDE;
58 virtual void AdjustLowMemoryMargin(int64 margin_mb) OVERRIDE; 47 virtual void AdjustLowMemoryMargin(int64 margin_mb) OVERRIDE;
59 48
60 private: 49 private:
61 friend struct DefaultSingletonTraits<ZygoteHostImpl>; 50 friend struct DefaultSingletonTraits<ZygoteHostImpl>;
62 ZygoteHostImpl(); 51 ZygoteHostImpl();
63 virtual ~ZygoteHostImpl(); 52 virtual ~ZygoteHostImpl();
64 53
65 ssize_t ReadReply(void* buf, size_t buflen); 54 ssize_t ReadReply(void* buf, size_t buflen);
66 55
67 int control_fd_; // the socket to the zygote 56 int control_fd_; // the socket to the zygote
68 // A lock protecting all communication with the zygote. This lock must be 57 // A lock protecting all communication with the zygote. This lock must be
69 // acquired before sending a command and released after the result has been 58 // acquired before sending a command and released after the result has been
70 // received. 59 // received.
71 base::Lock control_lock_; 60 base::Lock control_lock_;
72 pid_t pid_; 61 pid_t pid_;
73 bool init_; 62 bool init_;
74 bool using_suid_sandbox_; 63 bool using_suid_sandbox_;
75 std::string sandbox_binary_; 64 std::string sandbox_binary_;
76 bool have_read_sandbox_status_word_; 65 bool have_read_sandbox_status_word_;
77 int sandbox_status_; 66 int sandbox_status_;
78 }; 67 };
79 68
80 #endif // CONTENT_BROWSER_ZYGOTE_HOST_IMPL_LINUX_H_ 69 #endif // CONTENT_BROWSER_ZYGOTE_HOST_IMPL_LINUX_H_
OLDNEW
« no previous file with comments | « content/app/content_main_runner.cc ('k') | content/browser/zygote_host_impl_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698