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

Side by Side Diff: chrome/common/service_process_util_mac.mm

Issue 968813002: Standardize struct public member variables in ServiceProcessState::StateData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 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
« no previous file with comments | « chrome/common/service_process_util_linux.cc ('k') | chrome/common/service_process_util_posix.h » ('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 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <launch.h> 8 #include <launch.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 bool ServiceProcessState::Initialize() { 173 bool ServiceProcessState::Initialize() {
174 CFErrorRef err = NULL; 174 CFErrorRef err = NULL;
175 CFDictionaryRef dict = 175 CFDictionaryRef dict =
176 Launchd::GetInstance()->CopyDictionaryByCheckingIn(&err); 176 Launchd::GetInstance()->CopyDictionaryByCheckingIn(&err);
177 if (!dict) { 177 if (!dict) {
178 DLOG(ERROR) << "ServiceProcess must be launched by launchd. " 178 DLOG(ERROR) << "ServiceProcess must be launched by launchd. "
179 << "CopyLaunchdDictionaryByCheckingIn: " << err; 179 << "CopyLaunchdDictionaryByCheckingIn: " << err;
180 CFRelease(err); 180 CFRelease(err);
181 return false; 181 return false;
182 } 182 }
183 state_->launchd_conf_.reset(dict); 183 state_->launchd_conf.reset(dict);
184 return true; 184 return true;
185 } 185 }
186 186
187 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() { 187 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() {
188 DCHECK(state_); 188 DCHECK(state_);
189 NSDictionary *ns_launchd_conf = base::mac::CFToNSCast(state_->launchd_conf_); 189 NSDictionary *ns_launchd_conf = base::mac::CFToNSCast(state_->launchd_conf);
190 NSDictionary* socket_dict = 190 NSDictionary* socket_dict =
191 [ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_SOCKETS]; 191 [ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_SOCKETS];
192 NSArray* sockets = 192 NSArray* sockets =
193 [socket_dict objectForKey:GetServiceProcessLaunchDSocketKey()]; 193 [socket_dict objectForKey:GetServiceProcessLaunchDSocketKey()];
194 DCHECK_EQ([sockets count], 1U); 194 DCHECK_EQ([sockets count], 1U);
195 int socket = [[sockets objectAtIndex:0] intValue]; 195 int socket = [[sockets objectAtIndex:0] intValue];
196 base::FileDescriptor fd(socket, false); 196 base::FileDescriptor fd(socket, false);
197 return IPC::ChannelHandle(std::string(), fd); 197 return IPC::ChannelHandle(std::string(), fd);
198 } 198 }
199 199
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 name, 294 name,
295 plist); 295 plist);
296 } 296 }
297 297
298 bool ServiceProcessState::RemoveFromAutoRun() { 298 bool ServiceProcessState::RemoveFromAutoRun() {
299 return RemoveFromLaunchd(); 299 return RemoveFromLaunchd();
300 } 300 }
301 301
302 bool ServiceProcessState::StateData::WatchExecutable() { 302 bool ServiceProcessState::StateData::WatchExecutable() {
303 base::mac::ScopedNSAutoreleasePool pool; 303 base::mac::ScopedNSAutoreleasePool pool;
304 NSDictionary* ns_launchd_conf = base::mac::CFToNSCast(launchd_conf_); 304 NSDictionary* ns_launchd_conf = base::mac::CFToNSCast(launchd_conf);
305 NSString* exe_path = [ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_PROGRAM]; 305 NSString* exe_path = [ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_PROGRAM];
306 if (!exe_path) { 306 if (!exe_path) {
307 DLOG(ERROR) << "No " LAUNCH_JOBKEY_PROGRAM; 307 DLOG(ERROR) << "No " LAUNCH_JOBKEY_PROGRAM;
308 return false; 308 return false;
309 } 309 }
310 310
311 base::FilePath executable_path = 311 base::FilePath executable_path =
312 base::FilePath([exe_path fileSystemRepresentation]); 312 base::FilePath([exe_path fileSystemRepresentation]);
313 scoped_ptr<ExecFilePathWatcherCallback> callback( 313 scoped_ptr<ExecFilePathWatcherCallback> callback(
314 new ExecFilePathWatcherCallback); 314 new ExecFilePathWatcherCallback);
315 if (!callback->Init(executable_path)) { 315 if (!callback->Init(executable_path)) {
316 DLOG(ERROR) << "executable_watcher_.Init " << executable_path.value(); 316 DLOG(ERROR) << "executable_watcher.Init " << executable_path.value();
317 return false; 317 return false;
318 } 318 }
319 if (!executable_watcher_.Watch( 319 if (!executable_watcher.Watch(
320 executable_path, 320 executable_path,
321 false, 321 false,
322 base::Bind(&ExecFilePathWatcherCallback::NotifyPathChanged, 322 base::Bind(&ExecFilePathWatcherCallback::NotifyPathChanged,
323 base::Owned(callback.release())))) { 323 base::Owned(callback.release())))) {
324 DLOG(ERROR) << "executable_watcher_.watch " << executable_path.value(); 324 DLOG(ERROR) << "executable_watcher.watch " << executable_path.value();
325 return false; 325 return false;
326 } 326 }
327 return true; 327 return true;
328 } 328 }
329 329
330 bool ExecFilePathWatcherCallback::Init(const base::FilePath& path) { 330 bool ExecFilePathWatcherCallback::Init(const base::FilePath& path) {
331 return base::mac::FSRefFromPath(path.value(), &executable_fsref_); 331 return base::mac::FSRefFromPath(path.value(), &executable_fsref_);
332 } 332 }
333 333
334 void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path, 334 void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 CFErrorRef err = NULL; 434 CFErrorRef err = NULL;
435 if (!Launchd::GetInstance()->RemoveJob(label, &err)) { 435 if (!Launchd::GetInstance()->RemoveJob(label, &err)) {
436 base::ScopedCFTypeRef<CFErrorRef> scoped_err(err); 436 base::ScopedCFTypeRef<CFErrorRef> scoped_err(err);
437 DLOG(ERROR) << "RemoveJob " << err; 437 DLOG(ERROR) << "RemoveJob " << err;
438 // Exiting with zero, so launchd doesn't restart the process. 438 // Exiting with zero, so launchd doesn't restart the process.
439 exit(0); 439 exit(0);
440 } 440 }
441 } 441 }
442 } 442 }
443 } 443 }
OLDNEW
« no previous file with comments | « chrome/common/service_process_util_linux.cc ('k') | chrome/common/service_process_util_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698