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

Side by Side Diff: content/browser/renderer_host/render_message_filter.cc

Issue 10052006: Merge 131324 - Mac: OOP font loading should run on FILE thread. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/render_message_filter.h ('k') | content/common/mac/font_loader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/renderer_host/render_message_filter.h" 5 #include "content/browser/renderer_host/render_message_filter.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen ter.h" 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPresen ter.h"
57 #include "webkit/glue/webcookie.h" 57 #include "webkit/glue/webcookie.h"
58 #include "webkit/glue/webkit_glue.h" 58 #include "webkit/glue/webkit_glue.h"
59 #include "webkit/plugins/npapi/plugin_group.h" 59 #include "webkit/plugins/npapi/plugin_group.h"
60 #include "webkit/plugins/npapi/webplugin.h" 60 #include "webkit/plugins/npapi/webplugin.h"
61 #include "webkit/plugins/plugin_constants.h" 61 #include "webkit/plugins/plugin_constants.h"
62 #include "webkit/plugins/webplugininfo.h" 62 #include "webkit/plugins/webplugininfo.h"
63 63
64 #if defined(OS_MACOSX) 64 #if defined(OS_MACOSX)
65 #include "content/common/mac/font_descriptor.h" 65 #include "content/common/mac/font_descriptor.h"
66 #include "content/common/mac/font_loader.h"
67 #endif 66 #endif
68 #if defined(OS_POSIX) 67 #if defined(OS_POSIX)
69 #include "base/file_descriptor_posix.h" 68 #include "base/file_descriptor_posix.h"
70 #endif 69 #endif
71 70
72 using content::BrowserContext; 71 using content::BrowserContext;
73 using content::BrowserMessageFilter; 72 using content::BrowserMessageFilter;
74 using content::BrowserThread; 73 using content::BrowserThread;
75 using content::ChildProcessHostImpl; 74 using content::ChildProcessHostImpl;
76 using content::PluginServiceFilter; 75 using content::PluginServiceFilter;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnMsgCreateWindow) 340 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnMsgCreateWindow)
342 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget) 341 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget)
343 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateFullscreenWidget, 342 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateFullscreenWidget,
344 OnMsgCreateFullscreenWidget) 343 OnMsgCreateFullscreenWidget)
345 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie) 344 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie)
346 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies) 345 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies)
347 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies, OnGetRawCookies) 346 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies, OnGetRawCookies)
348 IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie) 347 IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie)
349 IPC_MESSAGE_HANDLER(ViewHostMsg_CookiesEnabled, OnCookiesEnabled) 348 IPC_MESSAGE_HANDLER(ViewHostMsg_CookiesEnabled, OnCookiesEnabled)
350 #if defined(OS_MACOSX) 349 #if defined(OS_MACOSX)
351 IPC_MESSAGE_HANDLER(ViewHostMsg_LoadFont, OnLoadFont) 350 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_LoadFont, OnLoadFont)
352 #endif 351 #endif
353 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins) 352 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetPlugins, OnGetPlugins)
354 IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginInfo, OnGetPluginInfo) 353 IPC_MESSAGE_HANDLER(ViewHostMsg_GetPluginInfo, OnGetPluginInfo)
355 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl) 354 IPC_MESSAGE_HANDLER(ViewHostMsg_DownloadUrl, OnDownloadUrl)
356 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPlugin, 355 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPlugin,
357 OnOpenChannelToPlugin) 356 OnOpenChannelToPlugin)
358 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPepperPlugin, 357 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPepperPlugin,
359 OnOpenChannelToPepperPlugin) 358 OnOpenChannelToPepperPlugin)
360 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToPpapiBroker, 359 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToPpapiBroker,
361 OnOpenChannelToPpapiBroker) 360 OnOpenChannelToPpapiBroker)
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 // TODO(ananta): If this render view is associated with an automation channel, 545 // TODO(ananta): If this render view is associated with an automation channel,
547 // aka ChromeFrame then we need to retrieve cookie settings from the external 546 // aka ChromeFrame then we need to retrieve cookie settings from the external
548 // host. 547 // host.
549 *cookies_enabled = content::GetContentClient()->browser()->AllowGetCookie( 548 *cookies_enabled = content::GetContentClient()->browser()->AllowGetCookie(
550 url, first_party_for_cookies, net::CookieList(), resource_context_, 549 url, first_party_for_cookies, net::CookieList(), resource_context_,
551 render_process_id_, MSG_ROUTING_CONTROL); 550 render_process_id_, MSG_ROUTING_CONTROL);
552 } 551 }
553 552
554 #if defined(OS_MACOSX) 553 #if defined(OS_MACOSX)
555 void RenderMessageFilter::OnLoadFont(const FontDescriptor& font, 554 void RenderMessageFilter::OnLoadFont(const FontDescriptor& font,
556 uint32* handle_size, 555 IPC::Message* reply_msg) {
557 base::SharedMemoryHandle* handle, 556 FontLoader::Result* result = new FontLoader::Result;
558 uint32* font_id) { 557
559 base::SharedMemory font_data; 558 BrowserThread::PostTaskAndReply(
560 uint32 font_data_size = 0; 559 BrowserThread::FILE, FROM_HERE,
561 bool ok = FontLoader::LoadFontIntoBuffer(font.ToNSFont(), &font_data, 560 base::Bind(&FontLoader::LoadFont, font, result),
562 &font_data_size, font_id); 561 base::Bind(&RenderMessageFilter::SendLoadFontReply, this, reply_msg,
563 if (!ok || font_data_size == 0 || *font_id == 0) { 562 base::Owned(result)));
564 LOG(ERROR) << "Couldn't load font data for " << font.font_name << 563 }
565 " ok=" << ok << " font_data_size=" << font_data_size << 564
566 " font id=" << *font_id; 565 void RenderMessageFilter::SendLoadFontReply(IPC::Message* reply,
567 *handle_size = 0; 566 FontLoader::Result* result) {
568 *handle = base::SharedMemory::NULLHandle(); 567 base::SharedMemoryHandle handle;
569 *font_id = 0; 568 if (result->font_data_size == 0 || result->font_id == 0) {
570 return; 569 result->font_data_size = 0;
570 result->font_id = 0;
571 handle = base::SharedMemory::NULLHandle();
572 } else {
573 result->font_data.GiveToProcess(base::GetCurrentProcessHandle(), &handle);
571 } 574 }
572 575 ViewHostMsg_LoadFont::WriteReplyParams(
573 *handle_size = font_data_size; 576 reply, result->font_data_size, handle, result->font_id);
574 font_data.GiveToProcess(base::GetCurrentProcessHandle(), handle); 577 Send(reply);
575 } 578 }
576 #endif // OS_MACOSX 579 #endif // OS_MACOSX
577 580
578 void RenderMessageFilter::OnGetPlugins( 581 void RenderMessageFilter::OnGetPlugins(
579 bool refresh, 582 bool refresh,
580 IPC::Message* reply_msg) { 583 IPC::Message* reply_msg) {
581 // Don't refresh if the specified threshold has not been passed. Note that 584 // Don't refresh if the specified threshold has not been passed. Note that
582 // this check is performed before off-loading to the file thread. The reason 585 // this check is performed before off-loading to the file thread. The reason
583 // we do this is that some pages tend to request that the list of plugins be 586 // we do this is that some pages tend to request that the list of plugins be
584 // refreshed at an excessive rate. This instigates disk scanning, as the list 587 // refreshed at an excessive rate. This instigates disk scanning, as the list
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 // for a resize or if no backing store) the RenderWidgetHost is blocking the 947 // for a resize or if no backing store) the RenderWidgetHost is blocking the
945 // UI thread for some time, waiting for an UpdateRect from the renderer. If we 948 // UI thread for some time, waiting for an UpdateRect from the renderer. If we
946 // are going to switch to accelerated compositing, the GPU process may need 949 // are going to switch to accelerated compositing, the GPU process may need
947 // round-trips to the UI thread before finishing the frame, causing deadlocks 950 // round-trips to the UI thread before finishing the frame, causing deadlocks
948 // if we delay the UpdateRect until we receive the OnSwapBuffersComplete. So 951 // if we delay the UpdateRect until we receive the OnSwapBuffersComplete. So
949 // the renderer sent us this message, so that we can unblock the UI thread. 952 // the renderer sent us this message, so that we can unblock the UI thread.
950 // We will simply re-use the UpdateRect unblock mechanism, just with a 953 // We will simply re-use the UpdateRect unblock mechanism, just with a
951 // different message. 954 // different message.
952 render_widget_helper_->DidReceiveUpdateMsg(msg); 955 render_widget_helper_->DidReceiveUpdateMsg(msg);
953 } 956 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_message_filter.h ('k') | content/common/mac/font_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698