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

Unified Diff: remoting/host/desktop_session_agent.cc

Issue 12096071: Adding a unit test to verify the IPC channel between the network and desktop processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/desktop_session_agent.cc
diff --git a/remoting/host/desktop_session_agent.cc b/remoting/host/desktop_session_agent.cc
index a339f5382741258cfa57b031e8b1520e727d7a1d..b837b638c40288ce7c5760b096d7b85cfa7885e4 100644
--- a/remoting/host/desktop_session_agent.cc
+++ b/remoting/host/desktop_session_agent.cc
@@ -26,6 +26,10 @@
#include "remoting/protocol/input_event_tracker.h"
#include "third_party/skia/include/core/SkRegion.h"
+#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
Sergey Ulanov 2013/02/04 21:04:41 nit: don't need #ifdef here - that header should c
alexeypa (please no reviews) 2013/02/04 23:45:58 Done.
+#endif // defined(OS_POSIX)
+
namespace remoting {
namespace {
@@ -75,6 +79,7 @@ DesktopSessionAgent::~DesktopSessionAgent() {
DCHECK(!disconnect_window_);
DCHECK(!local_input_monitor_);
DCHECK(!network_channel_);
+ DCHECK(desktop_pipe_ == IPC::InvalidPlatformFileForTransit());
Sergey Ulanov 2013/02/04 21:04:41 DCHECK_EQ
alexeypa (please no reviews) 2013/02/04 23:45:58 Done.
DCHECK(!video_capturer_);
}
@@ -119,6 +124,8 @@ void DesktopSessionAgent::OnChannelConnected(int32 peer_pid) {
DCHECK(caller_task_runner()->BelongsToCurrentThread());
VLOG(1) << "IPC: desktop <- network (" << peer_pid << ")";
+
+ CloseDesktopPipeHandle();
}
void DesktopSessionAgent::OnChannelError() {
@@ -126,6 +133,7 @@ void DesktopSessionAgent::OnChannelError() {
// Make sure the channel is closed.
network_channel_.reset();
+ CloseDesktopPipeHandle();
// Notify the caller that the channel has been disconnected.
if (delegate_.get())
@@ -293,7 +301,10 @@ bool DesktopSessionAgent::Start(const base::WeakPtr<Delegate>& delegate,
delegate_ = delegate;
// Create an IPC channel to communicate with the network process.
- return CreateChannelForNetworkProcess(desktop_pipe_out, &network_channel_);
+ bool result = CreateChannelForNetworkProcess(&desktop_pipe_,
+ &network_channel_);
+ *desktop_pipe_out = desktop_pipe_;
+ return result;
}
void DesktopSessionAgent::Stop() {
@@ -528,10 +539,27 @@ DesktopSessionAgent::DesktopSessionAgent(
input_task_runner_(input_task_runner),
io_task_runner_(io_task_runner),
video_capture_task_runner_(video_capture_task_runner),
+ desktop_pipe_(IPC::InvalidPlatformFileForTransit()),
current_size_(SkISize::Make(0, 0)),
next_shared_buffer_id_(1),
started_(false) {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
}
+void DesktopSessionAgent::CloseDesktopPipeHandle() {
+ DCHECK(caller_task_runner_->BelongsToCurrentThread());
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698