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 #include "content/zygote/zygote_main.h" | 5 #include "content/zygote/zygote_main.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <pthread.h> | 9 #include <pthread.h> |
10 #include <signal.h> | 10 #include <signal.h> |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 second->Run(); | 86 second->Run(); |
87 } | 87 } |
88 | 88 |
89 } // namespace | 89 } // namespace |
90 | 90 |
91 // See http://code.google.com/p/chromium/wiki/LinuxZygote | 91 // See http://code.google.com/p/chromium/wiki/LinuxZygote |
92 | 92 |
93 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, | 93 static void ProxyLocaltimeCallToBrowser(time_t input, struct tm* output, |
94 char* timezone_out, | 94 char* timezone_out, |
95 size_t timezone_out_len) { | 95 size_t timezone_out_len) { |
96 Pickle request; | 96 base::Pickle request; |
97 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); | 97 request.WriteInt(LinuxSandbox::METHOD_LOCALTIME); |
98 request.WriteString( | 98 request.WriteString( |
99 std::string(reinterpret_cast<char*>(&input), sizeof(input))); | 99 std::string(reinterpret_cast<char*>(&input), sizeof(input))); |
100 | 100 |
101 uint8_t reply_buf[512]; | 101 uint8_t reply_buf[512]; |
102 const ssize_t r = UnixDomainSocket::SendRecvMsg( | 102 const ssize_t r = UnixDomainSocket::SendRecvMsg( |
103 GetSandboxFD(), reply_buf, sizeof(reply_buf), NULL, | 103 GetSandboxFD(), reply_buf, sizeof(reply_buf), NULL, |
104 request); | 104 request); |
105 if (r == -1) { | 105 if (r == -1) { |
106 memset(output, 0, sizeof(struct tm)); | 106 memset(output, 0, sizeof(struct tm)); |
107 return; | 107 return; |
108 } | 108 } |
109 | 109 |
110 Pickle reply(reinterpret_cast<char*>(reply_buf), r); | 110 base::Pickle reply(reinterpret_cast<char*>(reply_buf), r); |
111 PickleIterator iter(reply); | 111 base::PickleIterator iter(reply); |
112 std::string result, timezone; | 112 std::string result, timezone; |
113 if (!iter.ReadString(&result) || | 113 if (!iter.ReadString(&result) || |
114 !iter.ReadString(&timezone) || | 114 !iter.ReadString(&timezone) || |
115 result.size() != sizeof(struct tm)) { | 115 result.size() != sizeof(struct tm)) { |
116 memset(output, 0, sizeof(struct tm)); | 116 memset(output, 0, sizeof(struct tm)); |
117 return; | 117 return; |
118 } | 118 } |
119 | 119 |
120 memcpy(output, result.data(), sizeof(struct tm)); | 120 memcpy(output, result.data(), sizeof(struct tm)); |
121 if (timezone_out_len) { | 121 if (timezone_out_len) { |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; | 610 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; |
611 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); | 611 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); |
612 | 612 |
613 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, | 613 Zygote zygote(sandbox_flags, fork_delegates.Pass(), extra_children, |
614 extra_fds); | 614 extra_fds); |
615 // This function call can return multiple times, once per fork(). | 615 // This function call can return multiple times, once per fork(). |
616 return zygote.ProcessRequests(); | 616 return zygote.ProcessRequests(); |
617 } | 617 } |
618 | 618 |
619 } // namespace content | 619 } // namespace content |
OLD | NEW |