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

Side by Side Diff: content/browser/zygote_host/zygote_host_impl_linux.cc

Issue 191673003: Implement ScopedFD in terms of ScopedGeneric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 #include "content/browser/zygote_host/zygote_host_impl_linux.h" 5 #include "content/browser/zygote_host/zygote_host_impl_linux.h"
6 6
7 #include <sys/socket.h> 7 #include <sys/socket.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #include "base/base_switches.h" 12 #include "base/base_switches.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/environment.h" 14 #include "base/environment.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/files/file_enumerator.h" 16 #include "base/files/file_enumerator.h"
17 #include "base/files/scoped_file.h"
17 #include "base/linux_util.h" 18 #include "base/linux_util.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/memory/linked_ptr.h" 20 #include "base/memory/linked_ptr.h"
20 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
21 #include "base/metrics/histogram.h" 22 #include "base/metrics/histogram.h"
22 #include "base/path_service.h" 23 #include "base/path_service.h"
23 #include "base/posix/eintr_wrapper.h" 24 #include "base/posix/eintr_wrapper.h"
24 #include "base/posix/unix_domain_socket_linux.h" 25 #include "base/posix/unix_domain_socket_linux.h"
25 #include "base/process/launch.h" 26 #include "base/process/launch.h"
26 #include "base/process/memory.h" 27 #include "base/process/memory.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 pickle.WriteInt(argv.size()); 312 pickle.WriteInt(argv.size());
312 for (std::vector<std::string>::const_iterator 313 for (std::vector<std::string>::const_iterator
313 i = argv.begin(); i != argv.end(); ++i) 314 i = argv.begin(); i != argv.end(); ++i)
314 pickle.WriteString(*i); 315 pickle.WriteString(*i);
315 316
316 pickle.WriteInt(mapping.size()); 317 pickle.WriteInt(mapping.size());
317 318
318 std::vector<int> fds; 319 std::vector<int> fds;
319 // Scoped pointers cannot be stored in containers, so we have to use a 320 // Scoped pointers cannot be stored in containers, so we have to use a
320 // linked_ptr. 321 // linked_ptr.
321 std::vector<linked_ptr<file_util::ScopedFD> > autodelete_fds; 322 std::vector<linked_ptr<base::ScopedFD> > autodelete_fds;
322 for (std::vector<FileDescriptorInfo>::const_iterator 323 for (std::vector<FileDescriptorInfo>::const_iterator
323 i = mapping.begin(); i != mapping.end(); ++i) { 324 i = mapping.begin(); i != mapping.end(); ++i) {
324 pickle.WriteUInt32(i->id); 325 pickle.WriteUInt32(i->id);
325 fds.push_back(i->fd.fd); 326 fds.push_back(i->fd.fd);
326 if (i->fd.auto_close) { 327 if (i->fd.auto_close) {
327 // Auto-close means we need to close the FDs after they have been passed 328 // Auto-close means we need to close the FDs after they have been passed
328 // to the other process. 329 // to the other process.
329 linked_ptr<file_util::ScopedFD> ptr( 330 linked_ptr<base::ScopedFD> ptr(new base::ScopedFD(fds.back()));
330 new file_util::ScopedFD(&(fds.back())));
331 autodelete_fds.push_back(ptr); 331 autodelete_fds.push_back(ptr);
332 } 332 }
333 } 333 }
334 334
335 pid_t pid; 335 pid_t pid;
336 { 336 {
337 base::AutoLock lock(control_lock_); 337 base::AutoLock lock(control_lock_);
338 if (!SendMessage(pickle, &fds)) 338 if (!SendMessage(pickle, &fds))
339 return base::kNullProcessHandle; 339 return base::kNullProcessHandle;
340 340
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 return RenderSandboxHostLinux::GetInstance()->pid(); 528 return RenderSandboxHostLinux::GetInstance()->pid();
529 } 529 }
530 530
531 int ZygoteHostImpl::GetSandboxStatus() const { 531 int ZygoteHostImpl::GetSandboxStatus() const {
532 if (have_read_sandbox_status_word_) 532 if (have_read_sandbox_status_word_)
533 return sandbox_status_; 533 return sandbox_status_;
534 return 0; 534 return 0;
535 } 535 }
536 536
537 } // namespace content 537 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698