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

Unified Diff: remoting/host/daemon_process.cc

Issue 16143004: Use a weak pointer to post service control events and session change notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/daemon_process.h ('k') | remoting/host/daemon_process_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/daemon_process.cc
diff --git a/remoting/host/daemon_process.cc b/remoting/host/daemon_process.cc
index b7a033694e59bc212ba64ab26e698eae58483002..d9d05b428bc8faa811aa89b2bafa546fc429feb4 100644
--- a/remoting/host/daemon_process.cc
+++ b/remoting/host/daemon_process.cc
@@ -37,8 +37,13 @@ std::ostream& operator<<(std::ostream& os, const ScreenResolution& resolution) {
} // namespace
DaemonProcess::~DaemonProcess() {
- DCHECK(!config_watcher_.get());
- DCHECK(desktop_sessions_.empty());
+ DCHECK(caller_task_runner()->BelongsToCurrentThread());
+
+ host_event_logger_.reset();
+ weak_factory_.InvalidateWeakPtrs();
+
+ config_watcher_.reset();
+ DeleteAllDesktopSessions();
}
void DaemonProcess::OnConfigUpdated(const std::string& serialized_config) {
@@ -163,10 +168,10 @@ DaemonProcess::DaemonProcess(
scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
scoped_refptr<AutoThreadTaskRunner> io_task_runner,
const base::Closure& stopped_callback)
- : Stoppable(caller_task_runner, stopped_callback),
- caller_task_runner_(caller_task_runner),
+ : caller_task_runner_(caller_task_runner),
io_task_runner_(io_task_runner),
next_terminal_id_(0),
+ stopped_callback_(stopped_callback),
weak_factory_(this) {
DCHECK(caller_task_runner->BelongsToCurrentThread());
}
@@ -270,6 +275,16 @@ void DaemonProcess::Initialize() {
LaunchNetworkProcess();
}
+void DaemonProcess::Stop() {
+ DCHECK(caller_task_runner()->BelongsToCurrentThread());
+
+ if (!stopped_callback_.is_null()) {
+ base::Closure stopped_callback = stopped_callback_;
+ stopped_callback_.Reset();
+ stopped_callback.Run();
+ }
+}
+
bool DaemonProcess::WasTerminalIdAllocated(int terminal_id) {
return terminal_id < next_terminal_id_;
}
@@ -352,18 +367,6 @@ void DaemonProcess::OnHostShutdown() {
FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, OnShutdown());
}
-void DaemonProcess::DoStop() {
- DCHECK(caller_task_runner()->BelongsToCurrentThread());
-
- host_event_logger_.reset();
- weak_factory_.InvalidateWeakPtrs();
-
- config_watcher_.reset();
- DeleteAllDesktopSessions();
-
- CompleteStopping();
-}
-
void DaemonProcess::DeleteAllDesktopSessions() {
while (!desktop_sessions_.empty()) {
delete desktop_sessions_.front();
« no previous file with comments | « remoting/host/daemon_process.h ('k') | remoting/host/daemon_process_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698