OLD | NEW |
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_ZYGOTE_HOST_IMPL_LINUX_H_ | 5 #ifndef CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ |
6 #define CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ | 6 #define CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/pickle.h" |
11 #include "base/process_util.h" | 12 #include "base/process_util.h" |
12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
13 #include "content/public/browser/file_descriptor_info.h" | 14 #include "content/public/browser/file_descriptor_info.h" |
14 #include "content/public/browser/zygote_host_linux.h" | 15 #include "content/public/browser/zygote_host_linux.h" |
15 | 16 |
16 template<typename Type> | 17 template<typename Type> |
17 struct DefaultSingletonTraits; | 18 struct DefaultSingletonTraits; |
18 | 19 |
19 class CONTENT_EXPORT ZygoteHostImpl : public content::ZygoteHost { | 20 class CONTENT_EXPORT ZygoteHostImpl : public content::ZygoteHost { |
20 public: | 21 public: |
(...skipping 19 matching lines...) Expand all Loading... |
40 // ZygoteHost implementation: | 41 // ZygoteHost implementation: |
41 virtual pid_t GetPid() const OVERRIDE; | 42 virtual pid_t GetPid() const OVERRIDE; |
42 virtual pid_t GetSandboxHelperPid() const OVERRIDE; | 43 virtual pid_t GetSandboxHelperPid() const OVERRIDE; |
43 virtual int GetSandboxStatus() const OVERRIDE; | 44 virtual int GetSandboxStatus() const OVERRIDE; |
44 virtual void AdjustRendererOOMScore(base::ProcessHandle process_handle, | 45 virtual void AdjustRendererOOMScore(base::ProcessHandle process_handle, |
45 int score) OVERRIDE; | 46 int score) OVERRIDE; |
46 virtual void AdjustLowMemoryMargin(int64 margin_mb) OVERRIDE; | 47 virtual void AdjustLowMemoryMargin(int64 margin_mb) OVERRIDE; |
47 | 48 |
48 private: | 49 private: |
49 friend struct DefaultSingletonTraits<ZygoteHostImpl>; | 50 friend struct DefaultSingletonTraits<ZygoteHostImpl>; |
| 51 |
50 ZygoteHostImpl(); | 52 ZygoteHostImpl(); |
51 virtual ~ZygoteHostImpl(); | 53 virtual ~ZygoteHostImpl(); |
52 | 54 |
| 55 // Sends |data| to the zygote via |control_fd_|. If |fds| is non-NULL, the |
| 56 // included file descriptors will also be passed. The caller is responsible |
| 57 // for acquiring |control_lock_|. |
| 58 bool SendMessage(const Pickle& data, const std::vector<int>* fds); |
| 59 |
53 ssize_t ReadReply(void* buf, size_t buflen); | 60 ssize_t ReadReply(void* buf, size_t buflen); |
54 | 61 |
55 int control_fd_; // the socket to the zygote | 62 int control_fd_; // the socket to the zygote |
56 // A lock protecting all communication with the zygote. This lock must be | 63 // A lock protecting all communication with the zygote. This lock must be |
57 // acquired before sending a command and released after the result has been | 64 // acquired before sending a command and released after the result has been |
58 // received. | 65 // received. |
59 base::Lock control_lock_; | 66 base::Lock control_lock_; |
60 pid_t pid_; | 67 pid_t pid_; |
61 bool init_; | 68 bool init_; |
62 bool using_suid_sandbox_; | 69 bool using_suid_sandbox_; |
63 std::string sandbox_binary_; | 70 std::string sandbox_binary_; |
64 bool have_read_sandbox_status_word_; | 71 bool have_read_sandbox_status_word_; |
65 int sandbox_status_; | 72 int sandbox_status_; |
66 }; | 73 }; |
67 | 74 |
68 #endif // CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ | 75 #endif // CONTENT_BROWSER_ZYGOTE_HOST_ZYGOTE_HOST_IMPL_LINUX_H_ |
OLD | NEW |