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

Side by Side Diff: base/file_descriptor_shuffle.h

Issue 179028: Revert "Fix a ton of compiler warnings." (Closed)
Patch Set: Created 11 years, 3 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
« no previous file with comments | « base/field_trial_unittest.cc ('k') | base/multiprocess_test.h » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 BASE_FILE_DESCRIPTOR_SHUFFLE_H_ 5 #ifndef BASE_FILE_DESCRIPTOR_SHUFFLE_H_
6 #define BASE_FILE_DESCRIPTOR_SHUFFLE_H_ 6 #define BASE_FILE_DESCRIPTOR_SHUFFLE_H_
7 7
8 // This code exists to perform the shuffling of file descriptors which is 8 // This code exists to perform the shuffling of file descriptors which is
9 // commonly needed when forking subprocesses. The naive approve is very simple, 9 // commonly needed when forking subprocesses. The naive approve is very simple,
10 // just call dup2 to setup the desired descriptors, but wrong. It's tough to 10 // just call dup2 to setup the desired descriptors, but wrong. It's tough to
(...skipping 19 matching lines...) Expand all
30 class InjectionDelegate { 30 class InjectionDelegate {
31 public: 31 public:
32 // Duplicate |fd|, an element of the domain, and write a fresh element of the 32 // Duplicate |fd|, an element of the domain, and write a fresh element of the
33 // domain into |result|. Returns true iff successful. 33 // domain into |result|. Returns true iff successful.
34 virtual bool Duplicate(int* result, int fd) = 0; 34 virtual bool Duplicate(int* result, int fd) = 0;
35 // Destructively move |src| to |dest|, overwriting |dest|. Returns true iff 35 // Destructively move |src| to |dest|, overwriting |dest|. Returns true iff
36 // successful. 36 // successful.
37 virtual bool Move(int src, int dest) = 0; 37 virtual bool Move(int src, int dest) = 0;
38 // Delete an element of the domain. 38 // Delete an element of the domain.
39 virtual void Close(int fd) = 0; 39 virtual void Close(int fd) = 0;
40
41 protected:
42 ~InjectionDelegate() {}
43 }; 40 };
44 41
45 // An implementation of the InjectionDelegate interface using the file 42 // An implementation of the InjectionDelegate interface using the file
46 // descriptor table of the current process as the domain. 43 // descriptor table of the current process as the domain.
47 class FileDescriptorTableInjection : public InjectionDelegate { 44 class FileDescriptorTableInjection : public InjectionDelegate {
48 bool Duplicate(int* result, int fd); 45 bool Duplicate(int* result, int fd);
49 bool Move(int src, int dest); 46 bool Move(int src, int dest);
50 void Close(int fd); 47 void Close(int fd);
51 }; 48 };
52 49
(...skipping 17 matching lines...) Expand all
70 InjectionDelegate* delegate); 67 InjectionDelegate* delegate);
71 68
72 static inline bool ShuffleFileDescriptors(const InjectiveMultimap& map) { 69 static inline bool ShuffleFileDescriptors(const InjectiveMultimap& map) {
73 FileDescriptorTableInjection delegate; 70 FileDescriptorTableInjection delegate;
74 return PerformInjectiveMultimap(map, &delegate); 71 return PerformInjectiveMultimap(map, &delegate);
75 } 72 }
76 73
77 } // namespace base 74 } // namespace base
78 75
79 #endif // !BASE_FILE_DESCRIPTOR_SHUFFLE_H_ 76 #endif // !BASE_FILE_DESCRIPTOR_SHUFFLE_H_
OLDNEW
« no previous file with comments | « base/field_trial_unittest.cc ('k') | base/multiprocess_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698