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

Side by Side Diff: content/utility/utility_thread_impl.cc

Issue 897563002: Unify the three places that patch font loading for PDFium on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
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/utility/utility_thread_impl.h" 5 #include "content/utility/utility_thread_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 22 matching lines...) Expand all
33 dest->push_back(typename DEST::value_type(*i)); 33 dest->push_back(typename DEST::value_type(*i));
34 } 34 }
35 35
36 } // namespace 36 } // namespace
37 37
38 UtilityThreadImpl::UtilityThreadImpl() : single_process_(false) { 38 UtilityThreadImpl::UtilityThreadImpl() : single_process_(false) {
39 Init(); 39 Init();
40 } 40 }
41 41
42 UtilityThreadImpl::UtilityThreadImpl(const std::string& channel_name) 42 UtilityThreadImpl::UtilityThreadImpl(const std::string& channel_name)
43 : ChildThread(Options(channel_name, false)), 43 : ChildThreadImpl(Options(channel_name, false)),
44 single_process_(true) { 44 single_process_(true) {
45 Init(); 45 Init();
46 } 46 }
47 47
48 UtilityThreadImpl::~UtilityThreadImpl() { 48 UtilityThreadImpl::~UtilityThreadImpl() {
49 } 49 }
50 50
51 void UtilityThreadImpl::Shutdown() { 51 void UtilityThreadImpl::Shutdown() {
52 ChildThread::Shutdown(); 52 ChildThreadImpl::Shutdown();
53 53
54 if (!single_process_) 54 if (!single_process_)
55 blink::shutdown(); 55 blink::shutdown();
56 } 56 }
57 57
58 bool UtilityThreadImpl::Send(IPC::Message* msg) {
59 return ChildThread::Send(msg);
60 }
61
62 void UtilityThreadImpl::ReleaseProcessIfNeeded() { 58 void UtilityThreadImpl::ReleaseProcessIfNeeded() {
63 if (batch_mode_) 59 if (batch_mode_)
64 return; 60 return;
65 61
66 if (single_process_) { 62 if (single_process_) {
67 // Close the channel to cause UtilityProcessHostImpl to be deleted. We need 63 // Close the channel to cause UtilityProcessHostImpl to be deleted. We need
68 // to take a different code path than the multi-process case because that 64 // to take a different code path than the multi-process case because that
69 // depends on the child process going away to close the channel, but that 65 // depends on the child process going away to close the channel, but that
70 // can't happen when we're in single process mode. 66 // can't happen when we're in single process mode.
71 channel()->Close(); 67 channel()->Close();
72 } else { 68 } else {
73 ChildProcess::current()->ReleaseProcess(); 69 ChildProcess::current()->ReleaseProcess();
74 } 70 }
75 } 71 }
76 72
77 #if defined(OS_WIN)
78
79 void UtilityThreadImpl::PreCacheFont(const LOGFONT& log_font) {
80 Send(new ChildProcessHostMsg_PreCacheFont(log_font));
81 }
82
83 void UtilityThreadImpl::ReleaseCachedFonts() {
84 Send(new ChildProcessHostMsg_ReleaseCachedFonts());
85 }
86
87 #endif // OS_WIN
88
89 void UtilityThreadImpl::Init() { 73 void UtilityThreadImpl::Init() {
90 batch_mode_ = false; 74 batch_mode_ = false;
91 ChildProcess::current()->AddRefProcess(); 75 ChildProcess::current()->AddRefProcess();
92 if (!single_process_) { 76 if (!single_process_) {
93 // We can only initialize WebKit on one thread, and in single process mode 77 // We can only initialize WebKit on one thread, and in single process mode
94 // we run the utility thread on separate thread. This means that if any code 78 // we run the utility thread on separate thread. This means that if any code
95 // needs WebKit initialized in the utility process, they need to have 79 // needs WebKit initialized in the utility process, they need to have
96 // another path to support single process mode. 80 // another path to support single process mode.
97 blink_platform_impl_.reset(new BlinkPlatformImpl); 81 blink_platform_impl_.reset(new BlinkPlatformImpl);
98 blink::initialize(blink_platform_impl_.get()); 82 blink::initialize(blink_platform_impl_.get());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); 125 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i]));
142 else 126 else
143 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); 127 Send(new UtilityHostMsg_LoadedPlugin(i, plugin));
144 } 128 }
145 129
146 ReleaseProcessIfNeeded(); 130 ReleaseProcessIfNeeded();
147 } 131 }
148 #endif 132 #endif
149 133
150 } // namespace content 134 } // namespace content
OLDNEW
« content/child/child_thread_impl.h ('K') | « content/utility/utility_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698