summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-17 12:56:09 +0000
committerhans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-17 12:56:09 +0000
commitd20e0b986707dd49ae7a2cad347f4e50140ec86e (patch)
treeb0cef7b8dcf072f4640ec9d24b9e546c501df52a
parent7e58a5a1b1a11dd3571127dc952e32fc841a50ad (diff)
downloadchromium_src-d20e0b986707dd49ae7a2cad347f4e50140ec86e.zip
chromium_src-d20e0b986707dd49ae7a2cad347f4e50140ec86e.tar.gz
chromium_src-d20e0b986707dd49ae7a2cad347f4e50140ec86e.tar.bz2
IndexedDB: Allow injection of keys into values via key path.
BUG=70118 TEST=browser_tests Review URL: http://codereview.chromium.org/6529021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75258 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/idbbindingutilities_browsertest.cc116
-rw-r--r--chrome/browser/in_process_webkit/browser_webkitclient_impl.cc8
-rw-r--r--chrome/browser/in_process_webkit/browser_webkitclient_impl.h4
-rw-r--r--chrome/browser/in_process_webkit/indexed_db_key_utility_client.cc92
-rw-r--r--chrome/browser/in_process_webkit/indexed_db_key_utility_client.h7
-rw-r--r--chrome/browser/utility_process_host.cc13
-rw-r--r--chrome/browser/utility_process_host.h12
-rw-r--r--chrome/common/utility_messages_internal.h11
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc9
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.h4
-rw-r--r--chrome/utility/utility_thread.cc12
-rw-r--r--chrome/utility/utility_thread.h6
-rw-r--r--webkit/glue/idb_bindings.cc9
-rw-r--r--webkit/glue/idb_bindings.h5
-rw-r--r--webkit/support/test_webkit_client.cc8
-rw-r--r--webkit/support/test_webkit_client.h4
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.cc8
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h6
18 files changed, 305 insertions, 29 deletions
diff --git a/chrome/browser/idbbindingutilities_browsertest.cc b/chrome/browser/idbbindingutilities_browsertest.cc
index 581e736..9d25d17 100644
--- a/chrome/browser/idbbindingutilities_browsertest.cc
+++ b/chrome/browser/idbbindingutilities_browsertest.cc
@@ -98,14 +98,18 @@ class IDBKeyPathHelper : public UtilityProcessHost::Client {
new MessageLoop::QuitTask());
}
- void SetExpected(int expected_id,
- const std::vector<IndexedDBKey>& expected_values,
- bool failed) {
+ void SetExpectedKeys(int expected_id,
+ const std::vector<IndexedDBKey>& expected_keys,
+ bool failed) {
expected_id_ = expected_id;
- expected_values_ = expected_values;
+ expected_keys_ = expected_keys;
value_for_key_path_failed_ = failed;
}
+ void SetExpectedValue(const SerializedScriptValue& expected_value) {
+ expected_value_ = expected_value;
+ }
+
void CheckValuesForKeyPath(
int id, const std::vector<SerializedScriptValue>& serialized_values,
const string16& key_path) {
@@ -123,20 +127,35 @@ class IDBKeyPathHelper : public UtilityProcessHost::Client {
ASSERT_TRUE(ret);
}
+ void CheckInjectValue(const IndexedDBKey& key,
+ const SerializedScriptValue& value,
+ const string16& key_path) {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &IDBKeyPathHelper::CheckInjectValue,
+ key, value, key_path));
+ return;
+ }
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ bool ret = utility_process_host_->StartInjectIDBKey(key, value, key_path);
+ ASSERT_TRUE(ret);
+ }
+
// UtilityProcessHost::Client
virtual void OnIDBKeysFromValuesAndKeyPathSucceeded(
int id, const std::vector<IndexedDBKey>& values) {
EXPECT_EQ(expected_id_, id);
EXPECT_FALSE(value_for_key_path_failed_);
- ASSERT_EQ(expected_values_.size(), values.size());
+ ASSERT_EQ(expected_keys_.size(), values.size());
size_t pos = 0;
for (std::vector<IndexedDBKey>::const_iterator i(values.begin());
i != values.end(); ++i, ++pos) {
- ASSERT_EQ(expected_values_[pos].type(), i->type());
+ ASSERT_EQ(expected_keys_[pos].type(), i->type());
if (i->type() == WebKit::WebIDBKey::StringType) {
- ASSERT_EQ(expected_values_[pos].string(), i->string());
+ ASSERT_EQ(expected_keys_[pos].string(), i->string());
} else if (i->type() == WebKit::WebIDBKey::NumberType) {
- ASSERT_EQ(expected_values_[pos].number(), i->number());
+ ASSERT_EQ(expected_keys_[pos].number(), i->number());
}
}
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
@@ -149,11 +168,20 @@ class IDBKeyPathHelper : public UtilityProcessHost::Client {
new MessageLoop::QuitTask());
}
+ virtual void OnInjectIDBKeyFinished(
+ const SerializedScriptValue& new_value) {
+ EXPECT_EQ(expected_value_.data(), new_value.data());
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ new MessageLoop::QuitTask());
+ }
+
+
private:
int expected_id_;
- std::vector<IndexedDBKey> expected_values_;
+ std::vector<IndexedDBKey> expected_keys_;
UtilityProcessHost* utility_process_host_;
bool value_for_key_path_failed_;
+ SerializedScriptValue expected_value_;
};
// This test fixture runs in the UI thread. However, most of the work done by
@@ -175,9 +203,13 @@ class ScopedIDBKeyPathHelper {
ui_test_utils::RunMessageLoop();
}
- void SetExpected(int id, const std::vector<IndexedDBKey>& expected_values,
+ void SetExpectedKeys(int id, const std::vector<IndexedDBKey>& expected_keys,
bool failed) {
- key_path_helper_->SetExpected(id, expected_values, failed);
+ key_path_helper_->SetExpectedKeys(id, expected_keys, failed);
+ }
+
+ void SetExpectedValue(const SerializedScriptValue& expected_value) {
+ key_path_helper_->SetExpectedValue(expected_value);
}
void CheckValuesForKeyPath(
@@ -189,6 +221,13 @@ class ScopedIDBKeyPathHelper {
ui_test_utils::RunMessageLoop();
}
+ void CheckInjectValue(const IndexedDBKey& key,
+ const SerializedScriptValue& value,
+ const string16& key_path) {
+ key_path_helper_->CheckInjectValue(key, value, key_path);
+ ui_test_utils::RunMessageLoop();
+ }
+
private:
scoped_refptr<IDBKeyPathHelper> key_path_helper_;
};
@@ -196,16 +235,16 @@ class ScopedIDBKeyPathHelper {
IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathExtract) {
ScopedIDBKeyPathHelper scoped_helper;
const int kId = 7;
- std::vector<IndexedDBKey> expected_values;
+ std::vector<IndexedDBKey> expected_keys;
IndexedDBKey value;
value.SetString(UTF8ToUTF16("zoo"));
- expected_values.push_back(value);
+ expected_keys.push_back(value);
IndexedDBKey invalid_value;
invalid_value.SetInvalid();
- expected_values.push_back(invalid_value);
+ expected_keys.push_back(invalid_value);
- scoped_helper.SetExpected(kId, expected_values, false);
+ scoped_helper.SetExpectedKeys(kId, expected_keys, false);
char16 data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b};
std::vector<SerializedScriptValue> serialized_values;
@@ -220,13 +259,13 @@ IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathExtract) {
IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathPropertyNotAvailable) {
ScopedIDBKeyPathHelper scoped_helper;
const int kId = 7;
- std::vector<IndexedDBKey> expected_values;
+ std::vector<IndexedDBKey> expected_keys;
IndexedDBKey invalid_value;
invalid_value.SetInvalid();
- expected_values.push_back(invalid_value);
- expected_values.push_back(invalid_value);
+ expected_keys.push_back(invalid_value);
+ expected_keys.push_back(invalid_value);
- scoped_helper.SetExpected(kId, expected_values, false);
+ scoped_helper.SetExpectedKeys(kId, expected_keys, false);
char16 data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b};
std::vector<SerializedScriptValue> serialized_values;
@@ -241,13 +280,13 @@ IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathPropertyNotAvailable) {
IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathMultipleCalls) {
ScopedIDBKeyPathHelper scoped_helper;
const int kId = 7;
- std::vector<IndexedDBKey> expected_values;
+ std::vector<IndexedDBKey> expected_keys;
IndexedDBKey invalid_value;
invalid_value.SetInvalid();
- expected_values.push_back(invalid_value);
- expected_values.push_back(invalid_value);
+ expected_keys.push_back(invalid_value);
+ expected_keys.push_back(invalid_value);
- scoped_helper.SetExpected(kId, expected_values, true);
+ scoped_helper.SetExpectedKeys(kId, expected_keys, true);
char16 data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b};
std::vector<SerializedScriptValue> serialized_values;
@@ -259,12 +298,35 @@ IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, IDBKeyPathMultipleCalls) {
UTF8ToUTF16("!+Invalid[KeyPath[[["));
// Call again with the Utility process in batch mode and with valid keys.
- expected_values.clear();
+ expected_keys.clear();
IndexedDBKey value;
value.SetString(UTF8ToUTF16("zoo"));
- expected_values.push_back(value);
- expected_values.push_back(invalid_value);
- scoped_helper.SetExpected(kId + 1, expected_values, false);
+ expected_keys.push_back(value);
+ expected_keys.push_back(invalid_value);
+ scoped_helper.SetExpectedKeys(kId + 1, expected_keys, false);
scoped_helper.CheckValuesForKeyPath(kId + 1, serialized_values,
UTF8ToUTF16("foo"));
}
+
+IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, InjectIDBKey) {
+ // {foo: 'zoo'}
+ const char16 data[] = {0x0353,0x6f66,0x536f,0x7a03,0x6f6f,0x017b};
+ SerializedScriptValue value(false, false, string16(data, arraysize(data)));
+ IndexedDBKey key;
+ key.SetString(UTF8ToUTF16("myNewKey"));
+
+ // {foo: 'zoo', bar: 'myNewKey'}
+ const char16 expected_data[] = {0x353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x353,
+ 0x6162, 0x5372, 0x6d08, 0x4e79, 0x7765,
+ 0x654b, 0x7b79, 0x2};
+ SerializedScriptValue expected_value(false, false,
+ string16(expected_data,
+ arraysize(expected_data)));
+
+ ScopedIDBKeyPathHelper scoped_helper;
+ scoped_helper.SetExpectedValue(expected_value);
+ scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bar"));
+
+ scoped_helper.SetExpectedValue(SerializedScriptValue()); // Expect null.
+ scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bad.key.path"));
+}
diff --git a/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc b/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
index da76fa2..0795f1b 100644
--- a/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
+++ b/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
@@ -165,3 +165,11 @@ void BrowserWebKitClientImpl::createIDBKeysFromSerializedValuesAndKeyPath(
keys = std_keys;
}
+
+WebKit::WebSerializedScriptValue
+BrowserWebKitClientImpl::injectIDBKeyIntoSerializedValue(
+ const WebKit::WebIDBKey& key, const WebKit::WebSerializedScriptValue& value,
+ const WebKit::WebString& keyPath) {
+ return IndexedDBKeyUtilityClient::InjectIDBKeyIntoSerializedValue(
+ IndexedDBKey(key), SerializedScriptValue(value), keyPath);
+}
diff --git a/chrome/browser/in_process_webkit/browser_webkitclient_impl.h b/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
index 54ada73..e0dbae5 100644
--- a/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
+++ b/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
@@ -52,6 +52,10 @@ class BrowserWebKitClientImpl : public webkit_glue::WebKitClientImpl {
const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values,
const WebKit::WebString& keyPath,
WebKit::WebVector<WebKit::WebIDBKey>& keys);
+ virtual WebKit::WebSerializedScriptValue injectIDBKeyIntoSerializedValue(
+ const WebKit::WebIDBKey& key,
+ const WebKit::WebSerializedScriptValue& value,
+ const WebKit::WebString& keyPath);
private:
webkit_glue::WebFileUtilitiesImpl file_utilities_;
diff --git a/chrome/browser/in_process_webkit/indexed_db_key_utility_client.cc b/chrome/browser/in_process_webkit/indexed_db_key_utility_client.cc
index e70b2a3..aec651f 100644
--- a/chrome/browser/in_process_webkit/indexed_db_key_utility_client.cc
+++ b/chrome/browser/in_process_webkit/indexed_db_key_utility_client.cc
@@ -33,6 +33,13 @@ class KeyUtilityClientImpl
const string16& key_path,
std::vector<IndexedDBKey>* keys);
+ // Synchronously inject |key| into |value| using the given |key_path|,
+ // returning the new value.
+ SerializedScriptValue InjectIDBKeyIntoSerializedValue(
+ const IndexedDBKey& key,
+ const SerializedScriptValue& value,
+ const string16& key_path);
+
private:
class Client : public UtilityProcessHost::Client {
public:
@@ -43,6 +50,7 @@ class KeyUtilityClientImpl
virtual void OnIDBKeysFromValuesAndKeyPathSucceeded(
int id, const std::vector<IndexedDBKey>& keys);
virtual void OnIDBKeysFromValuesAndKeyPathFailed(int id);
+ virtual void OnInjectIDBKeyFinished(const SerializedScriptValue& value);
private:
KeyUtilityClientImpl* parent_;
@@ -59,9 +67,15 @@ class KeyUtilityClientImpl
void CallStartIDBKeyFromValueAndKeyPathFromIOThread(
const std::vector<SerializedScriptValue>& values,
const string16& key_path);
+ void CallStartInjectIDBKeyFromIOThread(
+ const IndexedDBKey& key,
+ const SerializedScriptValue& value,
+ const string16& key_path);
void SetKeys(const std::vector<IndexedDBKey>& keys);
void FinishCreatingKeys();
+ void SetValueAfterInjection(const SerializedScriptValue& value);
+ void FinishInjectingKey();
base::WaitableEvent waitable_event_;
@@ -71,10 +85,12 @@ class KeyUtilityClientImpl
STATE_UNINITIALIZED,
STATE_INITIALIZED,
STATE_CREATING_KEYS,
+ STATE_INJECTING_KEY,
STATE_SHUTDOWN,
};
State state_;
std::vector<IndexedDBKey> keys_;
+ SerializedScriptValue value_after_injection_;
// Used in the IO thread.
UtilityProcessHost* utility_process_host_;
@@ -129,6 +145,26 @@ void IndexedDBKeyUtilityClient::CreateIDBKeysFromSerializedValuesAndKeyPath(
keys);
}
+// static
+SerializedScriptValue
+IndexedDBKeyUtilityClient::InjectIDBKeyIntoSerializedValue(
+ const IndexedDBKey& key, const SerializedScriptValue& value,
+ const string16& key_path) {
+ IndexedDBKeyUtilityClient* instance = client_instance.Pointer();
+
+ if (instance->is_shutdown_)
+ return SerializedScriptValue();
+
+ if (!instance->impl_) {
+ instance->impl_ = new KeyUtilityClientImpl();
+ instance->impl_->StartUtilityProcess();
+ }
+
+ return instance->impl_->InjectIDBKeyIntoSerializedValue(key, value, key_path);
+}
+
+
+
// KeyUtilityClientImpl definitions.
void KeyUtilityClientImpl::Shutdown() {
@@ -182,6 +218,26 @@ void KeyUtilityClientImpl::CreateIDBKeysFromSerializedValuesAndKeyPath(
*keys = keys_;
}
+SerializedScriptValue KeyUtilityClientImpl::InjectIDBKeyIntoSerializedValue(
+ const IndexedDBKey& key,
+ const SerializedScriptValue& value,
+ const string16& key_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
+ if (state_ == STATE_SHUTDOWN)
+ return SerializedScriptValue();
+
+ DCHECK(state_ == STATE_INITIALIZED);
+
+ state_ = STATE_INJECTING_KEY;
+ CallStartInjectIDBKeyFromIOThread(key, value, key_path);
+
+ bool ret = waitable_event_.Wait();
+ DCHECK(ret && state_ == STATE_INITIALIZED);
+
+ return value_after_injection_;
+}
+
+
void KeyUtilityClientImpl::GetRDHAndStartUtilityProcess() {
// In order to start the UtilityProcess, we need to grab
// a pointer to the ResourceDispatcherHost. This can only
@@ -259,6 +315,24 @@ void KeyUtilityClientImpl::CallStartIDBKeyFromValueAndKeyPathFromIOThread(
0, values, key_path);
}
+void KeyUtilityClientImpl::CallStartInjectIDBKeyFromIOThread(
+ const IndexedDBKey& key,
+ const SerializedScriptValue& value,
+ const string16& key_path) {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ NewRunnableMethod(this,
+ &KeyUtilityClientImpl::
+ CallStartInjectIDBKeyFromIOThread,
+ key, value, key_path));
+ return;
+ }
+
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ utility_process_host_->StartInjectIDBKey(key, value, key_path);
+}
+
void KeyUtilityClientImpl::SetKeys(const std::vector<IndexedDBKey>& keys) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
keys_ = keys;
@@ -270,6 +344,18 @@ void KeyUtilityClientImpl::FinishCreatingKeys() {
waitable_event_.Signal();
}
+void KeyUtilityClientImpl::SetValueAfterInjection(
+ const SerializedScriptValue& value) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ value_after_injection_ = value;
+}
+
+void KeyUtilityClientImpl::FinishInjectingKey() {
+ DCHECK(state_ == STATE_INJECTING_KEY);
+ state_ = STATE_INITIALIZED;
+ waitable_event_.Signal();
+}
+
KeyUtilityClientImpl::Client::Client(KeyUtilityClientImpl* parent)
: parent_(parent) {
}
@@ -285,6 +371,12 @@ void KeyUtilityClientImpl::Client::OnIDBKeysFromValuesAndKeyPathSucceeded(
parent_->FinishCreatingKeys();
}
+void KeyUtilityClientImpl::Client::OnInjectIDBKeyFinished(
+ const SerializedScriptValue& value) {
+ parent_->SetValueAfterInjection(value);
+ parent_->FinishInjectingKey();
+}
+
void KeyUtilityClientImpl::Client::OnIDBKeysFromValuesAndKeyPathFailed(
int id) {
parent_->FinishCreatingKeys();
diff --git a/chrome/browser/in_process_webkit/indexed_db_key_utility_client.h b/chrome/browser/in_process_webkit/indexed_db_key_utility_client.h
index b36aafa..0c92a58 100644
--- a/chrome/browser/in_process_webkit/indexed_db_key_utility_client.h
+++ b/chrome/browser/in_process_webkit/indexed_db_key_utility_client.h
@@ -31,6 +31,13 @@ class IndexedDBKeyUtilityClient {
const string16& key_path,
std::vector<IndexedDBKey>* keys);
+ // Synchronously inject |key| into |value| using |key_path|. Returns the new
+ // value.
+ static SerializedScriptValue InjectIDBKeyIntoSerializedValue(
+ const IndexedDBKey& key,
+ const SerializedScriptValue& value,
+ const string16& key_path);
+
// Shut down the underlying implementation. Must be called on the IO thread.
static void Shutdown();
diff --git a/chrome/browser/utility_process_host.cc b/chrome/browser/utility_process_host.cc
index 378f945..98502c9 100644
--- a/chrome/browser/utility_process_host.cc
+++ b/chrome/browser/utility_process_host.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/indexed_db_key.h"
+#include "chrome/common/serialized_script_value.h"
#include "chrome/common/utility_messages.h"
#include "ipc/ipc_switches.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -76,6 +77,16 @@ bool UtilityProcessHost::StartIDBKeysFromValuesAndKeyPath(
return true;
}
+bool UtilityProcessHost::StartInjectIDBKey(
+ const IndexedDBKey& key, const SerializedScriptValue& value,
+ const string16& key_path) {
+ if (!StartProcess(FilePath()))
+ return false;
+
+ Send(new UtilityMsg_InjectIDBKey(key, value, key_path));
+ return true;
+}
+
bool UtilityProcessHost::StartBatchMode() {
CHECK(!is_batch_mode_);
is_batch_mode_ = StartProcess(FilePath());
@@ -195,6 +206,8 @@ bool UtilityProcessHost::Client::OnMessageReceived(
Client::OnIDBKeysFromValuesAndKeyPathSucceeded)
IPC_MESSAGE_HANDLER(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Failed,
Client::OnIDBKeysFromValuesAndKeyPathFailed)
+ IPC_MESSAGE_HANDLER(UtilityHostMsg_InjectIDBKey_Finished,
+ Client::OnInjectIDBKeyFinished)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
return handled;
diff --git a/chrome/browser/utility_process_host.h b/chrome/browser/utility_process_host.h
index c1f4055..eaa0771 100644
--- a/chrome/browser/utility_process_host.h
+++ b/chrome/browser/utility_process_host.h
@@ -89,6 +89,12 @@ class UtilityProcessHost : public BrowserChildProcessHost {
// StartIDBKeysFromValuesAndKeyPath.
virtual void OnIDBKeysFromValuesAndKeyPathFailed(int id) {}
+ // Called when an IDBKey was injected into a
+ // SerializedScriptValue. If injection failed, SerializedScriptValue is
+ // empty.
+ virtual void OnInjectIDBKeyFinished(
+ const SerializedScriptValue& new_value) {}
+
protected:
friend class base::RefCountedThreadSafe<Client>;
@@ -132,6 +138,12 @@ class UtilityProcessHost : public BrowserChildProcessHost {
int id, const std::vector<SerializedScriptValue>& serialized_values,
const string16& key_path);
+ // Starts injecting |key| into |value| via |key_path|, and replies with the
+ // updated value via OnInjectIDBKeyFinished.
+ bool StartInjectIDBKey(const IndexedDBKey& key,
+ const SerializedScriptValue& value,
+ const string16& key_path);
+
// Starts utility process in batch mode. Caller must call EndBatchMode()
// to finish the utility process.
bool StartBatchMode();
diff --git a/chrome/common/utility_messages_internal.h b/chrome/common/utility_messages_internal.h
index 11e07f22..162d183 100644
--- a/chrome/common/utility_messages_internal.h
+++ b/chrome/common/utility_messages_internal.h
@@ -55,6 +55,11 @@ IPC_MESSAGE_CONTROL3(UtilityMsg_IDBKeysFromValuesAndKeyPath,
std::vector<SerializedScriptValue>,
string16) // IDBKeyPath
+IPC_MESSAGE_CONTROL3(UtilityMsg_InjectIDBKey,
+ IndexedDBKey /* key */,
+ SerializedScriptValue /* value */,
+ string16 /* key path*/);
+
// Tells the utility process that it's running in batch mode.
IPC_MESSAGE_CONTROL0(UtilityMsg_BatchMode_Started)
@@ -137,6 +142,11 @@ IPC_MESSAGE_CONTROL2(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Succeeded,
IPC_MESSAGE_CONTROL1(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Failed,
int /* id */)
+// Reply when the utility process has finished injecting an IDBKey into
+// a SerializedScriptValue.
+IPC_MESSAGE_CONTROL1(UtilityHostMsg_InjectIDBKey_Finished,
+ SerializedScriptValue /* new value */)
+
// Reply when the utility process has succeeded in obtaining the printer
// capabilities and defaults.
IPC_MESSAGE_CONTROL2(UtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded,
@@ -147,4 +157,3 @@ IPC_MESSAGE_CONTROL2(UtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded,
// capabilities and defaults.
IPC_MESSAGE_CONTROL1(UtilityHostMsg_GetPrinterCapsAndDefaults_Failed,
std::string /* printer name */)
-
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index ab51c01..4cb215f 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -311,6 +311,15 @@ void RendererWebKitClientImpl::createIDBKeysFromSerializedValuesAndKeyPath(
keys_out.swap(keys);
}
+WebSerializedScriptValue
+RendererWebKitClientImpl::injectIDBKeyIntoSerializedValue(const WebIDBKey& key,
+ const WebSerializedScriptValue& value,
+ const WebString& keyPath) {
+ DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess));
+ return WebIDBKey::injectIDBKeyIntoSerializedValue(
+ key, value, WebIDBKeyPath::create(keyPath));
+}
+
//------------------------------------------------------------------------------
WebFileSystem* RendererWebKitClientImpl::fileSystem() {
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
index 60010fc..ba4cc69 100644
--- a/chrome/renderer/renderer_webkitclient_impl.h
+++ b/chrome/renderer/renderer_webkitclient_impl.h
@@ -66,6 +66,10 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values,
const WebKit::WebString& keyPath,
WebKit::WebVector<WebKit::WebIDBKey>& keys);
+ virtual WebKit::WebSerializedScriptValue injectIDBKeyIntoSerializedValue(
+ const WebKit::WebIDBKey& key,
+ const WebKit::WebSerializedScriptValue& value,
+ const WebKit::WebString& keyPath);
virtual WebKit::WebFileSystem* fileSystem();
virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository();
diff --git a/chrome/utility/utility_thread.cc b/chrome/utility/utility_thread.cc
index fb5f0ac..6d078e3 100644
--- a/chrome/utility/utility_thread.cc
+++ b/chrome/utility/utility_thread.cc
@@ -63,6 +63,8 @@ bool UtilityThread::OnControlMessageReceived(const IPC::Message& msg) {
OnRenderPDFPagesToMetafile)
IPC_MESSAGE_HANDLER(UtilityMsg_IDBKeysFromValuesAndKeyPath,
OnIDBKeysFromValuesAndKeyPath)
+ IPC_MESSAGE_HANDLER(UtilityMsg_InjectIDBKey,
+ OnInjectIDBKey)
IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted)
IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished)
IPC_MESSAGE_HANDLER(UtilityMsg_GetPrinterCapsAndDefaults,
@@ -304,6 +306,15 @@ void UtilityThread::OnIDBKeysFromValuesAndKeyPath(
ReleaseProcessIfNeeded();
}
+void UtilityThread::OnInjectIDBKey(const IndexedDBKey& key,
+ const SerializedScriptValue& value,
+ const string16& key_path) {
+ SerializedScriptValue new_value(webkit_glue::InjectIDBKey(key, value,
+ key_path));
+ Send(new UtilityHostMsg_InjectIDBKey_Finished(new_value));
+ ReleaseProcessIfNeeded();
+}
+
void UtilityThread::OnBatchModeStarted() {
batch_mode_ = true;
}
@@ -330,4 +341,3 @@ void UtilityThread::ReleaseProcessIfNeeded() {
if (!batch_mode_)
ChildProcess::current()->ReleaseProcess();
}
-
diff --git a/chrome/utility/utility_thread.h b/chrome/utility/utility_thread.h
index ce4cc25..348cc90 100644
--- a/chrome/utility/utility_thread.h
+++ b/chrome/utility/utility_thread.h
@@ -14,6 +14,7 @@
#include "printing/native_metafile.h"
class GURL;
+class IndexedDBKey;
class SerializedScriptValue;
class SkBitmap;
@@ -77,6 +78,11 @@ class UtilityThread : public ChildThread {
const std::vector<SerializedScriptValue>& serialized_script_values,
const string16& idb_key_path);
+ // IPC for injecting an IndexedDB key into a SerializedScriptValue.
+ void OnInjectIDBKey(const IndexedDBKey& key,
+ const SerializedScriptValue& value,
+ const string16& key_path);
+
// IPC to notify we'll be running in batch mode instead of quitting after
// any of the IPCs above, we'll only quit during OnBatchModeFinished().
void OnBatchModeStarted();
diff --git a/webkit/glue/idb_bindings.cc b/webkit/glue/idb_bindings.cc
index c565f94..633045e 100644
--- a/webkit/glue/idb_bindings.cc
+++ b/webkit/glue/idb_bindings.cc
@@ -42,4 +42,13 @@ bool IDBKeysFromValuesAndKeyPath(
return error;
}
+WebSerializedScriptValue InjectIDBKey(
+ const WebIDBKey& key,
+ const WebSerializedScriptValue& value,
+ const string16& idb_key_path) {
+ v8::Locker lock;
+ return WebIDBKey::injectIDBKeyIntoSerializedValue(
+ key, value, WebIDBKeyPath::create(idb_key_path));
+}
+
} // namespace webkit_glue
diff --git a/webkit/glue/idb_bindings.h b/webkit/glue/idb_bindings.h
index 074595d..7d7c90d 100644
--- a/webkit/glue/idb_bindings.h
+++ b/webkit/glue/idb_bindings.h
@@ -22,4 +22,9 @@ bool IDBKeysFromValuesAndKeyPath(
const string16& idb_key_path,
std::vector<WebKit::WebIDBKey>* values);
+WebKit::WebSerializedScriptValue InjectIDBKey(
+ const WebKit::WebIDBKey& key,
+ const WebKit::WebSerializedScriptValue& value,
+ const string16& idb_key_path);
+
} // namespace webkit_glue
diff --git a/webkit/support/test_webkit_client.cc b/webkit/support/test_webkit_client.cc
index eaa99ba..fd314a4 100644
--- a/webkit/support/test_webkit_client.cc
+++ b/webkit/support/test_webkit_client.cc
@@ -331,6 +331,14 @@ void TestWebKitClient::createIDBKeysFromSerializedValuesAndKeyPath(
keys_out.swap(keys);
}
+WebKit::WebSerializedScriptValue
+TestWebKitClient::injectIDBKeyIntoSerializedValue(const WebKit::WebIDBKey& key,
+ const WebKit::WebSerializedScriptValue& value,
+ const WebKit::WebString& keyPath) {
+ return WebKit::WebIDBKey::injectIDBKeyIntoSerializedValue(
+ key, value, WebKit::WebIDBKeyPath::create(keyPath));
+}
+
#if defined(OS_WIN) || defined(OS_MACOSX)
void TestWebKitClient::SetThemeEngine(WebKit::WebThemeEngine* engine) {
active_theme_engine_ = engine ? engine : WebKitClientImpl::themeEngine();
diff --git a/webkit/support/test_webkit_client.h b/webkit/support/test_webkit_client.h
index dfe7acf..efeecf6 100644
--- a/webkit/support/test_webkit_client.h
+++ b/webkit/support/test_webkit_client.h
@@ -67,6 +67,10 @@ class TestWebKitClient : public webkit_glue::WebKitClientImpl {
const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values,
const WebKit::WebString& keyPath,
WebKit::WebVector<WebKit::WebIDBKey>& keys_out);
+ virtual WebKit::WebSerializedScriptValue injectIDBKeyIntoSerializedValue(
+ const WebKit::WebIDBKey& key,
+ const WebKit::WebSerializedScriptValue& value,
+ const WebKit::WebString& keyPath);
#if defined(OS_WIN) || defined(OS_MACOSX)
void SetThemeEngine(WebKit::WebThemeEngine* engine);
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.cc b/webkit/tools/test_shell/test_shell_webkit_init.cc
index 94dbb58..274ad63 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.cc
+++ b/webkit/tools/test_shell/test_shell_webkit_init.cc
@@ -278,6 +278,14 @@ void TestShellWebKitInit::createIDBKeysFromSerializedValuesAndKeyPath(
keys_out.swap(keys);
}
+WebKit::WebSerializedScriptValue
+TestShellWebKitInit::injectIDBKeyIntoSerializedValue(
+ const WebKit::WebIDBKey& key, const WebKit::WebSerializedScriptValue& value,
+ const WebKit::WebString& keyPath) {
+ return WebKit::WebIDBKey::injectIDBKeyIntoSerializedValue(
+ key, value, WebKit::WebIDBKeyPath::create(keyPath));
+}
+
WebKit::WebSharedWorkerRepository*
TestShellWebKitInit::sharedWorkerRepository() {
return NULL;
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index 8690991..f4c1e79 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -82,6 +82,12 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
const WebKit::WebString& keyPath,
WebKit::WebVector<WebKit::WebIDBKey>& keys_out);
+ virtual WebKit::WebSerializedScriptValue injectIDBKeyIntoSerializedValue(
+ const WebKit::WebIDBKey& key,
+ const WebKit::WebSerializedScriptValue& value,
+ const WebKit::WebString& keyPath);
+
+
#if defined(OS_WIN)
void SetThemeEngine(WebKit::WebThemeEngine* engine) {
active_theme_engine_ = engine ? engine : WebKitClientImpl::themeEngine();