OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <objidl.h> | 9 #include <objidl.h> |
10 #include <mlang.h> | 10 #include <mlang.h> |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 ChildProcess::GlobalCleanup(); | 114 ChildProcess::GlobalCleanup(); |
115 } | 115 } |
116 | 116 |
117 // static | 117 // static |
118 bool RenderProcess::ShouldLoadPluginsInProcess() { | 118 bool RenderProcess::ShouldLoadPluginsInProcess() { |
119 return load_plugins_in_process_; | 119 return load_plugins_in_process_; |
120 } | 120 } |
121 | 121 |
122 // static | 122 // static |
123 base::SharedMemory* RenderProcess::AllocSharedMemory(size_t size) { | 123 base::SharedMemory* RenderProcess::AllocSharedMemory(size_t size) { |
124 #if defined(OS_LINUX) | |
125 // Linux has trouble with ""; the Create() call below will fail when | |
126 // triggered by RenderProcessTest.TestSharedMemoryAllocOne(), every | |
127 // time. | |
128 std::wstring root_name(L"root"); | |
129 #else | |
130 std::wstring root_name(L""); | |
131 #endif | |
132 | |
133 self()->clearer_factory_.RevokeAll(); | 124 self()->clearer_factory_.RevokeAll(); |
134 | 125 |
135 base::SharedMemory* mem = self()->GetSharedMemFromCache(size); | 126 base::SharedMemory* mem = self()->GetSharedMemFromCache(size); |
136 if (mem) | 127 if (mem) |
137 return mem; | 128 return mem; |
138 | 129 |
139 // Round-up size to allocation granularity | 130 // Round-up size to allocation granularity |
140 size_t allocation_granularity = base::SysInfo::VMAllocationGranularity(); | 131 size_t allocation_granularity = base::SysInfo::VMAllocationGranularity(); |
141 size = size / allocation_granularity + 1; | 132 size = size / allocation_granularity + 1; |
142 size = size * allocation_granularity; | 133 size = size * allocation_granularity; |
143 | 134 |
144 mem = new base::SharedMemory(); | 135 mem = new base::SharedMemory(); |
145 if (!mem) | 136 if (!mem) |
146 return NULL; | 137 return NULL; |
147 if (!mem->Create(root_name, false, true, size)) { | 138 if (!mem->Create(L"", false, true, size)) { |
148 delete mem; | 139 delete mem; |
149 return NULL; | 140 return NULL; |
150 } | 141 } |
151 | 142 |
152 return mem; | 143 return mem; |
153 } | 144 } |
154 | 145 |
155 // static | 146 // static |
156 void RenderProcess::FreeSharedMemory(base::SharedMemory* mem) { | 147 void RenderProcess::FreeSharedMemory(base::SharedMemory* mem) { |
157 if (self()->PutSharedMemInCache(mem)) { | 148 if (self()->PutSharedMemInCache(mem)) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } | 211 } |
221 | 212 |
222 void RenderProcess::Cleanup() { | 213 void RenderProcess::Cleanup() { |
223 // TODO(port) | 214 // TODO(port) |
224 // Try and limit what we pull in for our non-Win unit test bundle | 215 // Try and limit what we pull in for our non-Win unit test bundle |
225 #ifndef NDEBUG | 216 #ifndef NDEBUG |
226 // log important leaked objects | 217 // log important leaked objects |
227 webkit_glue::CheckForLeaks(); | 218 webkit_glue::CheckForLeaks(); |
228 #endif | 219 #endif |
229 } | 220 } |
OLD | NEW |