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 "chrome/common/service_process_util_posix.h" | 5 #include "chrome/common/service_process_util_posix.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // not, but we don't ever expect it to be called. | 73 // not, but we don't ever expect it to be called. |
74 static void SigTermHandler(int sig, siginfo_t* info, void* uap) { | 74 static void SigTermHandler(int sig, siginfo_t* info, void* uap) { |
75 // TODO(dmaclach): add security here to make sure that we are being shut | 75 // TODO(dmaclach): add security here to make sure that we are being shut |
76 // down by an appropriate process. | 76 // down by an appropriate process. |
77 int message = ServiceProcessTerminateMonitor::kTerminateMessage; | 77 int message = ServiceProcessTerminateMonitor::kTerminateMessage; |
78 if (write(g_signal_socket, &message, sizeof(message)) < 0) { | 78 if (write(g_signal_socket, &message, sizeof(message)) < 0) { |
79 DPLOG(ERROR) << "write"; | 79 DPLOG(ERROR) << "write"; |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 ServiceProcessState::StateData::StateData() : set_action(false) { | 83 ServiceProcessState::StateData::StateData() |
| 84 : watcher(FROM_HERE), set_action(false) { |
84 memset(sockets, -1, sizeof(sockets)); | 85 memset(sockets, -1, sizeof(sockets)); |
85 memset(&old_action, 0, sizeof(old_action)); | 86 memset(&old_action, 0, sizeof(old_action)); |
86 } | 87 } |
87 | 88 |
88 void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal, | 89 void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal, |
89 bool* success) { | 90 bool* success) { |
90 DCHECK(task_runner->BelongsToCurrentThread()); | 91 DCHECK(task_runner->BelongsToCurrentThread()); |
91 DCHECK_EQ(g_signal_socket, -1); | 92 DCHECK_EQ(g_signal_socket, -1); |
92 DCHECK(!signal->IsSignaled()); | 93 DCHECK(!signal->IsSignaled()); |
93 *success = base::MessageLoopForIO::current()->WatchFileDescriptor( | 94 *success = base::MessageLoopForIO::current()->WatchFileDescriptor( |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return success; | 196 return success; |
196 } | 197 } |
197 | 198 |
198 void ServiceProcessState::TearDownState() { | 199 void ServiceProcessState::TearDownState() { |
199 if (state_ && state_->task_runner) | 200 if (state_ && state_->task_runner) |
200 state_->task_runner->DeleteSoon(FROM_HERE, state_); | 201 state_->task_runner->DeleteSoon(FROM_HERE, state_); |
201 else | 202 else |
202 delete state_; | 203 delete state_; |
203 state_ = nullptr; | 204 state_ = nullptr; |
204 } | 205 } |
OLD | NEW |