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

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

Issue 6731064: kqueue implementation of FilePathWatcher on Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed up mattias's grammar nits, and added test Created 9 years, 8 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) 2011 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 #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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 CFErrorRef err = NULL; 172 CFErrorRef err = NULL;
173 CFDictionaryRef dict = 173 CFDictionaryRef dict =
174 Launchd::GetInstance()->CopyDictionaryByCheckingIn(&err); 174 Launchd::GetInstance()->CopyDictionaryByCheckingIn(&err);
175 175
176 if (!dict) { 176 if (!dict) {
177 LOG(ERROR) << "CopyLaunchdDictionaryByCheckingIn: " << err; 177 LOG(ERROR) << "CopyLaunchdDictionaryByCheckingIn: " << err;
178 CFRelease(err); 178 CFRelease(err);
179 return false; 179 return false;
180 } 180 }
181 state_->launchd_conf_.reset(dict); 181 state_->launchd_conf_.reset(dict);
182 state_->ui_message_loop_= base::MessageLoopProxy::CreateForCurrentThread();
183 return true; 182 return true;
184 } 183 }
185 184
186 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() { 185 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() {
187 CHECK(state_); 186 CHECK(state_);
188 NSDictionary *ns_launchd_conf = base::mac::CFToNSCast(state_->launchd_conf_); 187 NSDictionary *ns_launchd_conf = base::mac::CFToNSCast(state_->launchd_conf_);
189 NSDictionary* socket_dict = 188 NSDictionary* socket_dict =
190 [ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_SOCKETS]; 189 [ns_launchd_conf objectForKey:@ LAUNCH_JOBKEY_SOCKETS];
191 NSArray* sockets = 190 NSArray* sockets =
192 [socket_dict objectForKey:GetServiceProcessLaunchDSocketKey()]; 191 [socket_dict objectForKey:GetServiceProcessLaunchDSocketKey()];
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 return false; 315 return false;
317 } 316 }
318 317
319 FilePath executable_path = FilePath([exe_path fileSystemRepresentation]); 318 FilePath executable_path = FilePath([exe_path fileSystemRepresentation]);
320 scoped_ptr<ExecFilePathWatcherDelegate> delegate( 319 scoped_ptr<ExecFilePathWatcherDelegate> delegate(
321 new ExecFilePathWatcherDelegate); 320 new ExecFilePathWatcherDelegate);
322 if (!delegate->Init(executable_path)) { 321 if (!delegate->Init(executable_path)) {
323 LOG(ERROR) << "executable_watcher_.Init " << executable_path.value(); 322 LOG(ERROR) << "executable_watcher_.Init " << executable_path.value();
324 return false; 323 return false;
325 } 324 }
326 if (!executable_watcher_.Watch(executable_path, 325 if (!executable_watcher_.Watch(executable_path, delegate.release())) {
327 delegate.release(),
328 ui_message_loop_)) {
329 LOG(ERROR) << "executable_watcher_.watch " << executable_path.value(); 326 LOG(ERROR) << "executable_watcher_.watch " << executable_path.value();
330 return false; 327 return false;
331 } 328 }
332 return true; 329 return true;
333 } 330 }
334 331
335 bool ExecFilePathWatcherDelegate::Init(const FilePath& path) { 332 bool ExecFilePathWatcherDelegate::Init(const FilePath& path) {
336 return base::mac::FSRefFromPath(path.value(), &executable_fsref_); 333 return base::mac::FSRefFromPath(path.value(), &executable_fsref_);
337 } 334 }
338 335
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 CFErrorRef err = NULL; 433 CFErrorRef err = NULL;
437 if (!Launchd::GetInstance()->RemoveJob(label, &err)) { 434 if (!Launchd::GetInstance()->RemoveJob(label, &err)) {
438 base::mac::ScopedCFTypeRef<CFErrorRef> scoped_err(err); 435 base::mac::ScopedCFTypeRef<CFErrorRef> scoped_err(err);
439 LOG(ERROR) << "RemoveJob " << err; 436 LOG(ERROR) << "RemoveJob " << err;
440 // Exiting with zero, so launchd doesn't restart the process. 437 // Exiting with zero, so launchd doesn't restart the process.
441 exit(0); 438 exit(0);
442 } 439 }
443 } 440 }
444 } 441 }
445 } 442 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698