summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-04 10:57:19 +0000
committerrvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-04 10:57:19 +0000
commitcfeb6eedca30160b15d9a3b61f2e2b3ef1bb4245 (patch)
tree2224f3b9ba3b8f732300bb8565c1ee470ea30d53
parentd58ceea83f332d8958b10e2f21ae38ad15026e45 (diff)
downloadchromium_src-cfeb6eedca30160b15d9a3b61f2e2b3ef1bb4245.zip
chromium_src-cfeb6eedca30160b15d9a3b61f2e2b3ef1bb4245.tar.gz
chromium_src-cfeb6eedca30160b15d9a3b61f2e2b3ef1bb4245.tar.bz2
Remove PlatformFile from remoting
BUG=322664 Review URL: https://codereview.chromium.org/307463004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274761 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/host/desktop_process_unittest.cc2
-rw-r--r--remoting/host/desktop_session_agent.cc30
-rw-r--r--remoting/host/desktop_session_agent.h5
-rw-r--r--remoting/host/desktop_session_proxy.cc1
-rw-r--r--remoting/host/ipc_desktop_environment.cc3
-rw-r--r--remoting/host/ipc_util.h3
-rw-r--r--remoting/host/ipc_util_posix.cc5
-rw-r--r--remoting/host/ipc_util_win.cc22
-rw-r--r--remoting/host/native_messaging/native_messaging_reader_unittest.cc1
-rw-r--r--remoting/host/native_messaging/native_messaging_writer_unittest.cc1
-rw-r--r--remoting/host/win/unprivileged_process_delegate.cc9
11 files changed, 33 insertions, 49 deletions
diff --git a/remoting/host/desktop_process_unittest.cc b/remoting/host/desktop_process_unittest.cc
index d83d803..3f5f109 100644
--- a/remoting/host/desktop_process_unittest.cc
+++ b/remoting/host/desktop_process_unittest.cc
@@ -186,7 +186,7 @@ void DesktopProcessTest::OnDesktopAttached(
#if defined(OS_POSIX)
DCHECK(desktop_process.auto_close);
- base::ClosePlatformFile(desktop_process.fd);
+ base::File closer(IPC::PlatformFileForTransitToFile(desktop_process));
#endif // defined(OS_POSIX)
}
diff --git a/remoting/host/desktop_session_agent.cc b/remoting/host/desktop_session_agent.cc
index 4f023a6..634ca64 100644
--- a/remoting/host/desktop_session_agent.cc
+++ b/remoting/host/desktop_session_agent.cc
@@ -120,7 +120,6 @@ DesktopSessionAgent::DesktopSessionAgent(
io_task_runner_(io_task_runner),
video_capture_task_runner_(video_capture_task_runner),
control_factory_(this),
- desktop_pipe_(IPC::InvalidPlatformFileForTransit()),
next_shared_buffer_id_(1),
shared_buffers_(0),
started_(false) {
@@ -164,7 +163,7 @@ void DesktopSessionAgent::OnChannelConnected(int32 peer_pid) {
VLOG(1) << "IPC: desktop <- network (" << peer_pid << ")";
- CloseDesktopPipeHandle();
+ desktop_pipe_.Close();
}
void DesktopSessionAgent::OnChannelError() {
@@ -172,7 +171,7 @@ void DesktopSessionAgent::OnChannelError() {
// Make sure the channel is closed.
network_channel_.reset();
- CloseDesktopPipeHandle();
+ desktop_pipe_.Close();
// Notify the caller that the channel has been disconnected.
if (delegate_.get())
@@ -216,8 +215,6 @@ DesktopSessionAgent::~DesktopSessionAgent() {
DCHECK(!network_channel_);
DCHECK(!screen_controls_);
DCHECK(!video_capturer_);
-
- CloseDesktopPipeHandle();
}
const std::string& DesktopSessionAgent::client_jid() const {
@@ -371,7 +368,14 @@ bool DesktopSessionAgent::Start(const base::WeakPtr<Delegate>& delegate,
this,
&desktop_pipe_,
&network_channel_);
- *desktop_pipe_out = desktop_pipe_;
+ base::PlatformFile raw_desktop_pipe = desktop_pipe_.GetPlatformFile();
+#if defined(OS_WIN)
+ *desktop_pipe_out = IPC::PlatformFileForTransit(raw_desktop_pipe);
+#elif defined(OS_POSIX)
+ *desktop_pipe_out = IPC::PlatformFileForTransit(raw_desktop_pipe, false);
+#else
+#error Unsupported platform.
+#endif
return result;
}
@@ -562,18 +566,4 @@ void DesktopSessionAgent::OnSharedBufferDeleted(int id) {
SendToNetwork(new ChromotingDesktopNetworkMsg_ReleaseSharedBuffer(id));
}
-void DesktopSessionAgent::CloseDesktopPipeHandle() {
- if (!(desktop_pipe_ == IPC::InvalidPlatformFileForTransit())) {
-#if defined(OS_WIN)
- base::ClosePlatformFile(desktop_pipe_);
-#elif defined(OS_POSIX)
- base::ClosePlatformFile(desktop_pipe_.fd);
-#else // !defined(OS_POSIX)
-#error Unsupported platform.
-#endif // !defined(OS_POSIX)
-
- desktop_pipe_ = IPC::InvalidPlatformFileForTransit();
- }
-}
-
} // namespace remoting
diff --git a/remoting/host/desktop_session_agent.h b/remoting/host/desktop_session_agent.h
index 82c02fd..db6fc65 100644
--- a/remoting/host/desktop_session_agent.h
+++ b/remoting/host/desktop_session_agent.h
@@ -153,9 +153,6 @@ class DesktopSessionAgent
// Called by SharedBuffer when it's destroyed.
void OnSharedBufferDeleted(int id);
- // Closes |desktop_pipe_| if it is open.
- void CloseDesktopPipeHandle();
-
// Task runner dedicated to running methods of |audio_capturer_|.
scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner_;
@@ -201,7 +198,7 @@ class DesktopSessionAgent
// The client end of the network-to-desktop pipe. It is kept alive until
// the network process connects to the pipe.
- IPC::PlatformFileForTransit desktop_pipe_;
+ base::File desktop_pipe_;
// Size of the most recent captured video frame.
webrtc::DesktopSize current_size_;
diff --git a/remoting/host/desktop_session_proxy.cc b/remoting/host/desktop_session_proxy.cc
index 73497f9..28f8296 100644
--- a/remoting/host/desktop_session_proxy.cc
+++ b/remoting/host/desktop_session_proxy.cc
@@ -6,7 +6,6 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
-#include "base/platform_file.h"
#include "base/process/process_handle.h"
#include "base/memory/shared_memory.h"
#include "base/single_thread_task_runner.h"
diff --git a/remoting/host/ipc_desktop_environment.cc b/remoting/host/ipc_desktop_environment.cc
index 5125494..3332712 100644
--- a/remoting/host/ipc_desktop_environment.cc
+++ b/remoting/host/ipc_desktop_environment.cc
@@ -193,8 +193,7 @@ void IpcDesktopEnvironmentFactory::OnDesktopSessionAgentAttached(
#if defined(OS_POSIX)
DCHECK(desktop_pipe.auto_close);
-
- base::ClosePlatformFile(desktop_pipe.fd);
+ base::File pipe_closer(IPC::PlatformFileForTransitToFile(desktop_pipe));
#endif // defined(OS_POSIX)
}
}
diff --git a/remoting/host/ipc_util.h b/remoting/host/ipc_util.h
index 78b7271..09c08fd 100644
--- a/remoting/host/ipc_util.h
+++ b/remoting/host/ipc_util.h
@@ -18,6 +18,7 @@
#endif // defined(OS_WIN)
namespace base {
+class File;
class SingleThreadTaskRunner;
} // namespace base
@@ -36,7 +37,7 @@ namespace remoting {
bool CreateConnectedIpcChannel(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
IPC::Listener* listener,
- IPC::PlatformFileForTransit* client_out,
+ base::File* client_out,
scoped_ptr<IPC::ChannelProxy>* server_out);
#if defined(OS_WIN)
diff --git a/remoting/host/ipc_util_posix.cc b/remoting/host/ipc_util_posix.cc
index d7c6a5d..4901c99 100644
--- a/remoting/host/ipc_util_posix.cc
+++ b/remoting/host/ipc_util_posix.cc
@@ -9,6 +9,7 @@
#include <sys/types.h>
#include <unistd.h>
+#include "base/files/file.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "base/single_thread_task_runner.h"
@@ -20,7 +21,7 @@ namespace remoting {
bool CreateConnectedIpcChannel(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
IPC::Listener* listener,
- IPC::PlatformFileForTransit* client_out,
+ base::File* client_out,
scoped_ptr<IPC::ChannelProxy>* server_out) {
// Create a socket pair.
int pipe_fds[2];
@@ -50,7 +51,7 @@ bool CreateConnectedIpcChannel(
listener,
io_task_runner.get()));
- *client_out = base::FileDescriptor(pipe_fds[1], false);
+ *client_out = base::File(pipe_fds[1]);
return true;
}
diff --git a/remoting/host/ipc_util_win.cc b/remoting/host/ipc_util_win.cc
index 37c3383..dabdbe1 100644
--- a/remoting/host/ipc_util_win.cc
+++ b/remoting/host/ipc_util_win.cc
@@ -4,6 +4,7 @@
#include "remoting/host/ipc_util.h"
+#include "base/files/file.h"
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
@@ -25,7 +26,7 @@ const char kChromePipeNamePrefix[] = "\\\\.\\pipe\\chrome.";
bool CreateConnectedIpcChannel(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
IPC::Listener* listener,
- IPC::PlatformFileForTransit* client_out,
+ base::File* client_out,
scoped_ptr<IPC::ChannelProxy>* server_out) {
// presubmit: allow wstring
std::wstring user_sid;
@@ -68,21 +69,20 @@ bool CreateConnectedIpcChannel(
// Create the client end of the channel. This code should match the code in
// IPC::Channel.
- ScopedHandle client;
- client.Set(CreateFile(base::UTF8ToUTF16(pipe_name).c_str(),
- GENERIC_READ | GENERIC_WRITE,
- 0,
- &security_attributes,
- OPEN_EXISTING,
- SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION |
- FILE_FLAG_OVERLAPPED,
- NULL));
+ base::File client(CreateFile(base::UTF8ToUTF16(pipe_name).c_str(),
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ &security_attributes,
+ OPEN_EXISTING,
+ SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION |
+ FILE_FLAG_OVERLAPPED,
+ NULL));
if (!client.IsValid()) {
PLOG(ERROR) << "Failed to connect to '" << pipe_name << "'";
return false;
}
- *client_out = client.Take();
+ *client_out = client.Pass();
*server_out = server.Pass();
return true;
}
diff --git a/remoting/host/native_messaging/native_messaging_reader_unittest.cc b/remoting/host/native_messaging/native_messaging_reader_unittest.cc
index 964dffe..96ad18f 100644
--- a/remoting/host/native_messaging/native_messaging_reader_unittest.cc
+++ b/remoting/host/native_messaging/native_messaging_reader_unittest.cc
@@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "base/platform_file.h"
#include "base/run_loop.h"
#include "base/values.h"
#include "remoting/host/setup/test_util.h"
diff --git a/remoting/host/native_messaging/native_messaging_writer_unittest.cc b/remoting/host/native_messaging/native_messaging_writer_unittest.cc
index be7f2f0..df9158f 100644
--- a/remoting/host/native_messaging/native_messaging_writer_unittest.cc
+++ b/remoting/host/native_messaging/native_messaging_writer_unittest.cc
@@ -7,7 +7,6 @@
#include "base/basictypes.h"
#include "base/json/json_reader.h"
#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
#include "base/stl_util.h"
#include "base/values.h"
#include "remoting/host/setup/test_util.h"
diff --git a/remoting/host/win/unprivileged_process_delegate.cc b/remoting/host/win/unprivileged_process_delegate.cc
index 1f5a174..69a45aa 100644
--- a/remoting/host/win/unprivileged_process_delegate.cc
+++ b/remoting/host/win/unprivileged_process_delegate.cc
@@ -11,6 +11,7 @@
#include <sddl.h>
#include "base/command_line.h"
+#include "base/files/file.h"
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/single_thread_task_runner.h"
@@ -277,18 +278,16 @@ void UnprivilegedProcessDelegate::LaunchProcess(
base::AutoLock lock(g_inherit_handles_lock.Get());
// Create a connected IPC channel.
- HANDLE temp_handle;
- if (!CreateConnectedIpcChannel(io_task_runner_, this, &temp_handle,
- &server)) {
+ base::File client;
+ if (!CreateConnectedIpcChannel(io_task_runner_, this, &client, &server)) {
ReportFatalError();
return;
}
- ScopedHandle client(temp_handle);
// Convert the handle value into a decimal integer. Handle values are 32bit
// even on 64bit platforms.
std::string pipe_handle = base::StringPrintf(
- "%d", reinterpret_cast<ULONG_PTR>(client.Get()));
+ "%d", reinterpret_cast<ULONG_PTR>(client.GetPlatformFile()));
// Pass the IPC channel via the command line.
base::CommandLine command_line(target_command_->argv());