Index: chrome/utility/utility_thread.cc |
diff --git a/chrome/utility/utility_thread.cc b/chrome/utility/utility_thread.cc |
index 420df28fbf1ee7c1b8a3988f1c2e85383bb6952d..c759c0dc1b28a8aa5a514f2f4acf3831b91a9371 100644 |
--- a/chrome/utility/utility_thread.cc |
+++ b/chrome/utility/utility_thread.cc |
@@ -15,6 +15,7 @@ |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/extensions/extension_unpacker.h" |
#include "chrome/common/extensions/update_manifest.h" |
+#include "chrome/common/indexed_db_key.h" |
#include "chrome/common/utility_messages.h" |
#include "chrome/common/web_resource/web_resource_unpacker.h" |
#include "gfx/rect.h" |
@@ -22,10 +23,24 @@ |
#include "printing/page_range.h" |
#include "printing/units.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
+#include "webkit/glue/idb_bindings.h" |
#include "webkit/glue/image_decoder.h" |
-UtilityThread::UtilityThread() { |
+namespace { |
+ |
+template<typename SRC, typename DEST> |
+void ConvertVector(const SRC& src, DEST* dest) { |
+ dest->reserve(src.size()); |
+ for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i) |
+ dest->push_back(typename DEST::value_type(*i)); |
+} |
+ |
+} // namespace |
+ |
+ |
+UtilityThread::UtilityThread() |
+ : batch_mode_(false) { |
ChildProcess::current()->AddRefProcess(); |
} |
@@ -40,6 +55,10 @@ void UtilityThread::OnControlMessageReceived(const IPC::Message& msg) { |
IPC_MESSAGE_HANDLER(UtilityMsg_DecodeImage, OnDecodeImage) |
IPC_MESSAGE_HANDLER(UtilityMsg_RenderPDFPagesToMetafile, |
OnRenderPDFPagesToMetafile) |
+ IPC_MESSAGE_HANDLER(UtilityMsg_IDBKeysFromValuesAndKeyPath, |
+ OnIDBKeysFromValuesAndKeyPath) |
+ IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) |
+ IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) |
IPC_END_MESSAGE_MAP() |
} |
@@ -53,7 +72,7 @@ void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { |
Send(new UtilityHostMsg_UnpackExtension_Failed(unpacker.error_message())); |
} |
- ChildProcess::current()->ReleaseProcess(); |
+ ReleaseProcessIfNeeded(); |
} |
void UtilityThread::OnUnpackWebResource(const std::string& resource_data) { |
@@ -69,7 +88,7 @@ void UtilityThread::OnUnpackWebResource(const std::string& resource_data) { |
unpacker.error_message())); |
} |
- ChildProcess::current()->ReleaseProcess(); |
+ ReleaseProcessIfNeeded(); |
} |
void UtilityThread::OnParseUpdateManifest(const std::string& xml) { |
@@ -79,7 +98,7 @@ void UtilityThread::OnParseUpdateManifest(const std::string& xml) { |
} else { |
Send(new UtilityHostMsg_ParseUpdateManifest_Succeeded(manifest.results())); |
} |
- ChildProcess::current()->ReleaseProcess(); |
+ ReleaseProcessIfNeeded(); |
} |
void UtilityThread::OnDecodeImage( |
@@ -92,7 +111,7 @@ void UtilityThread::OnDecodeImage( |
} else { |
Send(new UtilityHostMsg_DecodeImage_Succeeded(decoded_image)); |
} |
- ChildProcess::current()->ReleaseProcess(); |
+ ReleaseProcessIfNeeded(); |
} |
@@ -116,7 +135,7 @@ void UtilityThread::OnRenderPDFPagesToMetafile( |
if (!succeeded) { |
Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Failed()); |
} |
- ChildProcess::current()->ReleaseProcess(); |
+ ReleaseProcessIfNeeded(); |
} |
#if defined(OS_WIN) |
@@ -253,3 +272,35 @@ bool UtilityThread::RenderPDFToWinMetafile( |
return ret; |
} |
#endif // defined(OS_WIN) |
+ |
+void UtilityThread::OnIDBKeysFromValuesAndKeyPath( |
+ int id, |
+ const std::vector<SerializedScriptValue>& serialized_script_values, |
+ const string16& idb_key_path) { |
+ std::vector<WebKit::WebSerializedScriptValue> web_values; |
+ ConvertVector(serialized_script_values, &web_values); |
+ std::vector<WebKit::WebIDBKey> web_keys; |
+ bool error = webkit_glue::IDBKeysFromValuesAndKeyPath( |
+ web_values, idb_key_path, &web_keys); |
+ if (error) { |
+ Send(new UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Failed(id)); |
+ return; |
+ } |
+ std::vector<IndexedDBKey> keys; |
+ ConvertVector(web_keys, &keys); |
+ Send(new UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Succeeded(id, keys)); |
+ ReleaseProcessIfNeeded(); |
+} |
+ |
+void UtilityThread::OnBatchModeStarted() { |
+ batch_mode_ = true; |
+} |
+ |
+void UtilityThread::OnBatchModeFinished() { |
+ ChildProcess::current()->ReleaseProcess(); |
+} |
+ |
+void UtilityThread::ReleaseProcessIfNeeded() { |
+ if (!batch_mode_) |
+ ChildProcess::current()->ReleaseProcess(); |
+} |