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" |
14 #include "content/common/utility_messages.h" | 16 #include "content/common/utility_messages.h" |
15 #include "content/common/webkitplatformsupport_impl.h" | 17 #include "content/common/webkitplatformsupport_impl.h" |
16 #include "content/public/utility/content_utility_client.h" | 18 #include "content/public/utility/content_utility_client.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" |
| 22 #include "webkit/glue/idb_bindings.h" |
19 #include "webkit/plugins/npapi/plugin_list.h" | 23 #include "webkit/plugins/npapi/plugin_list.h" |
20 | 24 |
21 #if defined(TOOLKIT_GTK) | 25 #if defined(TOOLKIT_GTK) |
22 #include <gtk/gtk.h> | 26 #include <gtk/gtk.h> |
23 | 27 |
24 #include "ui/gfx/gtk_util.h" | 28 #include "ui/gfx/gtk_util.h" |
25 #endif | 29 #endif |
26 | 30 |
27 namespace { | 31 namespace { |
28 | 32 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 72 |
69 #endif // OS_WIN | 73 #endif // OS_WIN |
70 | 74 |
71 | 75 |
72 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 76 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
73 if (content::GetContentClient()->utility()->OnMessageReceived(msg)) | 77 if (content::GetContentClient()->utility()->OnMessageReceived(msg)) |
74 return true; | 78 return true; |
75 | 79 |
76 bool handled = true; | 80 bool handled = true; |
77 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) | 81 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) |
| 82 IPC_MESSAGE_HANDLER(UtilityMsg_IDBKeysFromValuesAndKeyPath, |
| 83 OnIDBKeysFromValuesAndKeyPath) |
| 84 IPC_MESSAGE_HANDLER(UtilityMsg_InjectIDBKey, OnInjectIDBKey) |
78 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) | 85 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) |
79 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) | 86 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) |
80 #if defined(OS_POSIX) | 87 #if defined(OS_POSIX) |
81 IPC_MESSAGE_HANDLER(UtilityMsg_LoadPlugins, OnLoadPlugins) | 88 IPC_MESSAGE_HANDLER(UtilityMsg_LoadPlugins, OnLoadPlugins) |
82 #endif // OS_POSIX | 89 #endif // OS_POSIX |
83 IPC_MESSAGE_UNHANDLED(handled = false) | 90 IPC_MESSAGE_UNHANDLED(handled = false) |
84 IPC_END_MESSAGE_MAP() | 91 IPC_END_MESSAGE_MAP() |
85 return handled; | 92 return handled; |
86 } | 93 } |
87 | 94 |
| 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 |
88 void UtilityThreadImpl::OnBatchModeStarted() { | 120 void UtilityThreadImpl::OnBatchModeStarted() { |
89 batch_mode_ = true; | 121 batch_mode_ = true; |
90 } | 122 } |
91 | 123 |
92 void UtilityThreadImpl::OnBatchModeFinished() { | 124 void UtilityThreadImpl::OnBatchModeFinished() { |
93 ChildProcess::current()->ReleaseProcess(); | 125 ChildProcess::current()->ReleaseProcess(); |
94 } | 126 } |
95 | 127 |
96 #if defined(OS_POSIX) | 128 #if defined(OS_POSIX) |
97 void UtilityThreadImpl::OnLoadPlugins( | 129 void UtilityThreadImpl::OnLoadPlugins( |
(...skipping 22 matching lines...) Expand all Loading... |
120 webkit::WebPluginInfo plugin; | 152 webkit::WebPluginInfo plugin; |
121 if (!plugin_list->LoadPlugin(plugin_paths[i], &plugin_groups, &plugin)) | 153 if (!plugin_list->LoadPlugin(plugin_paths[i], &plugin_groups, &plugin)) |
122 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); | 154 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); |
123 else | 155 else |
124 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); | 156 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); |
125 } | 157 } |
126 | 158 |
127 ReleaseProcessIfNeeded(); | 159 ReleaseProcessIfNeeded(); |
128 } | 160 } |
129 #endif | 161 #endif |
OLD | NEW |