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

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1122163002: Ensure that the DirectWrite font cache works in Chrome canary on Windows 8+ with AppContainer prote… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 69d34d542ad96490de6720db63ee075e3b229c24..aa641535602a062bf6427dab39500cb8e8823afe 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -175,11 +175,14 @@
#endif
#if defined(OS_WIN)
+#include "base/memory/shared_memory.h"
#include "base/win/scoped_com_initializer.h"
#include "base/win/windows_version.h"
#include "content/common/font_cache_dispatcher_win.h"
#include "content/common/sandbox_win.h"
+#include "content/public/common/dwrite_font_platform_win.h"
#include "sandbox/win/src/sandbox_policy.h"
+#include "ui/gfx/win/direct_write.h"
#include "ui/gfx/win/dpi.h"
#endif
@@ -329,7 +332,9 @@ class RendererSandboxedProcessLauncherDelegate
explicit RendererSandboxedProcessLauncherDelegate(IPC::ChannelProxy* channel)
#if defined(OS_POSIX)
: ipc_fd_(channel->TakeClientFileDescriptor())
-#endif // OS_POSIX
+#elif defined(OS_WIN)
+ : direct_write_font_cache_section_(NULL)
+#endif // OS_WIN
{}
~RendererSandboxedProcessLauncherDelegate() override {}
@@ -356,9 +361,18 @@ class RendererSandboxedProcessLauncherDelegate
}
}
+ // If we have a valid DirectWrite font cache section then add its handle to
+ // the list of handles being shared with the renderer process.
+ if (direct_write_font_cache_section_)
+ policy->AddHandleToShare(direct_write_font_cache_section_);
+
GetContentClient()->browser()->PreSpawnRenderer(policy, success);
}
+ void set_direct_write_font_cache_handle(
+ base::SharedMemoryHandle direct_write_font_cache_section) {
+ direct_write_font_cache_section_ = direct_write_font_cache_section;
Shrikant Kelkar 2015/05/05 20:43:16 Scope/DuplicateHandle?
ananta 2015/05/07 22:00:47 This code is no longer needed. Based on a discussi
+ }
#elif defined(OS_POSIX)
bool ShouldUseZygote() override {
const base::CommandLine& browser_command_line =
@@ -374,6 +388,10 @@ class RendererSandboxedProcessLauncherDelegate
#if defined(OS_POSIX)
base::ScopedFD ipc_fd_;
#endif // OS_POSIX
+
+#if defined(OS_WIN)
+ base::SharedMemoryHandle direct_write_font_cache_section_;
Shrikant Kelkar 2015/05/05 20:43:15 Scope? Who is the owner?
ananta 2015/05/07 22:00:48 Reworked the patch to move the handle sharing and
+#endif
};
const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey";
@@ -665,6 +683,24 @@ bool RenderProcessHostImpl::Init() {
g_in_process_thread = in_process_renderer_->message_loop();
} else {
+ RendererSandboxedProcessLauncherDelegate* sandbox_delegate =
+ new RendererSandboxedProcessLauncherDelegate(channel_.get());
+#if defined(OS_WIN)
+ // If DirectWrite is enabled for font rendering then open the font cache
+ // section and pass the handle to the renderer process. This is needed
+ // because renderer processes on Windows 8+ may be running in an
+ // AppContainer sandbox and hence their kernel object namespace may be
+ // partitioned.
+ if (!run_renderer_in_process() && gfx::win::ShouldUseDirectWrite()) {
+ std::string name(content::kFontCacheSharedSectionName);
+ name.append(base::UintToString(base::GetCurrentProcId()));
+ direct_write_font_cache_section_.set_inheritable(true);
+ if (direct_write_font_cache_section_.Open(name, true)) {
+ sandbox_delegate->set_direct_write_font_cache_handle(
+ direct_write_font_cache_section_.handle());
+ }
+ }
+#endif
// Build command line for renderer. We call AppendRendererCommandLine()
// first so the process type argument will appear first.
base::CommandLine* cmd_line = new base::CommandLine(renderer_path);
@@ -677,7 +713,7 @@ bool RenderProcessHostImpl::Init() {
// As long as there's no renderer prefix, we can use the zygote process
// at this stage.
child_process_launcher_.reset(new ChildProcessLauncher(
- new RendererSandboxedProcessLauncherDelegate(channel_.get()),
+ sandbox_delegate,
cmd_line,
GetID(),
this));
@@ -1198,9 +1234,12 @@ void RenderProcessHostImpl::AppendRendererCommandLine(
#if defined(OS_WIN)
command_line->AppendSwitchASCII(switches::kDeviceScaleFactor,
base::DoubleToString(gfx::GetDPIScale()));
- command_line->AppendSwitchASCII(
- switches::kFontCacheSharedMemSuffix,
- base::UintToString(base::GetCurrentProcId()));
+ if (direct_write_font_cache_section_.handle()) {
+ command_line->AppendSwitchASCII(
+ switches::kFontCacheSharedHandle,
+ base::UintToString(reinterpret_cast<unsigned int>(
+ direct_write_font_cache_section_.handle())));
+ }
#endif
AppendCompositorCommandLineFlags(command_line);

Powered by Google App Engine
This is Rietveld 408576698