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

Side by Side Diff: remoting/host/posix/signal_handler.cc

Issue 14314026: remoting: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // TODO(jamiewalch): Add unit tests for this. 5 // TODO(jamiewalch): Add unit tests for this.
6 6
7 #include "remoting/host/posix/signal_handler.h" 7 #include "remoting/host/posix/signal_handler.h"
8 8
9 #include <errno.h> 9 #include <errno.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (!g_signal_listener) { 84 if (!g_signal_listener) {
85 g_signal_listener = new SignalListener(); 85 g_signal_listener = new SignalListener();
86 } 86 }
87 if (!g_write_fd) { 87 if (!g_write_fd) {
88 int pipe_fd[2]; 88 int pipe_fd[2];
89 int result = pipe(pipe_fd); 89 int result = pipe(pipe_fd);
90 if (result < 0) { 90 if (result < 0) {
91 LOG(ERROR) << "Could not create signal pipe: " << errno; 91 LOG(ERROR) << "Could not create signal pipe: " << errno;
92 return false; 92 return false;
93 } 93 }
94 MessageLoopForIO* message_loop = MessageLoopForIO::current(); 94 base::MessageLoopForIO* message_loop = base::MessageLoopForIO::current();
95 result = message_loop->WatchFileDescriptor( 95 result =
96 pipe_fd[0], true, MessageLoopForIO::WATCH_READ, 96 message_loop->WatchFileDescriptor(pipe_fd[0],
97 &g_signal_listener->controller, g_signal_listener); 97 true,
98 base::MessageLoopForIO::WATCH_READ,
99 &g_signal_listener->controller,
100 g_signal_listener);
98 if (!result) { 101 if (!result) {
99 LOG(ERROR) << "Failed to create signal detector task."; 102 LOG(ERROR) << "Failed to create signal detector task.";
100 close(pipe_fd[0]); 103 close(pipe_fd[0]);
101 close(pipe_fd[1]); 104 close(pipe_fd[1]);
102 return false; 105 return false;
103 } 106 }
104 g_write_fd = pipe_fd[1]; 107 g_write_fd = pipe_fd[1];
105 } 108 }
106 if (signal(signal_number, GlobalSignalHandler) == SIG_ERR) { 109 if (signal(signal_number, GlobalSignalHandler) == SIG_ERR) {
107 LOG(ERROR) << "signal() failed: " << errno; 110 LOG(ERROR) << "signal() failed: " << errno;
108 return false; 111 return false;
109 } 112 }
110 g_signal_listener->AddSignalHandler(signal_number, handler); 113 g_signal_listener->AddSignalHandler(signal_number, handler);
111 return true; 114 return true;
112 } 115 }
113 116
114 } // namespace remoting 117 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/policy_hack/policy_watcher_unittest.cc ('k') | remoting/host/register_support_host_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698