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

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

Issue 13142002: Moved code implementing message-only windows to a dedicated class (Windows only). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 7 years, 9 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/win/host_service.h ('k') | remoting/host/win/message_window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/win/host_service.cc
diff --git a/remoting/host/win/host_service.cc b/remoting/host/win/host_service.cc
index 60a1796330efabe756c414465aabdd58fd3d6fc0..44e091f5cebf3e3d03729b4e5046ad6f80fbc1a4 100644
--- a/remoting/host/win/host_service.cc
+++ b/remoting/host/win/host_service.cc
@@ -22,7 +22,6 @@
#include "base/threading/thread.h"
#include "base/utf_string_conversions.h"
#include "base/win/scoped_com_initializer.h"
-#include "base/win/wrapped_window_proc.h"
#include "remoting/base/auto_thread.h"
#include "remoting/base/scoped_sc_handle_win.h"
#include "remoting/base/stoppable.h"
@@ -48,10 +47,6 @@ namespace {
const char kIoThreadName[] = "I/O thread";
-// A window class for the session change notifications window.
-const wchar_t kSessionNotificationWindowClass[] =
- L"Chromoting_SessionNotificationWindow";
-
// Command line switches:
// "--console" runs the service interactively for debugging purposes.
@@ -402,32 +397,15 @@ int HostService::RunInConsole() {
}
// Create a window for receiving session change notifications.
- HWND window = NULL;
- WNDCLASSEX window_class;
- base::win::InitializeWindowClass(
- kSessionNotificationWindowClass,
- &base::win::WrappedWindowProc<SessionChangeNotificationProc>,
- 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
- &window_class);
- HINSTANCE instance = window_class.hInstance;
- ATOM atom = RegisterClassExW(&window_class);
- if (atom == 0) {
- LOG_GETLASTERROR(ERROR)
- << "Failed to register the window class '"
- << kSessionNotificationWindowClass << "'";
- goto cleanup;
- }
-
- window = CreateWindowW(MAKEINTATOM(atom), 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0,
- instance, 0);
- if (window == NULL) {
+ win::MessageWindow window;
+ if (!window.Create(this)) {
LOG_GETLASTERROR(ERROR)
- << "Failed to creat the session notificationwindow";
+ << "Failed to create the session notification window";
goto cleanup;
}
// Subscribe to session change notifications.
- if (WTSRegisterSessionNotification(window,
+ if (WTSRegisterSessionNotification(window.hwnd(),
NOTIFY_FOR_ALL_SESSIONS) != FALSE) {
CreateLauncher(scoped_refptr<AutoThreadTaskRunner>(
new AutoThreadTaskRunner(main_task_runner_,
@@ -439,19 +417,11 @@ int HostService::RunInConsole() {
// Release the control handler.
stopped_event_.Signal();
- WTSUnRegisterSessionNotification(window);
+ WTSUnRegisterSessionNotification(window.hwnd());
result = kSuccessExitCode;
}
cleanup:
- if (window != NULL) {
- DestroyWindow(window);
- }
-
- if (atom != 0) {
- UnregisterClass(MAKEINTATOM(atom), instance);
- }
-
// Unsubscribe from console events. Ignore the exit code. There is nothing
// we can do about it now and the program is about to exit anyway. Even if
// it crashes nothing is going to be broken because of it.
@@ -460,6 +430,17 @@ cleanup:
return result;
}
+bool HostService::HandleMessage(
+ HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT* result) {
+ if (message == WM_WTSSESSION_CHANGE) {
+ OnSessionChange(wparam, lparam);
+ *result = 0;
+ return true;
+ }
+
+ return false;
+}
+
// static
BOOL WINAPI HostService::ConsoleControlHandler(DWORD event) {
HostService* self = HostService::GetInstance();
@@ -519,23 +500,6 @@ VOID WINAPI HostService::ServiceMain(DWORD argc, WCHAR* argv[]) {
self->stopped_event_.Signal();
}
-// static
-LRESULT CALLBACK HostService::SessionChangeNotificationProc(HWND hwnd,
- UINT message,
- WPARAM wparam,
- LPARAM lparam) {
- switch (message) {
- case WM_WTSSESSION_CHANGE: {
- HostService* self = HostService::GetInstance();
- self->OnSessionChange(wparam, lparam);
- return 0;
- }
-
- default:
- return DefWindowProc(hwnd, message, wparam, lparam);
- }
-}
-
int DaemonProcessMain() {
HostService* service = HostService::GetInstance();
if (!service->InitWithCommandLine(CommandLine::ForCurrentProcess())) {
« no previous file with comments | « remoting/host/win/host_service.h ('k') | remoting/host/win/message_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698