OLD | NEW |
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/mac/mock_launchd.h" | 5 #include "chrome/common/mac/mock_launchd.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
11 #include <sys/un.h> | 11 #include <sys/un.h> |
12 | 12 |
| 13 #include <memory> |
| 14 |
13 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
15 #include "base/mac/foundation_util.h" | 17 #include "base/mac/foundation_util.h" |
16 #include "base/mac/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
17 #include "base/macros.h" | 19 #include "base/macros.h" |
18 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
19 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
20 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
21 #include "base/strings/sys_string_conversions.h" | 23 #include "base/strings/sys_string_conversions.h" |
22 #include "chrome/common/mac/launchd.h" | 24 #include "chrome/common/mac/launchd.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 checkin_called_(false), | 104 checkin_called_(false), |
103 write_called_(false), | 105 write_called_(false), |
104 delete_called_(false) { | 106 delete_called_(false) { |
105 } | 107 } |
106 | 108 |
107 MockLaunchd::~MockLaunchd() { | 109 MockLaunchd::~MockLaunchd() { |
108 } | 110 } |
109 | 111 |
110 CFDictionaryRef MockLaunchd::CopyJobDictionary(CFStringRef label) { | 112 CFDictionaryRef MockLaunchd::CopyJobDictionary(CFStringRef label) { |
111 if (!as_service_) { | 113 if (!as_service_) { |
112 scoped_ptr<MultiProcessLock> running_lock( | 114 std::unique_ptr<MultiProcessLock> running_lock( |
113 TakeNamedLock(pipe_name_, false)); | 115 TakeNamedLock(pipe_name_, false)); |
114 if (running_lock.get()) | 116 if (running_lock.get()) |
115 return NULL; | 117 return NULL; |
116 } | 118 } |
117 | 119 |
118 CFStringRef program = CFSTR(LAUNCH_JOBKEY_PROGRAM); | 120 CFStringRef program = CFSTR(LAUNCH_JOBKEY_PROGRAM); |
119 CFStringRef program_pid = CFSTR(LAUNCH_JOBKEY_PID); | 121 CFStringRef program_pid = CFSTR(LAUNCH_JOBKEY_PID); |
120 const void *keys[] = { program, program_pid }; | 122 const void *keys[] = { program, program_pid }; |
121 base::ScopedCFTypeRef<CFStringRef> path( | 123 base::ScopedCFTypeRef<CFStringRef> path( |
122 base::SysUTF8ToCFStringRef(file_.value())); | 124 base::SysUTF8ToCFStringRef(file_.value())); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 Type type, | 259 Type type, |
258 CFStringRef name) { | 260 CFStringRef name) { |
259 delete_called_ = true; | 261 delete_called_ = true; |
260 return true; | 262 return true; |
261 } | 263 } |
262 | 264 |
263 void MockLaunchd::SignalReady() { | 265 void MockLaunchd::SignalReady() { |
264 ASSERT_TRUE(as_service_); | 266 ASSERT_TRUE(as_service_); |
265 running_lock_.reset(TakeNamedLock(pipe_name_, true)); | 267 running_lock_.reset(TakeNamedLock(pipe_name_, true)); |
266 } | 268 } |
OLD | NEW |