Changeset 82651 in webkit
- Timestamp:
- Mar 31, 2011 6:05:40 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r82649 r82651 1 2011-03-31 Adam Roben <aroben@apple.com> 2 3 Add SharedMemory::adopt, which can take ownership of an existing file mapping object 4 5 Fixes <http://webkit.org/b/57599> Need a way to wrap an existing file mapping object in a 6 SharedMemory 7 8 Reviewed by Anders Carlsson. 9 10 * Platform/SharedMemory.h: Added adopt. 11 12 * Platform/win/SharedMemoryWin.cpp: 13 (WebKit::SharedMemory::create): Moved code to adopt the HANDLE from here... 14 (WebKit::SharedMemory::adopt): ...to here. 15 1 16 2011-03-31 Chang Shu <cshu@webkit.org> 2 17 -
trunk/Source/WebKit2/Platform/SharedMemory.h
r78513 r82651 83 83 static PassRefPtr<SharedMemory> create(const Handle&, Protection); 84 84 85 #if PLATFORM(WIN) 86 static PassRefPtr<SharedMemory> adopt(HANDLE, size_t, Protection); 87 #endif 88 85 89 ~SharedMemory(); 86 90 -
trunk/Source/WebKit2/Platform/win/SharedMemoryWin.cpp
r82615 r82651 146 146 PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection protection) 147 147 { 148 if (handle.isNull()) 148 RefPtr<SharedMemory> memory = adopt(handle.m_handle, handle.m_size, protection); 149 if (!memory) 150 return 0; 151 152 // The SharedMemory object now owns the HANDLE. 153 handle.m_handle = 0; 154 155 return memory.release(); 156 } 157 158 PassRefPtr<SharedMemory> SharedMemory::adopt(HANDLE handle, size_t size, Protection protection) 159 { 160 if (!handle) 149 161 return 0; 150 162 151 163 DWORD desiredAccess = accessRights(protection); 152 164 153 void* baseAddress = ::MapViewOfFile(handle .m_handle, desiredAccess, 0, 0, handle.m_size);165 void* baseAddress = ::MapViewOfFile(handle, desiredAccess, 0, 0, size); 154 166 ASSERT_WITH_MESSAGE(baseAddress, "::MapViewOfFile failed with error %lu", ::GetLastError()); 155 167 if (!baseAddress) … … 157 169 158 170 RefPtr<SharedMemory> memory = adoptRef(new SharedMemory); 159 memory->m_size = handle.m_size;171 memory->m_size = size; 160 172 memory->m_data = baseAddress; 161 162 // Adopt the HANDLE. 163 memory->m_handle = handle.m_handle; 164 handle.m_handle = 0; 173 memory->m_handle = handle; 165 174 166 175 return memory.release();
Note: See TracChangeset
for help on using the changeset viewer.