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

Side by Side Diff: content/child/child_thread_impl.h

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 #ifndef CONTENT_CHILD_CHILD_THREAD_H_ 5 #ifndef CONTENT_CHILD_CHILD_THREAD_IMPL_H_
6 #define CONTENT_CHILD_CHILD_THREAD_H_ 6 #define CONTENT_CHILD_CHILD_THREAD_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/power_monitor/power_monitor.h" 14 #include "base/power_monitor/power_monitor.h"
15 #include "base/tracked_objects.h" 15 #include "base/tracked_objects.h"
16 #include "content/child/mojo/mojo_application.h" 16 #include "content/child/mojo/mojo_application.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/common/message_router.h" 18 #include "content/common/message_router.h"
19 #include "content/public/child/child_thread.h"
19 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. 20 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
20 21
21 namespace base { 22 namespace base {
22 class MessageLoop; 23 class MessageLoop;
23 24
24 namespace debug { 25 namespace debug {
25 class TraceMemoryController; 26 class TraceMemoryController;
26 } // namespace debug 27 } // namespace debug
27 } // namespace base 28 } // namespace base
28 29
(...skipping 21 matching lines...) Expand all
50 class PushDispatcher; 51 class PushDispatcher;
51 class ServiceWorkerMessageFilter; 52 class ServiceWorkerMessageFilter;
52 class QuotaDispatcher; 53 class QuotaDispatcher;
53 class QuotaMessageFilter; 54 class QuotaMessageFilter;
54 class ResourceDispatcher; 55 class ResourceDispatcher;
55 class ThreadSafeSender; 56 class ThreadSafeSender;
56 class WebSocketDispatcher; 57 class WebSocketDispatcher;
57 struct RequestInfo; 58 struct RequestInfo;
58 59
59 // The main thread of a child process derives from this class. 60 // The main thread of a child process derives from this class.
60 class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender { 61 class CONTENT_EXPORT ChildThreadImpl
62 : public IPC::Listener,
63 virtual public ChildThread {
scottmg 2015/02/03 17:52:06 Why does this need to be virtual?
jam 2015/02/03 18:13:04 It's because of the diamond inheritance: ChildTh
61 public: 64 public:
62 struct CONTENT_EXPORT Options { 65 struct CONTENT_EXPORT Options {
63 Options(); 66 Options();
64 explicit Options(bool mojo); 67 explicit Options(bool mojo);
65 Options(std::string name, bool mojo); 68 Options(std::string name, bool mojo);
66 ~Options(); 69 ~Options();
67 70
68 std::string channel_name; 71 std::string channel_name;
69 bool use_mojo_channel; 72 bool use_mojo_channel;
70 bool in_browser_process; 73 bool in_browser_process;
71 std::vector<IPC::MessageFilter*> startup_filters; 74 std::vector<IPC::MessageFilter*> startup_filters;
72 }; 75 };
73 76
74 // Creates the thread. 77 // Creates the thread.
75 ChildThread(); 78 ChildThreadImpl();
76 // Allow to be used for single-process mode and for in process gpu mode via 79 // Allow to be used for single-process mode and for in process gpu mode via
77 // options. 80 // options.
78 explicit ChildThread(const Options& options); 81 explicit ChildThreadImpl(const Options& options);
79 // ChildProcess::main_thread() is reset after Shutdown(), and before the 82 // ChildProcess::main_thread() is reset after Shutdown(), and before the
80 // destructor, so any subsystem that relies on ChildProcess::main_thread() 83 // destructor, so any subsystem that relies on ChildProcess::main_thread()
81 // must be terminated before Shutdown returns. In particular, if a subsystem 84 // must be terminated before Shutdown returns. In particular, if a subsystem
82 // has a thread that post tasks to ChildProcess::main_thread(), that thread 85 // has a thread that post tasks to ChildProcess::main_thread(), that thread
83 // should be joined in Shutdown(). 86 // should be joined in Shutdown().
84 ~ChildThread() override; 87 ~ChildThreadImpl() override;
85 virtual void Shutdown(); 88 virtual void Shutdown();
86 89
87 // IPC::Sender implementation: 90 // IPC::Sender implementation:
88 bool Send(IPC::Message* msg) override; 91 bool Send(IPC::Message* msg) override;
89 92
93 // ChildThread implementation:
94 #if defined(OS_WIN)
95 void PreCacheFont(const LOGFONT& log_font) override;
96 void ReleaseCachedFonts() override;
97 #endif
98
90 IPC::SyncChannel* channel() { return channel_.get(); } 99 IPC::SyncChannel* channel() { return channel_.get(); }
91 100
92 MessageRouter* GetRouter(); 101 MessageRouter* GetRouter();
93 102
94 // Allocates a block of shared memory of the given size. Returns NULL on 103 // Allocates a block of shared memory of the given size. Returns NULL on
95 // failure. 104 // failure.
96 // Note: On posix, this requires a sync IPC to the browser process, 105 // Note: On posix, this requires a sync IPC to the browser process,
97 // but on windows the child process directly allocates the block. 106 // but on windows the child process directly allocates the block.
98 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size); 107 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size);
99 108
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return quota_message_filter_.get(); 172 return quota_message_filter_.get();
164 } 173 }
165 174
166 ChildResourceMessageFilter* child_resource_message_filter() const { 175 ChildResourceMessageFilter* child_resource_message_filter() const {
167 return resource_message_filter_.get(); 176 return resource_message_filter_.get();
168 } 177 }
169 178
170 base::MessageLoop* message_loop() const { return message_loop_; } 179 base::MessageLoop* message_loop() const { return message_loop_; }
171 180
172 // Returns the one child thread. Can only be called on the main thread. 181 // Returns the one child thread. Can only be called on the main thread.
173 static ChildThread* current(); 182 static ChildThreadImpl* current();
174 183
175 #if defined(OS_ANDROID) 184 #if defined(OS_ANDROID)
176 // Called on Android's service thread to shutdown the main thread of this 185 // Called on Android's service thread to shutdown the main thread of this
177 // process. 186 // process.
178 static void ShutdownThread(); 187 static void ShutdownThread();
179 #endif 188 #endif
180 189
181 ServiceRegistry* service_registry() const { 190 ServiceRegistry* service_registry() const {
182 return mojo_application_->service_registry(); 191 return mojo_application_->service_registry();
183 } 192 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 scoped_ptr<MojoApplication> mojo_application_; 243 scoped_ptr<MojoApplication> mojo_application_;
235 244
236 std::string channel_name_; 245 std::string channel_name_;
237 scoped_ptr<IPC::SyncChannel> channel_; 246 scoped_ptr<IPC::SyncChannel> channel_;
238 247
239 // Allows threads other than the main thread to send sync messages. 248 // Allows threads other than the main thread to send sync messages.
240 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; 249 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
241 250
242 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 251 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
243 252
244 // Implements message routing functionality to the consumers of ChildThread. 253 // Implements message routing functionality to the consumers of
254 // ChildThreadImpl.
245 ChildThreadMessageRouter router_; 255 ChildThreadMessageRouter router_;
246 256
247 // Handles resource loads for this process. 257 // Handles resource loads for this process.
248 scoped_ptr<ResourceDispatcher> resource_dispatcher_; 258 scoped_ptr<ResourceDispatcher> resource_dispatcher_;
249 259
250 scoped_ptr<WebSocketDispatcher> websocket_dispatcher_; 260 scoped_ptr<WebSocketDispatcher> websocket_dispatcher_;
251 261
252 // The OnChannelError() callback was invoked - the channel is dead, don't 262 // The OnChannelError() callback was invoked - the channel is dead, don't
253 // attempt to communicate. 263 // attempt to communicate.
254 bool on_channel_error_called_; 264 bool on_channel_error_called_;
(...skipping 30 matching lines...) Expand all
285 scoped_ptr<base::PowerMonitor> power_monitor_; 295 scoped_ptr<base::PowerMonitor> power_monitor_;
286 296
287 scoped_refptr<GeofencingMessageFilter> geofencing_message_filter_; 297 scoped_refptr<GeofencingMessageFilter> geofencing_message_filter_;
288 298
289 scoped_refptr<BluetoothMessageFilter> bluetooth_message_filter_; 299 scoped_refptr<BluetoothMessageFilter> bluetooth_message_filter_;
290 300
291 scoped_refptr<NavigatorConnectDispatcher> navigator_connect_dispatcher_; 301 scoped_refptr<NavigatorConnectDispatcher> navigator_connect_dispatcher_;
292 302
293 bool in_browser_process_; 303 bool in_browser_process_;
294 304
295 base::WeakPtrFactory<ChildThread> channel_connected_factory_; 305 base::WeakPtrFactory<ChildThreadImpl> channel_connected_factory_;
296 306
297 DISALLOW_COPY_AND_ASSIGN(ChildThread); 307 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl);
298 }; 308 };
299 309
300 } // namespace content 310 } // namespace content
301 311
302 #endif // CONTENT_CHILD_CHILD_THREAD_H_ 312 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698