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/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/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 #include "content/common/child_process.h" | 12 #include "content/common/child_process.h" |
13 #include "content/common/child_process_messages.h" | 13 #include "content/common/child_process_messages.h" |
14 #include "content/common/utility_messages.h" | 14 #include "content/common/utility_messages.h" |
15 #include "content/common/webkitplatformsupport_impl.h" | 15 #include "content/common/webkitplatformsupport_impl.h" |
16 #include "content/public/utility/content_utility_client.h" | 16 #include "content/public/utility/content_utility_client.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" |
19 #include "webkit/plugins/npapi/plugin_list.h" | 19 #include "webkit/plugins/npapi/plugin_list.h" |
20 | 20 |
21 #if defined(TOOLKIT_GTK) | 21 #if defined(TOOLKIT_GTK) |
22 #include <gtk/gtk.h> | 22 #include <gtk/gtk.h> |
23 | 23 |
24 #include "ui/gfx/gtk_util.h" | 24 #include "ui/gfx/gtk_util.h" |
25 #endif | 25 #endif |
26 | 26 |
| 27 namespace content { |
| 28 |
27 namespace { | 29 namespace { |
28 | 30 |
29 template<typename SRC, typename DEST> | 31 template<typename SRC, typename DEST> |
30 void ConvertVector(const SRC& src, DEST* dest) { | 32 void ConvertVector(const SRC& src, DEST* dest) { |
31 dest->reserve(src.size()); | 33 dest->reserve(src.size()); |
32 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i) | 34 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i) |
33 dest->push_back(typename DEST::value_type(*i)); | 35 dest->push_back(typename DEST::value_type(*i)); |
34 } | 36 } |
35 | 37 |
36 } // namespace | 38 } // namespace |
37 | 39 |
38 UtilityThreadImpl::UtilityThreadImpl() | 40 UtilityThreadImpl::UtilityThreadImpl() |
39 : batch_mode_(false) { | 41 : batch_mode_(false) { |
40 ChildProcess::current()->AddRefProcess(); | 42 ChildProcess::current()->AddRefProcess(); |
41 webkit_platform_support_.reset(new content::WebKitPlatformSupportImpl); | 43 webkit_platform_support_.reset(new WebKitPlatformSupportImpl); |
42 WebKit::initialize(webkit_platform_support_.get()); | 44 WebKit::initialize(webkit_platform_support_.get()); |
43 content::GetContentClient()->utility()->UtilityThreadStarted(); | 45 GetContentClient()->utility()->UtilityThreadStarted(); |
44 } | 46 } |
45 | 47 |
46 UtilityThreadImpl::~UtilityThreadImpl() { | 48 UtilityThreadImpl::~UtilityThreadImpl() { |
47 WebKit::shutdown(); | 49 WebKit::shutdown(); |
48 } | 50 } |
49 | 51 |
50 bool UtilityThreadImpl::Send(IPC::Message* msg) { | 52 bool UtilityThreadImpl::Send(IPC::Message* msg) { |
51 return ChildThread::Send(msg); | 53 return ChildThread::Send(msg); |
52 } | 54 } |
53 | 55 |
54 void UtilityThreadImpl::ReleaseProcessIfNeeded() { | 56 void UtilityThreadImpl::ReleaseProcessIfNeeded() { |
55 if (!batch_mode_) | 57 if (!batch_mode_) |
56 ChildProcess::current()->ReleaseProcess(); | 58 ChildProcess::current()->ReleaseProcess(); |
57 } | 59 } |
58 | 60 |
59 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
60 | 62 |
61 void UtilityThreadImpl::PreCacheFont(const LOGFONT& log_font) { | 63 void UtilityThreadImpl::PreCacheFont(const LOGFONT& log_font) { |
62 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); | 64 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); |
63 } | 65 } |
64 | 66 |
65 void UtilityThreadImpl::ReleaseCachedFonts() { | 67 void UtilityThreadImpl::ReleaseCachedFonts() { |
66 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); | 68 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); |
67 } | 69 } |
68 | 70 |
69 #endif // OS_WIN | 71 #endif // OS_WIN |
70 | 72 |
71 | 73 |
72 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 74 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
73 if (content::GetContentClient()->utility()->OnMessageReceived(msg)) | 75 if (GetContentClient()->utility()->OnMessageReceived(msg)) |
74 return true; | 76 return true; |
75 | 77 |
76 bool handled = true; | 78 bool handled = true; |
77 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) | 79 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) |
78 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) | 80 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) |
79 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) | 81 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) |
80 #if defined(OS_POSIX) | 82 #if defined(OS_POSIX) |
81 IPC_MESSAGE_HANDLER(UtilityMsg_LoadPlugins, OnLoadPlugins) | 83 IPC_MESSAGE_HANDLER(UtilityMsg_LoadPlugins, OnLoadPlugins) |
82 #endif // OS_POSIX | 84 #endif // OS_POSIX |
83 IPC_MESSAGE_UNHANDLED(handled = false) | 85 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 if (!plugin_list->LoadPluginIntoPluginList( | 123 if (!plugin_list->LoadPluginIntoPluginList( |
122 plugin_paths[i], &plugins, &plugin)) | 124 plugin_paths[i], &plugins, &plugin)) |
123 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); | 125 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); |
124 else | 126 else |
125 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); | 127 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); |
126 } | 128 } |
127 | 129 |
128 ReleaseProcessIfNeeded(); | 130 ReleaseProcessIfNeeded(); |
129 } | 131 } |
130 #endif | 132 #endif |
| 133 |
| 134 } // namespace content |
OLD | NEW |