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

Side by Side Diff: chrome/common/mac/mock_launchd.cc

Issue 982883003: Use fixed socket name instead of SecureSocketWithKey (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/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 <sys/socket.h> 8 #include <sys/socket.h>
9 #include <sys/un.h> 9 #include <sys/un.h>
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 while (socket_path.value().length() + pipe_suffix.length() > 110 while (socket_path.value().length() + pipe_suffix.length() >
111 kMaxPipeNameLength - 2) { 111 kMaxPipeNameLength - 2) {
112 socket_path = socket_path.DirName(); 112 socket_path = socket_path.DirName();
113 } 113 }
114 pipe_name_ = socket_path.value() + pipe_suffix; 114 pipe_name_ = socket_path.value() + pipe_suffix;
115 } 115 }
116 116
117 MockLaunchd::~MockLaunchd() { 117 MockLaunchd::~MockLaunchd() {
118 } 118 }
119 119
120 CFDictionaryRef MockLaunchd::CopyExports() {
121 if (!create_socket_) {
122 ADD_FAILURE();
123 return NULL;
124 }
125
126 CFStringRef env_var =
127 base::mac::NSToCFCast(GetServiceProcessLaunchDSocketEnvVar());
128 base::ScopedCFTypeRef<CFStringRef> socket_path(CFStringCreateWithCString(
129 kCFAllocatorDefault, pipe_name_.c_str(), kCFStringEncodingUTF8));
130 const void *keys[] = { env_var };
131 const void *values[] = { socket_path };
132 static_assert(arraysize(keys) == arraysize(values),
133 "keys must have the same number of elements as values");
134 return CFDictionaryCreate(kCFAllocatorDefault,
135 keys,
136 values,
137 arraysize(keys),
138 &kCFTypeDictionaryKeyCallBacks,
139 &kCFTypeDictionaryValueCallBacks);
140 }
141
142 CFDictionaryRef MockLaunchd::CopyJobDictionary(CFStringRef label) { 120 CFDictionaryRef MockLaunchd::CopyJobDictionary(CFStringRef label) {
143 if (!as_service_) { 121 if (!as_service_) {
144 scoped_ptr<MultiProcessLock> running_lock( 122 scoped_ptr<MultiProcessLock> running_lock(
145 TakeNamedLock(pipe_name_, false)); 123 TakeNamedLock(pipe_name_, false));
146 if (running_lock.get()) 124 if (running_lock.get())
147 return NULL; 125 return NULL;
148 } 126 }
149 127
150 CFStringRef program = CFSTR(LAUNCH_JOBKEY_PROGRAM); 128 CFStringRef program = CFSTR(LAUNCH_JOBKEY_PROGRAM);
151 CFStringRef program_pid = CFSTR(LAUNCH_JOBKEY_PID); 129 CFStringRef program_pid = CFSTR(LAUNCH_JOBKEY_PID);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 Type type, 267 Type type,
290 CFStringRef name) { 268 CFStringRef name) {
291 delete_called_ = true; 269 delete_called_ = true;
292 return true; 270 return true;
293 } 271 }
294 272
295 void MockLaunchd::SignalReady() { 273 void MockLaunchd::SignalReady() {
296 ASSERT_TRUE(as_service_); 274 ASSERT_TRUE(as_service_);
297 running_lock_.reset(TakeNamedLock(pipe_name_, true)); 275 running_lock_.reset(TakeNamedLock(pipe_name_, true));
298 } 276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698