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/indexed_db/indexed_db_key.h" | |
15 #include "content/common/indexed_db/indexed_db_key_path.h" | |
16 #include "content/common/utility_messages.h" | 14 #include "content/common/utility_messages.h" |
17 #include "content/common/webkitplatformsupport_impl.h" | 15 #include "content/common/webkitplatformsupport_impl.h" |
18 #include "content/public/utility/content_utility_client.h" | 16 #include "content/public/utility/content_utility_client.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" | |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
21 #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" |
22 #include "webkit/glue/idb_bindings.h" | |
23 #include "webkit/plugins/npapi/plugin_list.h" | 19 #include "webkit/plugins/npapi/plugin_list.h" |
24 | 20 |
25 #if defined(TOOLKIT_GTK) | 21 #if defined(TOOLKIT_GTK) |
26 #include <gtk/gtk.h> | 22 #include <gtk/gtk.h> |
27 | 23 |
28 #include "ui/gfx/gtk_util.h" | 24 #include "ui/gfx/gtk_util.h" |
29 #endif | 25 #endif |
30 | 26 |
31 namespace { | 27 namespace { |
32 | 28 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 68 |
73 #endif // OS_WIN | 69 #endif // OS_WIN |
74 | 70 |
75 | 71 |
76 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 72 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
77 if (content::GetContentClient()->utility()->OnMessageReceived(msg)) | 73 if (content::GetContentClient()->utility()->OnMessageReceived(msg)) |
78 return true; | 74 return true; |
79 | 75 |
80 bool handled = true; | 76 bool handled = true; |
81 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) | 77 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) |
82 IPC_MESSAGE_HANDLER(UtilityMsg_IDBKeysFromValuesAndKeyPath, | |
83 OnIDBKeysFromValuesAndKeyPath) | |
84 IPC_MESSAGE_HANDLER(UtilityMsg_InjectIDBKey, OnInjectIDBKey) | |
85 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) | 78 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) |
86 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) | 79 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) |
87 #if defined(OS_POSIX) | 80 #if defined(OS_POSIX) |
88 IPC_MESSAGE_HANDLER(UtilityMsg_LoadPlugins, OnLoadPlugins) | 81 IPC_MESSAGE_HANDLER(UtilityMsg_LoadPlugins, OnLoadPlugins) |
89 #endif // OS_POSIX | 82 #endif // OS_POSIX |
90 IPC_MESSAGE_UNHANDLED(handled = false) | 83 IPC_MESSAGE_UNHANDLED(handled = false) |
91 IPC_END_MESSAGE_MAP() | 84 IPC_END_MESSAGE_MAP() |
92 return handled; | 85 return handled; |
93 } | 86 } |
94 | 87 |
95 void UtilityThreadImpl::OnIDBKeysFromValuesAndKeyPath( | |
96 int id, | |
97 const std::vector<content::SerializedScriptValue>& serialized_script_values, | |
98 const content::IndexedDBKeyPath& idb_key_path) { | |
99 std::vector<WebKit::WebSerializedScriptValue> web_values; | |
100 ConvertVector(serialized_script_values, &web_values); | |
101 std::vector<WebKit::WebIDBKey> web_keys; | |
102 webkit_glue::IDBKeysFromValuesAndKeyPath( | |
103 web_values, idb_key_path, &web_keys); | |
104 std::vector<content::IndexedDBKey> keys; | |
105 ConvertVector(web_keys, &keys); | |
106 Send(new UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Succeeded(id, keys)); | |
107 ReleaseProcessIfNeeded(); | |
108 } | |
109 | |
110 void UtilityThreadImpl::OnInjectIDBKey( | |
111 const content::IndexedDBKey& key, | |
112 const content::SerializedScriptValue& value, | |
113 const content::IndexedDBKeyPath& key_path) { | |
114 content::SerializedScriptValue new_value( | |
115 webkit_glue::InjectIDBKey(key, value, key_path)); | |
116 Send(new UtilityHostMsg_InjectIDBKey_Finished(new_value)); | |
117 ReleaseProcessIfNeeded(); | |
118 } | |
119 | |
120 void UtilityThreadImpl::OnBatchModeStarted() { | 88 void UtilityThreadImpl::OnBatchModeStarted() { |
121 batch_mode_ = true; | 89 batch_mode_ = true; |
122 } | 90 } |
123 | 91 |
124 void UtilityThreadImpl::OnBatchModeFinished() { | 92 void UtilityThreadImpl::OnBatchModeFinished() { |
125 ChildProcess::current()->ReleaseProcess(); | 93 ChildProcess::current()->ReleaseProcess(); |
126 } | 94 } |
127 | 95 |
128 #if defined(OS_POSIX) | 96 #if defined(OS_POSIX) |
129 void UtilityThreadImpl::OnLoadPlugins( | 97 void UtilityThreadImpl::OnLoadPlugins( |
(...skipping 22 matching lines...) Expand all Loading... |
152 webkit::WebPluginInfo plugin; | 120 webkit::WebPluginInfo plugin; |
153 if (!plugin_list->LoadPlugin(plugin_paths[i], &plugin_groups, &plugin)) | 121 if (!plugin_list->LoadPlugin(plugin_paths[i], &plugin_groups, &plugin)) |
154 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); | 122 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); |
155 else | 123 else |
156 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); | 124 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); |
157 } | 125 } |
158 | 126 |
159 ReleaseProcessIfNeeded(); | 127 ReleaseProcessIfNeeded(); |
160 } | 128 } |
161 #endif | 129 #endif |
OLD | NEW |