| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/test/base/in_process_browser_test.h" | 7 #include "chrome/test/base/in_process_browser_test.h" |
| 8 #include "chrome/test/base/ui_test_utils.h" | 8 #include "chrome/test/base/ui_test_utils.h" |
| 9 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 9 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 10 #include "content/browser/utility_process_host.h" | 10 #include "content/browser/utility_process_host.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 BrowserThread::PostTask( | 94 BrowserThread::PostTask( |
| 95 BrowserThread::IO, FROM_HERE, | 95 BrowserThread::IO, FROM_HERE, |
| 96 base::Bind(&IDBKeyPathHelper::CreateUtilityProcess, this)); | 96 base::Bind(&IDBKeyPathHelper::CreateUtilityProcess, this)); |
| 97 return; | 97 return; |
| 98 } | 98 } |
| 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 100 utility_process_host_ = | 100 utility_process_host_ = |
| 101 new UtilityProcessHost(this, BrowserThread::IO); | 101 new UtilityProcessHost(this, BrowserThread::IO); |
| 102 utility_process_host_->StartBatchMode(); | 102 utility_process_host_->StartBatchMode(); |
| 103 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 103 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 104 new MessageLoop::QuitTask()); | 104 MessageLoop::QuitClosure()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void DestroyUtilityProcess() { | 107 void DestroyUtilityProcess() { |
| 108 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 108 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 109 BrowserThread::PostTask( | 109 BrowserThread::PostTask( |
| 110 BrowserThread::IO, FROM_HERE, | 110 BrowserThread::IO, FROM_HERE, |
| 111 base::Bind(&IDBKeyPathHelper::DestroyUtilityProcess, this)); | 111 base::Bind(&IDBKeyPathHelper::DestroyUtilityProcess, this)); |
| 112 return; | 112 return; |
| 113 } | 113 } |
| 114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 115 utility_process_host_->EndBatchMode(); | 115 utility_process_host_->EndBatchMode(); |
| 116 utility_process_host_ = NULL; | 116 utility_process_host_ = NULL; |
| 117 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 117 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 118 new MessageLoop::QuitTask()); | 118 MessageLoop::QuitClosure()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void SetExpectedKeys(int expected_id, | 121 void SetExpectedKeys(int expected_id, |
| 122 const std::vector<IndexedDBKey>& expected_keys, | 122 const std::vector<IndexedDBKey>& expected_keys, |
| 123 bool failed) { | 123 bool failed) { |
| 124 expected_id_ = expected_id; | 124 expected_id_ = expected_id; |
| 125 expected_keys_ = expected_keys; | 125 expected_keys_ = expected_keys; |
| 126 value_for_key_path_failed_ = failed; | 126 value_for_key_path_failed_ = failed; |
| 127 } | 127 } |
| 128 | 128 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 for (std::vector<IndexedDBKey>::const_iterator i(values.begin()); | 189 for (std::vector<IndexedDBKey>::const_iterator i(values.begin()); |
| 190 i != values.end(); ++i, ++pos) { | 190 i != values.end(); ++i, ++pos) { |
| 191 ASSERT_EQ(expected_keys_[pos].type(), i->type()); | 191 ASSERT_EQ(expected_keys_[pos].type(), i->type()); |
| 192 if (i->type() == WebKit::WebIDBKey::StringType) { | 192 if (i->type() == WebKit::WebIDBKey::StringType) { |
| 193 ASSERT_EQ(expected_keys_[pos].string(), i->string()); | 193 ASSERT_EQ(expected_keys_[pos].string(), i->string()); |
| 194 } else if (i->type() == WebKit::WebIDBKey::NumberType) { | 194 } else if (i->type() == WebKit::WebIDBKey::NumberType) { |
| 195 ASSERT_EQ(expected_keys_[pos].number(), i->number()); | 195 ASSERT_EQ(expected_keys_[pos].number(), i->number()); |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 198 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 199 new MessageLoop::QuitTask()); | 199 MessageLoop::QuitClosure()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void OnIDBKeysFromValuesAndKeyPathFailed(int id) { | 202 void OnIDBKeysFromValuesAndKeyPathFailed(int id) { |
| 203 EXPECT_TRUE(value_for_key_path_failed_); | 203 EXPECT_TRUE(value_for_key_path_failed_); |
| 204 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 204 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 205 new MessageLoop::QuitTask()); | 205 MessageLoop::QuitClosure()); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void OnInjectIDBKeyFinished(const content::SerializedScriptValue& new_value) { | 208 void OnInjectIDBKeyFinished(const content::SerializedScriptValue& new_value) { |
| 209 EXPECT_EQ(expected_value_.data(), new_value.data()); | 209 EXPECT_EQ(expected_value_.data(), new_value.data()); |
| 210 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 210 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 211 new MessageLoop::QuitTask()); | 211 MessageLoop::QuitClosure()); |
| 212 } | 212 } |
| 213 | 213 |
| 214 | 214 |
| 215 private: | 215 private: |
| 216 int expected_id_; | 216 int expected_id_; |
| 217 std::vector<IndexedDBKey> expected_keys_; | 217 std::vector<IndexedDBKey> expected_keys_; |
| 218 UtilityProcessHost* utility_process_host_; | 218 UtilityProcessHost* utility_process_host_; |
| 219 bool value_for_key_path_failed_; | 219 bool value_for_key_path_failed_; |
| 220 content::SerializedScriptValue expected_value_; | 220 content::SerializedScriptValue expected_value_; |
| 221 }; | 221 }; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 ScopedIDBKeyPathHelper scoped_helper; | 362 ScopedIDBKeyPathHelper scoped_helper; |
| 363 scoped_helper.SetExpectedValue(expected_value); | 363 scoped_helper.SetExpectedValue(expected_value); |
| 364 // TODO(lukezarko@gmail.com): re-enable this after the changes described at | 364 // TODO(lukezarko@gmail.com): re-enable this after the changes described at |
| 365 // https://bugs.webkit.org/show_bug.cgi?id=63481 land. | 365 // https://bugs.webkit.org/show_bug.cgi?id=63481 land. |
| 366 // scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bar")); | 366 // scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bar")); |
| 367 | 367 |
| 368 // Expect null. | 368 // Expect null. |
| 369 scoped_helper.SetExpectedValue(content::SerializedScriptValue()); | 369 scoped_helper.SetExpectedValue(content::SerializedScriptValue()); |
| 370 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bad.key.path")); | 370 scoped_helper.CheckInjectValue(key, value, UTF8ToUTF16("bad.key.path")); |
| 371 } | 371 } |
| OLD | NEW |