Changeset 79746 in webkit
- Timestamp:
- Feb 25, 2011 4:47:31 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r79743 r79746 1 2011-02-25 Darin Adler <darin@apple.com> 2 3 Reviewed by Anders Carlsson. 4 5 <rdar://problem/8036034> WebKit2 should work even if DYLD_FRAMEWORK_PATH is not set 6 7 * UIProcess/Launcher/mac/ProcessLauncherMac.mm: 8 (WebKit::EnvironmentVariables::~EnvironmentVariables): Use fastFree, not delete, on 9 the strings here because they are allocated with fastMalloc, not new. 10 (WebKit::EnvironmentVariables::set): Use const more. 11 (WebKit::EnvironmentVariables::get): Ditto. 12 (WebKit::EnvironmentVariables::appendValue): Ditto. 13 (WebKit::EnvironmentVariables::valueIfVariableHasName): Ditto. Also fix mistake 14 where this would match if the name matched only a prefix of the environment variable's 15 name. We want to match the whole name, so we need to use memcmp, not strncmp. 16 (WebKit::EnvironmentVariables::createStringForVariable): Use const more. 17 (WebKit::ProcessLauncher::launchProcess): Use clearer name, frameworkExecutablePath, 18 for what was called bundlePath before. Append the frameworks path to DYLD_FRAMEWORK_PATH, 19 ensuring we can pick up other frameworks from the same directory in the web process. 20 Use a const_cast instead of a C-style cast. 21 1 22 2011-02-25 Chris Fleizach <cfleizach@apple.com> 2 23 -
trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
r78441 r79746 78 78 ~EnvironmentVariables() 79 79 { 80 deleteAllValues(m_allocatedStrings); 80 size_t size = m_allocatedStrings.size(); 81 for (size_t i = 0; i < size; ++i) 82 fastFree(m_allocatedStrings[i]); 81 83 } 82 84 … … 88 90 89 91 // Allocate a string for the name and value. 90 c har* nameAndValue = createStringForVariable(name, value);92 const char* nameAndValue = createStringForVariable(name, value); 91 93 92 94 for (size_t i = 0; i < m_environmentVariables.size() - 1; ++i) { 93 char* environmentVariable = m_environmentVariables[i]; 94 95 if (valueIfVariableHasName(environmentVariable, name)) { 95 if (valueIfVariableHasName(m_environmentVariables[i], name)) { 96 96 // Just replace the environment variable. 97 m_environmentVariables[i] = nameAndValue;97 m_environmentVariables[i] = const_cast<char*>(nameAndValue); 98 98 return; 99 99 } … … 102 102 // Append the new string. 103 103 ASSERT(!m_environmentVariables.last()); 104 m_environmentVariables.last() = nameAndValue;104 m_environmentVariables.last() = const_cast<char*>(nameAndValue); 105 105 m_environmentVariables.append(static_cast<char*>(0)); 106 106 … … 108 108 } 109 109 110 c har* get(const char* name) const110 const char* get(const char* name) const 111 111 { 112 112 for (size_t i = 0; m_environmentPointer[i]; ++i) { 113 if (c har* value = valueIfVariableHasName(m_environmentPointer[i], name))113 if (const char* value = valueIfVariableHasName(m_environmentPointer[i], name)) 114 114 return value; 115 115 } … … 120 120 void appendValue(const char* name, const char* value, char separator) 121 121 { 122 c har* existingValue = get(name);122 const char* existingValue = get(name); 123 123 if (!existingValue) { 124 124 set(name, value); … … 137 137 138 138 private: 139 c har *valueIfVariableHasName(const char* environmentVariable, const char* name) const139 const char* valueIfVariableHasName(const char* environmentVariable, const char* name) const 140 140 { 141 141 // Find the environment variable name. 142 c har* equalsLocation = strchr(environmentVariable, '=');142 const char* equalsLocation = strchr(environmentVariable, '='); 143 143 ASSERT(equalsLocation); 144 144 145 145 size_t nameLength = equalsLocation - environmentVariable; 146 if (str ncmp(environmentVariable, name, nameLength))146 if (strlen(name) != nameLength) 147 147 return 0; 148 if (memcmp(environmentVariable, name, nameLength)) 149 return 0; 148 150 149 151 return equalsLocation + 1; 150 152 } 151 153 152 c har* createStringForVariable(const char* name, const char* value)154 const char* createStringForVariable(const char* name, const char* value) 153 155 { 154 156 int nameLength = strlen(name); … … 193 195 194 196 NSBundle *webKit2Bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebKit2"]; 195 const char* bundlePath = [[webKit2Bundle executablePath] fileSystemRepresentation]; 197 const char* frameworksPath = [[[webKit2Bundle bundlePath] stringByDeletingLastPathComponent] fileSystemRepresentation]; 198 const char* frameworkExecutablePath = [[webKit2Bundle executablePath] fileSystemRepresentation]; 196 199 197 200 NSString *webProcessAppPath = [webKit2Bundle pathForAuxiliaryExecutable:@"WebProcess.app"]; … … 201 204 CString serviceName = String::format("com.apple.WebKit.WebProcess-%d-%p", getpid(), this).utf8(); 202 205 203 const char* path = [webProcessAppExecutablePath fileSystemRepresentation]; 204 const char* args[] = { path, bundlePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), 0 }; 206 const char* args[] = { [webProcessAppExecutablePath fileSystemRepresentation], frameworkExecutablePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), 0 }; 205 207 206 208 // Register ourselves. … … 244 246 EnvironmentVariables environmentVariables; 245 247 248 environmentVariables.appendValue("DYLD_FRAMEWORK_PATH", frameworksPath, ':'); 249 246 250 if (m_launchOptions.processType == ProcessLauncher::PluginProcess) { 247 251 // We need to insert the plug-in process shim. 248 252 NSString *pluginProcessShimPathNSString = [[webProcessAppExecutablePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"PluginProcessShim.dylib"]; 249 const char *pluginProcessShimPath = [pluginProcessShimPathNSString fileSystemRepresentation];253 const char* pluginProcessShimPath = [pluginProcessShimPathNSString fileSystemRepresentation]; 250 254 251 255 // Make sure that the file exists. … … 255 259 } 256 260 257 int result = posix_spawn(&processIdentifier, path, 0, &attr, (char *const*)args, environmentVariables.environmentPointer());261 int result = posix_spawn(&processIdentifier, args[0], 0, &attr, const_cast<char**>(args), environmentVariables.environmentPointer()); 258 262 259 263 posix_spawnattr_destroy(&attr);
Note: See TracChangeset
for help on using the changeset viewer.