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() {
}
bool ServiceProcessState::TakeSingletonLock() {
state_->initializing_lock_.reset(TakeServiceInitializingLock(true));
return state_->initializing_lock_.get();
state_->initializing_lock.reset(TakeServiceInitializingLock(true));
return state_->initializing_lock.get();
}
bool ServiceProcessState::AddToAutoRun() {
......
......@@ -180,13 +180,13 @@ bool ServiceProcessState::Initialize() {
CFRelease(err);
return false;
}
state_->launchd_conf_.reset(dict);
state_->launchd_conf.reset(dict);
return true;
}
IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() {
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 =
[ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_SOCKETS];
NSArray* sockets =
......@@ -301,7 +301,7 @@ bool ServiceProcessState::RemoveFromAutoRun() {
bool ServiceProcessState::StateData::WatchExecutable() {
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];
if (!exe_path) {
DLOG(ERROR) << "No " LAUNCH_JOBKEY_PROGRAM;
......@@ -313,15 +313,15 @@ bool ServiceProcessState::StateData::WatchExecutable() {
scoped_ptr<ExecFilePathWatcherCallback> callback(
new ExecFilePathWatcherCallback);
if (!callback->Init(executable_path)) {
DLOG(ERROR) << "executable_watcher_.Init " << executable_path.value();
DLOG(ERROR) << "executable_watcher.Init " << executable_path.value();
return false;
}
if (!executable_watcher_.Watch(
if (!executable_watcher.Watch(
executable_path,
false,
base::Bind(&ExecFilePathWatcherCallback::NotifyPathChanged,
base::Owned(callback.release())))) {
DLOG(ERROR) << "executable_watcher_.watch " << executable_path.value();
DLOG(ERROR) << "executable_watcher.watch " << executable_path.value();
return false;
}
return true;
......
......@@ -77,9 +77,9 @@ static void SigTermHandler(int sig, siginfo_t* info, void* uap) {
}
}
ServiceProcessState::StateData::StateData() : set_action_(false) {
memset(sockets_, -1, sizeof(sockets_));
memset(&old_action_, 0, sizeof(old_action_));
ServiceProcessState::StateData::StateData() : set_action(false) {
memset(sockets, -1, sizeof(sockets));
memset(&old_action, 0, sizeof(old_action));
}
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(!signal->IsSignaled());
*success = base::MessageLoopForIO::current()->WatchFileDescriptor(
sockets_[0],
sockets[0],
true,
base::MessageLoopForIO::WATCH_READ,
&watcher_,
terminate_monitor_.get());
&watcher,
terminate_monitor.get());
if (!*success) {
DLOG(ERROR) << "WatchFileDescriptor";
signal->Signal();
return;
}
g_signal_socket = sockets_[1];
g_signal_socket = sockets[1];
// Set up signal handler for SIGTERM.
struct sigaction action;
......@@ -105,7 +105,7 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal,
action.sa_sigaction = SigTermHandler;
sigemptyset(&action.sa_mask);
action.sa_flags = SA_SIGINFO;
*success = sigaction(SIGTERM, &action, &old_action_) == 0;
*success = sigaction(SIGTERM, &action, &old_action) == 0;
if (!*success) {
DPLOG(ERROR) << "sigaction";
signal->Signal();
......@@ -115,8 +115,8 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal,
// If the old_action is not default, somebody else has installed a
// a competing handler. Our handler is going to override it so it
// won't be called. If this occurs it needs to be fixed.
DCHECK_EQ(old_action_.sa_handler, SIG_DFL);
set_action_ = true;
DCHECK_EQ(old_action.sa_handler, SIG_DFL);
set_action = true;
#if defined(OS_MACOSX)
*success = WatchExecutable();
......@@ -126,24 +126,24 @@ void ServiceProcessState::StateData::SignalReady(base::WaitableEvent* signal,
return;
}
#elif defined(OS_POSIX)
initializing_lock_.reset();
initializing_lock.reset();
#endif // OS_POSIX
signal->Signal();
}
ServiceProcessState::StateData::~StateData() {
if (sockets_[0] != -1) {
if (IGNORE_EINTR(close(sockets_[0]))) {
if (sockets[0] != -1) {
if (IGNORE_EINTR(close(sockets[0]))) {
DPLOG(ERROR) << "close";
}
}
if (sockets_[1] != -1) {
if (IGNORE_EINTR(close(sockets_[1]))) {
if (sockets[1] != -1) {
if (IGNORE_EINTR(close(sockets[1]))) {
DPLOG(ERROR) << "close";
}
}
if (set_action_) {
if (sigaction(SIGTERM, &old_action_, NULL) < 0) {
if (set_action) {
if (sigaction(SIGTERM, &old_action, NULL) < 0) {
DPLOG(ERROR) << "sigaction";
}
}
......@@ -167,14 +167,14 @@ bool ServiceProcessState::SignalReady(
DCHECK(state_);
#if defined(OS_POSIX) && !defined(OS_MACOSX)
state_->running_lock_.reset(TakeServiceRunningLock(true));
if (state_->running_lock_.get() == NULL) {
state_->running_lock.reset(TakeServiceRunningLock(true));
if (state_->running_lock.get() == NULL) {
return false;
}
#endif
state_->terminate_monitor_.reset(
state_->terminate_monitor.reset(
new ServiceProcessTerminateMonitor(terminate_task));
if (pipe(state_->sockets_) < 0) {
if (pipe(state_->sockets) < 0) {
DPLOG(ERROR) << "pipe";
return false;
}
......
......@@ -64,25 +64,21 @@ struct ServiceProcessState::StateData
// to be monitoring it.
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)
bool WatchExecutable();
base::ScopedCFTypeRef<CFDictionaryRef> launchd_conf_;
base::FilePathWatcher executable_watcher_;
base::ScopedCFTypeRef<CFDictionaryRef> launchd_conf;
base::FilePathWatcher executable_watcher;
#endif // OS_MACOSX
#if defined(OS_POSIX) && !defined(OS_MACOSX)
scoped_ptr<MultiProcessLock> initializing_lock_;
scoped_ptr<MultiProcessLock> running_lock_;
scoped_ptr<MultiProcessLock> initializing_lock;
scoped_ptr<MultiProcessLock> running_lock;
#endif
scoped_ptr<ServiceProcessTerminateMonitor> terminate_monitor_;
base::MessageLoopForIO::FileDescriptorWatcher watcher_;
int sockets_[2];
struct sigaction old_action_;
bool set_action_;
scoped_ptr<ServiceProcessTerminateMonitor> terminate_monitor;
base::MessageLoopForIO::FileDescriptorWatcher watcher;
int sockets[2];
struct sigaction old_action;
bool set_action;
protected:
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