| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "remoting/host/daemon_process.h" | 5 #include "remoting/host/daemon_process.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "remoting/base/auto_thread_task_runner.h" |
| 13 #include "remoting/host/branding.h" | 14 #include "remoting/host/branding.h" |
| 14 #include "remoting/host/chromoting_messages.h" | 15 #include "remoting/host/chromoting_messages.h" |
| 15 #include "remoting/host/desktop_session.h" | 16 #include "remoting/host/desktop_session.h" |
| 16 | 17 |
| 17 namespace remoting { | 18 namespace remoting { |
| 18 | 19 |
| 19 DaemonProcess::~DaemonProcess() { | 20 DaemonProcess::~DaemonProcess() { |
| 20 DCHECK(!config_watcher_.get()); | 21 DCHECK(!config_watcher_.get()); |
| 21 DCHECK(desktop_sessions_.empty()); | 22 DCHECK(desktop_sessions_.empty()); |
| 22 } | 23 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 33 | 34 |
| 34 void DaemonProcess::OnConfigWatcherError() { | 35 void DaemonProcess::OnConfigWatcherError() { |
| 35 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 36 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 36 | 37 |
| 37 Stop(); | 38 Stop(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void DaemonProcess::OnChannelConnected(int32 peer_pid) { | 41 void DaemonProcess::OnChannelConnected(int32 peer_pid) { |
| 41 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 42 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 42 | 43 |
| 44 VLOG(1) << "IPC: daemon <- network (" << peer_pid << ")"; |
| 45 |
| 43 DeleteAllDesktopSessions(); | 46 DeleteAllDesktopSessions(); |
| 44 | 47 |
| 45 // Reset the last known terminal ID because no IDs have been allocated | 48 // Reset the last known terminal ID because no IDs have been allocated |
| 46 // by the the newly started process yet. | 49 // by the the newly started process yet. |
| 47 next_terminal_id_ = 0; | 50 next_terminal_id_ = 0; |
| 48 | 51 |
| 49 // Send the configuration to the network process. | 52 // Send the configuration to the network process. |
| 50 SendToNetwork( | 53 SendToNetwork( |
| 51 new ChromotingDaemonNetworkMsg_Configuration(serialized_config_)); | 54 new ChromotingDaemonNetworkMsg_Configuration(serialized_config_)); |
| 52 } | 55 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 101 |
| 99 delete *i; | 102 delete *i; |
| 100 desktop_sessions_.erase(i); | 103 desktop_sessions_.erase(i); |
| 101 | 104 |
| 102 VLOG(1) << "Daemon: closed desktop session " << terminal_id; | 105 VLOG(1) << "Daemon: closed desktop session " << terminal_id; |
| 103 SendToNetwork( | 106 SendToNetwork( |
| 104 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); | 107 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); |
| 105 } | 108 } |
| 106 | 109 |
| 107 DaemonProcess::DaemonProcess( | 110 DaemonProcess::DaemonProcess( |
| 108 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 111 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 109 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 112 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 110 const base::Closure& stopped_callback) | 113 const base::Closure& stopped_callback) |
| 111 : Stoppable(caller_task_runner, stopped_callback), | 114 : Stoppable(caller_task_runner, stopped_callback), |
| 112 caller_task_runner_(caller_task_runner), | 115 caller_task_runner_(caller_task_runner), |
| 113 io_task_runner_(io_task_runner), | 116 io_task_runner_(io_task_runner), |
| 114 next_terminal_id_(0) { | 117 next_terminal_id_(0) { |
| 115 DCHECK(caller_task_runner->BelongsToCurrentThread()); | 118 DCHECK(caller_task_runner->BelongsToCurrentThread()); |
| 116 } | 119 } |
| 117 | 120 |
| 118 bool DaemonProcess::IsTerminalIdKnown(int terminal_id) { | 121 bool DaemonProcess::IsTerminalIdKnown(int terminal_id) { |
| 119 return terminal_id < next_terminal_id_; | 122 return terminal_id < next_terminal_id_; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 178 } |
| 176 | 179 |
| 177 void DaemonProcess::DeleteAllDesktopSessions() { | 180 void DaemonProcess::DeleteAllDesktopSessions() { |
| 178 while (!desktop_sessions_.empty()) { | 181 while (!desktop_sessions_.empty()) { |
| 179 delete desktop_sessions_.front(); | 182 delete desktop_sessions_.front(); |
| 180 desktop_sessions_.pop_front(); | 183 desktop_sessions_.pop_front(); |
| 181 } | 184 } |
| 182 } | 185 } |
| 183 | 186 |
| 184 } // namespace remoting | 187 } // namespace remoting |
| OLD | NEW |