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

Unified Diff: remoting/host/win/host_service.h

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_win.cc ('k') | remoting/host/win/host_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/win/host_service.h
diff --git a/remoting/host/win/host_service.h b/remoting/host/win/host_service.h
index aa1d9ab5f1505ca988fccb20778a065045631ee2..a5910712b95009a3dd64c7302a40ac76d9a68df5 100644
--- a/remoting/host/win/host_service.h
+++ b/remoting/host/win/host_service.h
@@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/singleton.h"
+#include "base/memory/weak_ptr.h"
#include "base/synchronization/waitable_event.h"
#include "net/base/ip_endpoint.h"
#include "remoting/host/win/message_window.h"
@@ -25,7 +26,7 @@ class SingleThreadTaskRunner;
namespace remoting {
class AutoThreadTaskRunner;
-class Stoppable;
+class DaemonProcess;
class WtsTerminalObserver;
class HostService : public win::MessageWindow::Delegate,
@@ -55,8 +56,6 @@ class HostService : public win::MessageWindow::Delegate,
// Creates the process launcher.
void CreateLauncher(scoped_refptr<AutoThreadTaskRunner> task_runner);
- void OnChildStopped();
-
// This function handshakes with the service control manager and starts
// the service.
int RunAsService();
@@ -70,6 +69,9 @@ class HostService : public win::MessageWindow::Delegate,
// console application).
int RunInConsole();
+ // Stops and deletes |daemon_process_|.
+ void StopDaemonProcess();
+
// win::MessageWindow::Delegate interface.
virtual bool HandleMessage(HWND hwnd,
UINT message,
@@ -105,9 +107,10 @@ class HostService : public win::MessageWindow::Delegate,
// The list of observers receiving session notifications.
std::list<RegisteredObserver> observers_;
- scoped_ptr<Stoppable> child_;
+ scoped_ptr<DaemonProcess> daemon_process_;
- // Service message loop.
+ // Service message loop. |main_task_runner_| must be valid as long as the
+ // Control+C or service notification handler is registered.
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
// The action routine to be executed.
@@ -119,6 +122,10 @@ class HostService : public win::MessageWindow::Delegate,
// A waitable event that is used to wait until the service is stopped.
base::WaitableEvent stopped_event_;
+ // Used to post session change notifications and control events.
+ base::WeakPtrFactory<HostService> weak_factory_;
+ base::WeakPtr<HostService> weak_ptr_;
+
// Singleton.
friend struct DefaultSingletonTraits<HostService>;
« no previous file with comments | « remoting/host/daemon_process_win.cc ('k') | remoting/host/win/host_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698