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

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

Issue 1167163002: chrome: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added some missing message_loop.h includes. Created 5 years, 6 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
« no previous file with comments | « chrome/common/service_process_util.h ('k') | chrome/common/service_process_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/location.h"
10 #include "base/posix/eintr_wrapper.h" 10 #include "base/posix/eintr_wrapper.h"
11 #include "base/single_thread_task_runner.h"
11 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
12 #include "chrome/common/multi_process_lock.h" 13 #include "chrome/common/multi_process_lock.h"
13 14
14 namespace { 15 namespace {
15 int g_signal_socket = -1; 16 int g_signal_socket = -1;
16 } 17 }
17 18
18 // Attempts to take a lock named |name|. If |waiting| is true then this will 19 // Attempts to take a lock named |name|. If |waiting| is true then this will
19 // make multiple attempts to acquire the lock. 20 // make multiple attempts to acquire the lock.
20 // Caller is responsible for ownership of the MultiProcessLock. 21 // Caller is responsible for ownership of the MultiProcessLock.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 DCHECK(!state_); 155 DCHECK(!state_);
155 state_ = new StateData; 156 state_ = new StateData;
156 157
157 // Explicitly adding a reference here (and removing it in TearDownState) 158 // Explicitly adding a reference here (and removing it in TearDownState)
158 // because StateData is refcounted on Mac and Linux so that methods can 159 // because StateData is refcounted on Mac and Linux so that methods can
159 // be called on other threads. 160 // be called on other threads.
160 // It is not refcounted on Windows at this time. 161 // It is not refcounted on Windows at this time.
161 state_->AddRef(); 162 state_->AddRef();
162 } 163 }
163 164
164 bool ServiceProcessState::SignalReady( 165 bool ServiceProcessState::SignalReady(base::SingleThreadTaskRunner* task_runner,
165 base::MessageLoopProxy* message_loop_proxy, 166 const base::Closure& terminate_task) {
166 const base::Closure& terminate_task) {
167 DCHECK(state_); 167 DCHECK(state_);
168 168
169 #if defined(OS_POSIX) && !defined(OS_MACOSX) 169 #if defined(OS_POSIX) && !defined(OS_MACOSX)
170 state_->running_lock.reset(TakeServiceRunningLock(true)); 170 state_->running_lock.reset(TakeServiceRunningLock(true));
171 if (state_->running_lock.get() == NULL) { 171 if (state_->running_lock.get() == NULL) {
172 return false; 172 return false;
173 } 173 }
174 #endif 174 #endif
175 state_->terminate_monitor.reset( 175 state_->terminate_monitor.reset(
176 new ServiceProcessTerminateMonitor(terminate_task)); 176 new ServiceProcessTerminateMonitor(terminate_task));
177 if (pipe(state_->sockets) < 0) { 177 if (pipe(state_->sockets) < 0) {
178 DPLOG(ERROR) << "pipe"; 178 DPLOG(ERROR) << "pipe";
179 return false; 179 return false;
180 } 180 }
181 base::WaitableEvent signal_ready(true, false); 181 base::WaitableEvent signal_ready(true, false);
182 bool success = false; 182 bool success = false;
183 183
184 message_loop_proxy->PostTask(FROM_HERE, 184 task_runner->PostTask(FROM_HERE,
185 base::Bind(&ServiceProcessState::StateData::SignalReady, 185 base::Bind(&ServiceProcessState::StateData::SignalReady,
186 state_, 186 state_, &signal_ready, &success));
187 &signal_ready,
188 &success));
189 signal_ready.Wait(); 187 signal_ready.Wait();
190 return success; 188 return success;
191 } 189 }
192 190
193 void ServiceProcessState::TearDownState() { 191 void ServiceProcessState::TearDownState() {
194 if (state_) { 192 if (state_) {
195 state_->Release(); 193 state_->Release();
196 state_ = NULL; 194 state_ = NULL;
197 } 195 }
198 } 196 }
OLDNEW
« no previous file with comments | « chrome/common/service_process_util.h ('k') | chrome/common/service_process_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698