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

Side by Side Diff: chrome/common/service_process_util_posix.cc

Issue 6660001: Getting service process on Mac to handle having things moved/changed underneath it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix up bad instance reset Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 9
10 namespace { 10 namespace {
11 int g_signal_socket = -1; 11 int g_signal_socket = -1;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 state_ = new StateData; 89 state_ = new StateData;
90 state_->AddRef(); 90 state_->AddRef();
91 return true; 91 return true;
92 } 92 }
93 93
94 bool ServiceProcessState::SignalReady( 94 bool ServiceProcessState::SignalReady(
95 base::MessageLoopProxy* message_loop_proxy, Task* shutdown_task) { 95 base::MessageLoopProxy* message_loop_proxy, Task* shutdown_task) {
96 CHECK(state_); 96 CHECK(state_);
97 CHECK_EQ(g_signal_socket, -1); 97 CHECK_EQ(g_signal_socket, -1);
98 98
99 scoped_ptr<Task> scoped_shutdown_task(shutdown_task);
99 #if defined(OS_LINUX) 100 #if defined(OS_LINUX)
100 state_->running_lock_.reset(TakeServiceRunningLock(true)); 101 state_->running_lock_.reset(TakeServiceRunningLock(true));
101 if (state_->running_lock_.get() == NULL) { 102 if (state_->running_lock_.get() == NULL) {
102 return false; 103 return false;
103 } 104 }
104 #endif // OS_LINUX 105 #endif // OS_LINUX
105 state_->shut_down_monitor_.reset( 106 state_->shut_down_monitor_.reset(
106 new ServiceProcessShutdownMonitor(shutdown_task)); 107 new ServiceProcessShutdownMonitor(scoped_shutdown_task.release()));
107 if (pipe(state_->sockets_) < 0) { 108 if (pipe(state_->sockets_) < 0) {
108 PLOG(ERROR) << "pipe"; 109 PLOG(ERROR) << "pipe";
109 return false; 110 return false;
110 } 111 }
112 #if defined(OS_MACOSX)
113 state_->state_ = this;
114 message_loop_proxy->PostTask(FROM_HERE,
115 NewRunnableMethod(state_,
116 &ServiceProcessState::StateData::WatchExecutable));
117 #endif // OS_MACOSX
111 message_loop_proxy->PostTask(FROM_HERE, 118 message_loop_proxy->PostTask(FROM_HERE,
112 NewRunnableMethod(state_, &ServiceProcessState::StateData::SignalReady)); 119 NewRunnableMethod(state_, &ServiceProcessState::StateData::SignalReady));
113 return true; 120 return true;
114 } 121 }
115 122
116 void ServiceProcessState::TearDownState() { 123 void ServiceProcessState::TearDownState() {
117 g_signal_socket = -1; 124 g_signal_socket = -1;
118 if (state_) { 125 if (state_) {
119 if (state_->sockets_[0] != -1) { 126 if (state_->sockets_[0] != -1) {
120 close(state_->sockets_[0]); 127 close(state_->sockets_[0]);
121 } 128 }
122 if (state_->sockets_[1] != -1) { 129 if (state_->sockets_[1] != -1) {
123 close(state_->sockets_[1]); 130 close(state_->sockets_[1]);
124 } 131 }
125 if (state_->set_action_) { 132 if (state_->set_action_) {
126 if (sigaction(SIGTERM, &state_->old_action_, NULL) < 0) { 133 if (sigaction(SIGTERM, &state_->old_action_, NULL) < 0) {
127 PLOG(ERROR) << "sigaction"; 134 PLOG(ERROR) << "sigaction";
128 } 135 }
129 } 136 }
130 state_->Release(); 137 state_->Release();
131 state_ = NULL; 138 state_ = NULL;
132 } 139 }
133 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698