Chromium Code Reviews| 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 "content/browser/renderer_host/render_message_filter.h" | 5 #include "content/browser/renderer_host/render_message_filter.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 IPC_MESSAGE_HANDLER_DELAY_REPLY(RenderProcessHostMsg_Keygen, OnKeygen) | 210 IPC_MESSAGE_HANDLER_DELAY_REPLY(RenderProcessHostMsg_Keygen, OnKeygen) |
| 211 IPC_MESSAGE_HANDLER(RenderProcessHostMsg_DidGenerateCacheableMetadata, | 211 IPC_MESSAGE_HANDLER(RenderProcessHostMsg_DidGenerateCacheableMetadata, |
| 212 OnCacheableMetadataAvailable) | 212 OnCacheableMetadataAvailable) |
| 213 IPC_MESSAGE_HANDLER( | 213 IPC_MESSAGE_HANDLER( |
| 214 RenderProcessHostMsg_DidGenerateCacheableMetadataInCacheStorage, | 214 RenderProcessHostMsg_DidGenerateCacheableMetadataInCacheStorage, |
| 215 OnCacheableMetadataAvailableForCacheStorage) | 215 OnCacheableMetadataAvailableForCacheStorage) |
| 216 IPC_MESSAGE_HANDLER(ViewHostMsg_GetAudioHardwareConfig, | 216 IPC_MESSAGE_HANDLER(ViewHostMsg_GetAudioHardwareConfig, |
| 217 OnGetAudioHardwareConfig) | 217 OnGetAudioHardwareConfig) |
| 218 #if defined(OS_MACOSX) | 218 #if defined(OS_MACOSX) |
| 219 IPC_MESSAGE_HANDLER_DELAY_REPLY(RenderProcessHostMsg_LoadFont, OnLoadFont) | 219 IPC_MESSAGE_HANDLER_DELAY_REPLY(RenderProcessHostMsg_LoadFont, OnLoadFont) |
| 220 #elif defined(OS_WIN) | |
| 221 IPC_MESSAGE_HANDLER(RenderProcessHostMsg_PreCacheFontCharacters, | |
| 222 OnPreCacheFontCharacters) | |
| 223 #endif | 220 #endif |
| 224 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaLogEvents, OnMediaLogEvents) | 221 IPC_MESSAGE_HANDLER(ViewHostMsg_MediaLogEvents, OnMediaLogEvents) |
| 225 IPC_MESSAGE_UNHANDLED(handled = false) | 222 IPC_MESSAGE_UNHANDLED(handled = false) |
| 226 IPC_END_MESSAGE_MAP() | 223 IPC_END_MESSAGE_MAP() |
| 227 | 224 |
| 228 return handled; | 225 return handled; |
| 229 } | 226 } |
| 230 | 227 |
| 231 void RenderMessageFilter::OnDestruct() const { | 228 void RenderMessageFilter::OnDestruct() const { |
| 232 const_cast<RenderMessageFilter*>(this)->resource_context_ = nullptr; | 229 const_cast<RenderMessageFilter*>(this)->resource_context_ = nullptr; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 result->font_id = 0; | 335 result->font_id = 0; |
| 339 handle = base::SharedMemory::NULLHandle(); | 336 handle = base::SharedMemory::NULLHandle(); |
| 340 } else { | 337 } else { |
| 341 result->font_data.GiveToProcess(base::GetCurrentProcessHandle(), &handle); | 338 result->font_data.GiveToProcess(base::GetCurrentProcessHandle(), &handle); |
| 342 } | 339 } |
| 343 RenderProcessHostMsg_LoadFont::WriteReplyParams( | 340 RenderProcessHostMsg_LoadFont::WriteReplyParams( |
| 344 reply, result->font_data_size, handle, result->font_id); | 341 reply, result->font_data_size, handle, result->font_id); |
| 345 Send(reply); | 342 Send(reply); |
| 346 } | 343 } |
| 347 | 344 |
| 348 #elif defined(OS_WIN) | 345 #endif // defined(OS_MACOSX) |
| 349 | |
| 350 void RenderMessageFilter::OnPreCacheFontCharacters( | |
| 351 const LOGFONT& font, | |
| 352 const base::string16& str) { | |
| 353 // TODO(scottmg): pdf/ppapi still require the renderer to be able to precache | |
| 354 // GDI fonts (http://crbug.com/383227), even when using DirectWrite. | |
| 355 // Eventually this shouldn't be added and should be moved to | |
| 356 // FontCacheDispatcher too. http://crbug.com/356346. | |
|
Charlie Reis
2016/06/30 18:38:41
Can http://crbug.com/356346 be marked fixed after
Lei Zhang
2016/06/30 22:29:34
scottmg: ^
scottmg
2016/06/30 22:31:53
Who filed that useless bug? Yeah, I'd say so.
| |
| 357 | |
| 358 // First, comments from FontCacheDispatcher::OnPreCacheFont do apply here too. | |
| 359 // Except that for True Type fonts, | |
| 360 // GetTextMetrics will not load the font in memory. | |
| 361 // The only way windows seem to load properly, it is to create a similar | |
| 362 // device (like the one in which we print), then do an ExtTextOut, | |
| 363 // as we do in the printing thread, which is sandboxed. | |
| 364 HDC hdc = CreateEnhMetaFile(NULL, NULL, NULL, NULL); | |
| 365 HFONT font_handle = CreateFontIndirect(&font); | |
| 366 DCHECK(NULL != font_handle); | |
| 367 | |
| 368 HGDIOBJ old_font = SelectObject(hdc, font_handle); | |
| 369 DCHECK(NULL != old_font); | |
| 370 | |
| 371 ExtTextOut(hdc, 0, 0, ETO_GLYPH_INDEX, 0, str.c_str(), str.length(), NULL); | |
| 372 | |
| 373 SelectObject(hdc, old_font); | |
| 374 DeleteObject(font_handle); | |
| 375 | |
| 376 HENHMETAFILE metafile = CloseEnhMetaFile(hdc); | |
| 377 | |
| 378 if (metafile) | |
| 379 DeleteEnhMetaFile(metafile); | |
| 380 } | |
| 381 | |
| 382 | |
| 383 #endif // OS_* | |
| 384 | 346 |
| 385 void RenderMessageFilter::AllocateSharedMemoryOnFileThread( | 347 void RenderMessageFilter::AllocateSharedMemoryOnFileThread( |
| 386 uint32_t buffer_size, | 348 uint32_t buffer_size, |
| 387 IPC::Message* reply_msg) { | 349 IPC::Message* reply_msg) { |
| 388 base::SharedMemoryHandle handle; | 350 base::SharedMemoryHandle handle; |
| 389 ChildProcessHostImpl::AllocateSharedMemory(buffer_size, PeerHandle(), | 351 ChildProcessHostImpl::AllocateSharedMemory(buffer_size, PeerHandle(), |
| 390 &handle); | 352 &handle); |
| 391 ChildProcessHostMsg_SyncAllocateSharedMemory::WriteReplyParams(reply_msg, | 353 ChildProcessHostMsg_SyncAllocateSharedMemory::WriteReplyParams(reply_msg, |
| 392 handle); | 354 handle); |
| 393 Send(reply_msg); | 355 Send(reply_msg); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 714 void RenderMessageFilter::OnDeletedGpuMemoryBuffer( | 676 void RenderMessageFilter::OnDeletedGpuMemoryBuffer( |
| 715 gfx::GpuMemoryBufferId id, | 677 gfx::GpuMemoryBufferId id, |
| 716 const gpu::SyncToken& sync_token) { | 678 const gpu::SyncToken& sync_token) { |
| 717 DCHECK(BrowserGpuMemoryBufferManager::current()); | 679 DCHECK(BrowserGpuMemoryBufferManager::current()); |
| 718 | 680 |
| 719 BrowserGpuMemoryBufferManager::current()->ChildProcessDeletedGpuMemoryBuffer( | 681 BrowserGpuMemoryBufferManager::current()->ChildProcessDeletedGpuMemoryBuffer( |
| 720 id, PeerHandle(), render_process_id_, sync_token); | 682 id, PeerHandle(), render_process_id_, sync_token); |
| 721 } | 683 } |
| 722 | 684 |
| 723 } // namespace content | 685 } // namespace content |
| OLD | NEW |