ipc: Rename TakeFileHandleForProcess->TakePlatformFileForTransit.

This CL has no intended behavior change. This CL also removes the now
unnecessary parameter |process|.

BUG=493414

Review URL: https://codereview.chromium.org/1862333002

Cr-Commit-Position: refs/heads/master@{#385781}
diff --git a/chrome/browser/media_galleries/fileapi/safe_audio_video_checker.cc b/chrome/browser/media_galleries/fileapi/safe_audio_video_checker.cc
index abcfde2..a27e6cf 100644
--- a/chrome/browser/media_galleries/fileapi/safe_audio_video_checker.cc
+++ b/chrome/browser/media_galleries/fileapi/safe_audio_video_checker.cc
@@ -58,10 +58,8 @@
     return;
   state_ = STARTED_STATE;
 
-  if (utility_process_host_->GetData().handle == base::kNullProcessHandle)
-    DLOG(ERROR) << "Child process handle is null";
-  IPC::PlatformFileForTransit file_for_transit = IPC::TakeFileHandleForProcess(
-      std::move(file_), utility_process_host_->GetData().handle);
+  IPC::PlatformFileForTransit file_for_transit =
+      IPC::TakePlatformFileForTransit(std::move(file_));
   if (file_for_transit == IPC::InvalidPlatformFileForTransit()) {
     OnCheckingFinished(false /* valid? */);
     return;
diff --git a/chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.cc b/chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.cc
index 53e5bd04..abedc36 100644
--- a/chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.cc
+++ b/chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.cc
@@ -84,9 +84,7 @@
 
   if (!itunes_callback_.is_null()) {
     utility_process_host_->Send(new ChromeUtilityMsg_ParseITunesLibraryXmlFile(
-        IPC::TakeFileHandleForProcess(
-            std::move(library_file_),
-            utility_process_host_->GetData().handle)));
+        IPC::TakePlatformFileForTransit(std::move(library_file_))));
   }
 
   parser_state_ = STARTED_PARSING_STATE;
diff --git a/chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader.cc b/chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader.cc
index ee68dae..f45d5aa9 100644
--- a/chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader.cc
+++ b/chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader.cc
@@ -86,27 +86,20 @@
     DLOG(ERROR) << "Child process handle is null";
   }
   AlbumTableFilesForTransit files_for_transit;
-  files_for_transit.indicator_file = IPC::TakeFileHandleForProcess(
-      std::move(album_table_files_.indicator_file),
-      utility_process_host_->GetData().handle);
-  files_for_transit.category_file =
-      IPC::TakeFileHandleForProcess(std::move(album_table_files_.category_file),
-                                    utility_process_host_->GetData().handle);
+  files_for_transit.indicator_file = IPC::TakePlatformFileForTransit(
+      std::move(album_table_files_.indicator_file));
+  files_for_transit.category_file = IPC::TakePlatformFileForTransit(
+      std::move(album_table_files_.category_file));
   files_for_transit.date_file =
-      IPC::TakeFileHandleForProcess(std::move(album_table_files_.date_file),
-                                    utility_process_host_->GetData().handle);
-  files_for_transit.filename_file =
-      IPC::TakeFileHandleForProcess(std::move(album_table_files_.filename_file),
-                                    utility_process_host_->GetData().handle);
+      IPC::TakePlatformFileForTransit(std::move(album_table_files_.date_file));
+  files_for_transit.filename_file = IPC::TakePlatformFileForTransit(
+      std::move(album_table_files_.filename_file));
   files_for_transit.name_file =
-      IPC::TakeFileHandleForProcess(std::move(album_table_files_.name_file),
-                                    utility_process_host_->GetData().handle);
+      IPC::TakePlatformFileForTransit(std::move(album_table_files_.name_file));
   files_for_transit.token_file =
-      IPC::TakeFileHandleForProcess(std::move(album_table_files_.token_file),
-                                    utility_process_host_->GetData().handle);
+      IPC::TakePlatformFileForTransit(std::move(album_table_files_.token_file));
   files_for_transit.uid_file =
-      IPC::TakeFileHandleForProcess(std::move(album_table_files_.uid_file),
-                                    utility_process_host_->GetData().handle);
+      IPC::TakePlatformFileForTransit(std::move(album_table_files_.uid_file));
   utility_process_host_->Send(new ChromeUtilityMsg_ParsePicasaPMPDatabase(
       files_for_transit));
   parser_state_ = STARTED_PARSING_STATE;
diff --git a/chrome/browser/printing/pwg_raster_converter.cc b/chrome/browser/printing/pwg_raster_converter.cc
index 1b0b4d8..bc00f525 100644
--- a/chrome/browser/printing/pwg_raster_converter.cc
+++ b/chrome/browser/printing/pwg_raster_converter.cc
@@ -57,17 +57,17 @@
     return temp_dir_.path().AppendASCII("input.pdf");
   }
 
-  IPC::PlatformFileForTransit GetPdfForProcess(base::ProcessHandle process) {
+  IPC::PlatformFileForTransit GetPdfForProcess() {
     DCHECK(pdf_file_.IsValid());
     IPC::PlatformFileForTransit transit =
-        IPC::TakeFileHandleForProcess(std::move(pdf_file_), process);
+        IPC::TakePlatformFileForTransit(std::move(pdf_file_));
     return transit;
   }
 
-  IPC::PlatformFileForTransit GetPwgForProcess(base::ProcessHandle process) {
+  IPC::PlatformFileForTransit GetPwgForProcess() {
     DCHECK(pwg_file_.IsValid());
     IPC::PlatformFileForTransit transit =
-        IPC::TakeFileHandleForProcess(std::move(pwg_file_), process);
+        IPC::TakePlatformFileForTransit(std::move(pwg_file_));
     return transit;
   }
 
@@ -196,12 +196,9 @@
     return;
   }
 
-  base::ProcessHandle process = utility_process_host_->GetData().handle;
   utility_process_host_->Send(new ChromeUtilityMsg_RenderPDFPagesToPWGRaster(
-      files_->GetPdfForProcess(process),
-      settings_,
-      bitmap_settings_,
-      files_->GetPwgForProcess(process)));
+      files_->GetPdfForProcess(), settings_, bitmap_settings_,
+      files_->GetPwgForProcess()));
   utility_process_host_.reset();
 }
 
diff --git a/chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.cc b/chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.cc
index d4ed097..cfc709f 100644
--- a/chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.cc
+++ b/chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.cc
@@ -91,18 +91,9 @@
 
 void SandboxedDMGAnalyzer::OnUtilityProcessStarted() {
   DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
-  base::ProcessHandle utility_process =
-      content::RenderProcessHost::run_renderer_in_process() ?
-          base::GetCurrentProcessHandle() :
-          utility_process_host_->GetData().handle;
-  if (utility_process == base::kNullProcessHandle) {
-    DLOG(ERROR) << "Child process handle is null";
-  }
-
   utility_process_host_->Send(
       new ChromeUtilityMsg_AnalyzeDmgFileForDownloadProtection(
-          IPC::TakeFileHandleForProcess(std::move(file_), utility_process)));
+          IPC::TakePlatformFileForTransit(std::move(file_))));
 }
 
 void SandboxedDMGAnalyzer::OnAnalysisFinished(
diff --git a/chrome/browser/safe_browsing/sandboxed_zip_analyzer.cc b/chrome/browser/safe_browsing/sandboxed_zip_analyzer.cc
index 1779e4ee..4c4b4b60 100644
--- a/chrome/browser/safe_browsing/sandboxed_zip_analyzer.cc
+++ b/chrome/browser/safe_browsing/sandboxed_zip_analyzer.cc
@@ -137,17 +137,9 @@
 
 void SandboxedZipAnalyzer::OnUtilityProcessStarted() {
   DCHECK_CURRENTLY_ON(BrowserThread::IO);
-  base::ProcessHandle utility_process =
-      content::RenderProcessHost::run_renderer_in_process() ?
-          base::GetCurrentProcessHandle() :
-          utility_process_host_->GetData().handle;
-
-  if (utility_process == base::kNullProcessHandle) {
-    DLOG(ERROR) << "Child process handle is null";
-  }
   utility_process_host_->Send(
       new ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection(
-          IPC::TakeFileHandleForProcess(std::move(zip_file_), utility_process),
+          IPC::TakePlatformFileForTransit(std::move(zip_file_)),
           IPC::GetPlatformFileForTransit(temp_file_.GetPlatformFile(),
                                          false /* !close_source_handle */)));
 }
diff --git a/chrome/service/service_utility_process_host.cc b/chrome/service/service_utility_process_host.cc
index 957f3e6..8389a10 100644
--- a/chrome/service/service_utility_process_host.cc
+++ b/chrome/service/service_utility_process_host.cc
@@ -95,7 +95,7 @@
     if (!temp_dir_.CreateUniqueTempDir())
       return false;
     return host_->Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles(
-        IPC::TakeFileHandleForProcess(std::move(pdf_file), host_->handle()),
+        IPC::TakePlatformFileForTransit(std::move(pdf_file)),
         conversion_settings));
   }
 
diff --git a/components/nacl/browser/nacl_file_host.cc b/components/nacl/browser/nacl_file_host.cc
index 36c9eba..4c1cdb6 100644
--- a/components/nacl/browser/nacl_file_host.cc
+++ b/components/nacl/browser/nacl_file_host.cc
@@ -61,8 +61,8 @@
   uint64_t file_token_hi = 0;
   nacl_browser->PutFilePath(file_path, &file_token_lo, &file_token_hi);
 
-  IPC::PlatformFileForTransit file_desc = IPC::TakeFileHandleForProcess(
-      std::move(file), nacl_host_message_filter->PeerHandle());
+  IPC::PlatformFileForTransit file_desc =
+      IPC::TakePlatformFileForTransit(std::move(file));
 
   write_reply_message(reply_msg, file_desc, file_token_lo, file_token_hi);
   nacl_host_message_filter->Send(reply_msg);
@@ -110,8 +110,8 @@
                    static_cast<WriteFileInfoReply>(
                        NaClHostMsg_GetReadonlyPnaclFD::WriteReplyParams)));
   } else {
-    IPC::PlatformFileForTransit target_desc = IPC::TakeFileHandleForProcess(
-        std::move(file_to_open), nacl_host_message_filter->PeerHandle());
+    IPC::PlatformFileForTransit target_desc =
+        IPC::TakePlatformFileForTransit(std::move(file_to_open));
     uint64_t dummy_file_token = 0;
     NaClHostMsg_GetReadonlyPnaclFD::WriteReplyParams(
         reply_msg, target_desc, dummy_file_token, dummy_file_token);
@@ -158,8 +158,8 @@
                      static_cast<WriteFileInfoReply>(
                          NaClHostMsg_OpenNaClExecutable::WriteReplyParams)));
     } else {
-      IPC::PlatformFileForTransit file_desc = IPC::TakeFileHandleForProcess(
-          std::move(file), nacl_host_message_filter->PeerHandle());
+      IPC::PlatformFileForTransit file_desc =
+          IPC::TakePlatformFileForTransit(std::move(file));
       uint64_t dummy_file_token = 0;
       NaClHostMsg_OpenNaClExecutable::WriteReplyParams(
           reply_msg, file_desc, dummy_file_token, dummy_file_token);
diff --git a/components/nacl/browser/nacl_host_message_filter.cc b/components/nacl/browser/nacl_host_message_filter.cc
index 72a9565..c8d0ebfe 100644
--- a/components/nacl/browser/nacl_host_message_filter.cc
+++ b/components/nacl/browser/nacl_host_message_filter.cc
@@ -225,8 +225,8 @@
       continue;
 
     prefetched_resource_files.push_back(NaClResourcePrefetchResult(
-        IPC::TakeFileHandleForProcess(std::move(file), PeerHandle()),
-        file_path_metadata, request_list[i].file_key));
+        IPC::TakePlatformFileForTransit(std::move(file)), file_path_metadata,
+        request_list[i].file_key));
 
     if (prefetched_resource_files.size() >= kMaxPreOpenResourceFiles)
       break;
@@ -301,8 +301,7 @@
     base::File file) {
   if (file.IsValid()) {
     NaClHostMsg_NaClCreateTemporaryFile::WriteReplyParams(
-        reply_msg,
-        IPC::TakeFileHandleForProcess(std::move(file), PeerHandle()));
+        reply_msg, IPC::TakePlatformFileForTransit(std::move(file)));
   } else {
     reply_msg->set_reply_error();
   }
diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc
index e1a2f275..f1af838 100644
--- a/components/nacl/browser/nacl_process_host.cc
+++ b/components/nacl/browser/nacl_process_host.cc
@@ -965,11 +965,10 @@
     content::BrowserThread::GetBlockingPool()->PostTask(
         FROM_HERE, base::Bind(&CloseFile, base::Passed(std::move(nexe_file_))));
     params.nexe_file_path_metadata = file_path;
-    params.nexe_file = IPC::TakeFileHandleForProcess(
-        std::move(checked_nexe_file), process_->GetData().handle);
+    params.nexe_file =
+        IPC::TakePlatformFileForTransit(std::move(checked_nexe_file));
   } else {
-    params.nexe_file = IPC::TakeFileHandleForProcess(
-        std::move(nexe_file_), process_->GetData().handle);
+    params.nexe_file = IPC::TakePlatformFileForTransit(std::move(nexe_file_));
   }
 
 #if defined(OS_LINUX)
@@ -1232,8 +1231,7 @@
   IPC::PlatformFileForTransit out_handle;
   if (file.IsValid()) {
     out_file_path = file_path;
-    out_handle = IPC::TakeFileHandleForProcess(std::move(file),
-                                               process_->GetData().handle);
+    out_handle = IPC::TakePlatformFileForTransit(std::move(file));
   } else {
     out_handle = IPC::InvalidPlatformFileForTransit();
   }
diff --git a/components/nacl/renderer/manifest_service_channel.cc b/components/nacl/renderer/manifest_service_channel.cc
index b32ee10..1bb962a0 100644
--- a/components/nacl/renderer/manifest_service_channel.cc
+++ b/components/nacl/renderer/manifest_service_channel.cc
@@ -13,6 +13,7 @@
 #include "content/public/common/sandbox_init.h"
 #include "content/public/renderer/render_thread.h"
 #include "ipc/ipc_channel.h"
+#include "ipc/ipc_platform_file.h"
 #include "ipc/ipc_sync_channel.h"
 #include "ppapi/c/pp_errors.h"
 #include "ppapi/c/ppb_file_io.h"
diff --git a/content/browser/renderer_host/database_message_filter.cc b/content/browser/renderer_host/database_message_filter.cc
index d29b294..5f9a8ae5d 100644
--- a/content/browser/renderer_host/database_message_filter.cc
+++ b/content/browser/renderer_host/database_message_filter.cc
@@ -163,7 +163,7 @@
   // database tracker.
   *handle = IPC::InvalidPlatformFileForTransit();
   if (file.IsValid()) {
-    *handle = IPC::TakeFileHandleForProcess(std::move(file), PeerHandle());
+    *handle = IPC::TakePlatformFileForTransit(std::move(file));
   } else if (tracked_file) {
     DCHECK(tracked_file->IsValid());
     *handle =
diff --git a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc
index 3059dd7..6f03077 100644
--- a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc
+++ b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc
@@ -136,7 +136,7 @@
   }
 
   IPC::PlatformFileForTransit transit_file =
-      IPC::TakeFileHandleForProcess(std::move(file), plugin_process_.Handle());
+      IPC::TakePlatformFileForTransit(std::move(file));
   ppapi::host::ReplyMessageContext reply_context =
       context->MakeReplyMessageContext();
   reply_context.params.AppendHandle(ppapi::proxy::SerializedHandle(
@@ -258,7 +258,7 @@
     return ppapi::FileErrorToPepperError(file.error_details());
 
   IPC::PlatformFileForTransit transit_file =
-      IPC::TakeFileHandleForProcess(std::move(file), plugin_process_.Handle());
+      IPC::TakePlatformFileForTransit(std::move(file));
   ppapi::host::ReplyMessageContext reply_context =
       context->MakeReplyMessageContext();
   reply_context.params.AppendHandle(ppapi::proxy::SerializedHandle(
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 5ba1bc8e8..734aee25 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -282,8 +282,7 @@
 #if defined(ENABLE_WEBRTC)
 
 // Creates a file used for handing over to the renderer.
-IPC::PlatformFileForTransit CreateFileForProcess(base::FilePath file_path,
-                                                 base::ProcessHandle process) {
+IPC::PlatformFileForTransit CreateFileForProcess(base::FilePath file_path) {
   DCHECK_CURRENTLY_ON(BrowserThread::FILE);
   base::File dump_file(file_path,
                        base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_APPEND);
@@ -292,7 +291,7 @@
             << dump_file.error_details();
     return IPC::InvalidPlatformFileForTransit();
   }
-  return IPC::TakeFileHandleForProcess(std::move(dump_file), process);
+  return IPC::TakePlatformFileForTransit(std::move(dump_file));
 }
 
 // Allow us to only run the trial in the first renderer.
@@ -2714,8 +2713,7 @@
   DCHECK_CURRENTLY_ON(BrowserThread::UI);
   BrowserThread::PostTaskAndReplyWithResult(
       BrowserThread::FILE, FROM_HERE,
-      base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id)),
-                 GetHandle()),
+      base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id))),
       base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer,
                  weak_factory_.GetWeakPtr(), id));
 }
@@ -2725,8 +2723,7 @@
   DCHECK_CURRENTLY_ON(BrowserThread::UI);
   BrowserThread::PostTaskAndReplyWithResult(
       BrowserThread::FILE, FROM_HERE,
-      base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id)),
-                 GetHandle()),
+      base::Bind(&CreateFileForProcess, file.AddExtension(IntToStringType(id))),
       base::Bind(&RenderProcessHostImpl::SendEventLogFileToRenderer,
                  weak_factory_.GetWeakPtr(), id));
 }
diff --git a/ipc/ipc_platform_file.cc b/ipc/ipc_platform_file.cc
index 2dcc9aa..dbcfddc 100644
--- a/ipc/ipc_platform_file.cc
+++ b/ipc/ipc_platform_file.cc
@@ -44,8 +44,7 @@
 #endif
 }
 
-PlatformFileForTransit TakeFileHandleForProcess(base::File file,
-                                                base::ProcessHandle process) {
+PlatformFileForTransit TakePlatformFileForTransit(base::File file) {
   return GetPlatformFileForTransit(file.TakePlatformFile(), true);
 }
 
diff --git a/ipc/ipc_platform_file.h b/ipc/ipc_platform_file.h
index 3d60983..15807f6 100644
--- a/ipc/ipc_platform_file.h
+++ b/ipc/ipc_platform_file.h
@@ -61,11 +61,10 @@
     base::PlatformFile file,
     bool close_source_handle);
 
-// Returns a file handle equivalent to |file| that can be used in |process|.
+// Creates a new handle that can be passed through IPC. The result must be
+// passed to the IPC layer as part of a message, or else it will leak.
 // Note that this function takes ownership of |file|.
-IPC_EXPORT PlatformFileForTransit TakeFileHandleForProcess(
-    base::File file,
-    base::ProcessHandle process);
+IPC_EXPORT PlatformFileForTransit TakePlatformFileForTransit(base::File file);
 
 }  // namespace IPC