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

Side by Side Diff: ipc/ipc_platform_file.cc

Issue 7044095: Hooking MHTML generation to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved the GetFileForProcess to IPC::PlatformFile Created 9 years, 6 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ipc/ipc_platform_file.h"
6
7 namespace IPC {
8
9 PlatformFileForTransit GetFileHandleForProcess(base::PlatformFile handle,
10 base::ProcessHandle process,
11 bool close_source_handle) {
12 IPC::PlatformFileForTransit out_handle;
13 #if defined(OS_WIN)
14 DWORD options = DUPLICATE_SAME_ACCESS;
15 if (close_source_handle)
16 options |= DUPLICATE_CLOSE_SOURCE;
17 if (!::DuplicateHandle(::GetCurrentProcess(),
18 handle,
19 process,
20 &out_handle,
21 0,
22 FALSE,
23 options)) {
24 out_handle = IPC::InvalidPlatformFileForTransit();
25 }
26 #elif defined(OS_POSIX)
27 // If asked to close the source, we can simply re-use the source fd instead of
28 // dup()ing and close()ing.
brettw 2011/06/14 15:17:24 Can you add to this comment, I had to ask Antoine
29 int fd = close_source_handle ? handle : ::dup(handle);
30 out_handle = base::FileDescriptor(fd, true);
31 #else
32 #error Not implemented.
33 #endif
34 return out_handle;
35 }
36
37 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698