Commit cd95dda3 authored by qi1988.yang's avatar qi1988.yang Committed by Commit bot

Standardize struct public member variables in ServiceProcessState::StateData

Fix the TODO add by jhawkins.
Struct data members do not have the trailing underscores that data members in
class have.

BUG=

Review URL: https://codereview.chromium.org/968813002

Cr-Commit-Position: refs/heads/master@{#319007}
parent 668cf5cd
...@@ -66,8 +66,8 @@ bool CheckServiceProcessReady() { ...@@ -66,8 +66,8 @@ bool CheckServiceProcessReady() {
} }
bool ServiceProcessState::TakeSingletonLock() { bool ServiceProcessState::TakeSingletonLock() {
state_->initializing_lock_.reset(TakeServiceInitializingLock(true)); state_->initializing_lock.reset(TakeServiceInitializingLock(true));
return state_->initializing_lock_.get(); return state_->initializing_lock.get();
} }
bool ServiceProcessState::AddToAutoRun() { bool ServiceProcessState::AddToAutoRun() {
......
...@@ -180,13 +180,13 @@ bool ServiceProcessState::Initialize() { ...@@ -180,13 +180,13 @@ bool ServiceProcessState::Initialize() {
CFRelease(err); CFRelease(err);
return false; return false;
} }
state_->launchd_conf_.reset(dict); state_->launchd_conf.reset(dict);
return true; return true;
} }
IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() { IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() {
DCHECK(state_); DCHECK(state_);
NSDictionary *ns_launchd_conf = base::mac::CFToNSCast(state_->launchd_conf_); NSDictionary *ns_launchd_conf = base::mac::CFToNSCast(state_->launchd_conf);
NSDictionary* socket_dict = NSDictionary* socket_dict =
[ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_SOCKETS]; [ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_SOCKETS];
NSArray* sockets = NSArray* sockets =
...@@ -301,7 +301,7 @@ bool ServiceProcessState::RemoveFromAutoRun() { ...@@ -301,7 +301,7 @@ bool ServiceProcessState::RemoveFromAutoRun() {
bool ServiceProcessState::StateData::WatchExecutable() { bool ServiceProcessState::StateData::WatchExecutable() {
base::mac::ScopedNSAutoreleasePool pool; base::mac::ScopedNSAutoreleasePool pool;
NSDictionary* ns_launchd_conf = base::mac::CFToNSCast(launchd_conf_); NSDictionary* ns_launchd_conf = base::mac::CFToNSCast(launchd_conf);
NSString* exe_path = [ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_PROGRAM]; NSString* exe_path = [ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_PROGRAM];
if (!exe_path) { if (!exe_path) {
DLOG(ERROR) << "No " LAUNCH_JOBKEY_PROGRAM; DLOG(ERROR) << "No " LAUNCH_JOBKEY_PROGRAM;
...@@ -313,15 +313,15 @@ bool ServiceProcessState::StateData::WatchExecutable() { ...@@ -313,15 +313,15 @@ bool ServiceProcessState::StateData::WatchExecutable() {
scoped_ptr<ExecFilePathWatcherCallback> callback( scoped_ptr<ExecFilePathWatcherCallback> callback(
new ExecFilePathWatcherCallback); new ExecFilePathWatcherCallback);
if (!callback->Init(executable_path)) { if (!callback->Init(executable_path)) {
DLOG(ERROR) << "executable_watcher_.Init " << executable_path.value(); DLOG(ERROR) << "executable_watcher.Init " << executable_path.value();
return false; return false;
} }
if (!executable_watcher_.Watch( if (!executable_watcher.Watch(
executable_path, executable_path,
false, false,
base::Bind(&ExecFilePathWatcherCallback::NotifyPathChanged, base::Bind(&ExecFilePathWatcherCallback::NotifyPathChanged,
base::Owned(callback.release())))) { base::Owned(callback.release())))) {
DLOG(ERROR) << "executable_watcher_.watch " << executable_path.value(); DLOG(ERROR) << "executable_watcher.watch " << executable_path.value();
return false; return false;
} }
return true; return true;
......
...@@ -77,9 +77,9 @@ static void SigTermHandler(int sig, siginfo_t* info, void* uap) { ...@@ -77,9 +77,9 @@ static void SigTermHandler(int sig, siginfo_t* info, void* uap) {
} }
} }
ServiceProcessState::StateData::StateData() : set_action_(false) { ServiceProcessState::StateData::StateData() : set_action(false) {
memset(sockets_, -1, sizeof(sockets_)); memset(sockets, -1, sizeof(sockets));
memset(&old_action_, 0, sizeof(old_action_)); memset(&old_action, 0, sizeof(old_action));
} }
void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal, void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal,
...@@ -87,17 +87,17 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal, ...@@ -87,17 +87,17 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal,
DCHECK_EQ(g_signal_socket, -1); DCHECK_EQ(g_signal_socket, -1);
DCHECK(!signal->IsSignaled()); DCHECK(!signal->IsSignaled());
*success = base::MessageLoopForIO::current()->WatchFileDescriptor( *success = base::MessageLoopForIO::current()->WatchFileDescriptor(
sockets_[0], sockets[0],
true, true,
base::MessageLoopForIO::WATCH_READ, base::MessageLoopForIO::WATCH_READ,
&watcher_, &watcher,
terminate_monitor_.get()); terminate_monitor.get());
if (!*success) { if (!*success) {
DLOG(ERROR) << "WatchFileDescriptor"; DLOG(ERROR) << "WatchFileDescriptor";
signal->Signal(); signal->Signal();
return; return;
} }
g_signal_socket = sockets_[1]; g_signal_socket = sockets[1];
// Set up signal handler for SIGTERM. // Set up signal handler for SIGTERM.
struct sigaction action; struct sigaction action;
...@@ -105,7 +105,7 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal, ...@@ -105,7 +105,7 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal,
action.sa_sigaction = SigTermHandler; action.sa_sigaction = SigTermHandler;
sigemptyset(&action.sa_mask); sigemptyset(&action.sa_mask);
action.sa_flags = SA_SIGINFO; action.sa_flags = SA_SIGINFO;
*success = sigaction(SIGTERM, &action, &old_action_) == 0; *success = sigaction(SIGTERM, &action, &old_action) == 0;
if (!*success) { if (!*success) {
DPLOG(ERROR) << "sigaction"; DPLOG(ERROR) << "sigaction";
signal->Signal(); signal->Signal();
...@@ -115,8 +115,8 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal, ...@@ -115,8 +115,8 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal,
// If the old_action is not default, somebody else has installed a // If the old_action is not default, somebody else has installed a
// a competing handler. Our handler is going to override it so it // a competing handler. Our handler is going to override it so it
// won't be called. If this occurs it needs to be fixed. // won't be called. If this occurs it needs to be fixed.
DCHECK_EQ(old_action_.sa_handler, SIG_DFL); DCHECK_EQ(old_action.sa_handler, SIG_DFL);
set_action_ = true; set_action = true;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
*success = WatchExecutable(); *success = WatchExecutable();
...@@ -126,24 +126,24 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal, ...@@ -126,24 +126,24 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal,
return; return;
} }
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
initializing_lock_.reset(); initializing_lock.reset();
#endif // OS_POSIX #endif // OS_POSIX
signal->Signal(); signal->Signal();
} }
ServiceProcessState::StateData::~StateData() { ServiceProcessState::StateData::~StateData() {
if (sockets_[0] != -1) { if (sockets[0] != -1) {
if (IGNORE_EINTR(close(sockets_[0]))) { if (IGNORE_EINTR(close(sockets[0]))) {
DPLOG(ERROR) << "close"; DPLOG(ERROR) << "close";
} }
} }
if (sockets_[1] != -1) { if (sockets[1] != -1) {
if (IGNORE_EINTR(close(sockets_[1]))) { if (IGNORE_EINTR(close(sockets[1]))) {
DPLOG(ERROR) << "close"; DPLOG(ERROR) << "close";
} }
} }
if (set_action_) { if (set_action) {
if (sigaction(SIGTERM, &old_action_, NULL) < 0) { if (sigaction(SIGTERM, &old_action, NULL) < 0) {
DPLOG(ERROR) << "sigaction"; DPLOG(ERROR) << "sigaction";
} }
} }
...@@ -167,14 +167,14 @@ bool ServiceProcessState::SignalReady( ...@@ -167,14 +167,14 @@ bool ServiceProcessState::SignalReady(
DCHECK(state_); DCHECK(state_);
#if defined(OS_POSIX) && !defined(OS_MACOSX) #if defined(OS_POSIX) && !defined(OS_MACOSX)
state_->running_lock_.reset(TakeServiceRunningLock(true)); state_->running_lock.reset(TakeServiceRunningLock(true));
if (state_->running_lock_.get() == NULL) { if (state_->running_lock.get() == NULL) {
return false; return false;
} }
#endif #endif
state_->terminate_monitor_.reset( state_->terminate_monitor.reset(
new ServiceProcessTerminateMonitor(terminate_task)); new ServiceProcessTerminateMonitor(terminate_task));
if (pipe(state_->sockets_) < 0) { if (pipe(state_->sockets) < 0) {
DPLOG(ERROR) << "pipe"; DPLOG(ERROR) << "pipe";
return false; return false;
} }
......
...@@ -64,25 +64,21 @@ struct ServiceProcessState::StateData ...@@ -64,25 +64,21 @@ struct ServiceProcessState::StateData
// to be monitoring it. // to be monitoring it.
void SignalReady(base::WaitableEvent* signal, bool* success); void SignalReady(base::WaitableEvent* signal, bool* success);
// TODO(jhawkins): Either make this a class or rename these public member
// variables to remove the trailing underscore.
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
bool WatchExecutable(); bool WatchExecutable();
base::ScopedCFTypeRef<CFDictionaryRef> launchd_conf_; base::ScopedCFTypeRef<CFDictionaryRef> launchd_conf;
base::FilePathWatcher executable_watcher_; base::FilePathWatcher executable_watcher;
#endif // OS_MACOSX #endif // OS_MACOSX
#if defined(OS_POSIX) && !defined(OS_MACOSX) #if defined(OS_POSIX) && !defined(OS_MACOSX)
scoped_ptr<MultiProcessLock> initializing_lock_; scoped_ptr<MultiProcessLock> initializing_lock;
scoped_ptr<MultiProcessLock> running_lock_; scoped_ptr<MultiProcessLock> running_lock;
#endif #endif
scoped_ptr<ServiceProcessTerminateMonitor> terminate_monitor_; scoped_ptr<ServiceProcessTerminateMonitor> terminate_monitor;
base::MessageLoopForIO::FileDescriptorWatcher watcher_; base::MessageLoopForIO::FileDescriptorWatcher watcher;
int sockets_[2]; int sockets[2];
struct sigaction old_action_; struct sigaction old_action;
bool set_action_; bool set_action;
protected: protected:
friend class base::RefCountedThreadSafe<ServiceProcessState::StateData>; friend class base::RefCountedThreadSafe<ServiceProcessState::StateData>;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment