Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 | 69 |
| 70 TEST_F(WebIDBDatabaseImplTest, KeyAndValueSizeTest) { | 70 TEST_F(WebIDBDatabaseImplTest, KeyAndValueSizeTest) { |
| 71 // For testing use a much smaller maximum size to prevent allocating >100 MB | 71 // For testing use a much smaller maximum size to prevent allocating >100 MB |
| 72 // of memory, which crashes on memory-constrained systems. | 72 // of memory, which crashes on memory-constrained systems. |
| 73 const size_t kMaxValueSizeForTesting = 10 * 1024 * 1024; // 10 MB | 73 const size_t kMaxValueSizeForTesting = 10 * 1024 * 1024; // 10 MB |
| 74 const size_t kKeySize = 1024 * 1024; | 74 const size_t kKeySize = 1024 * 1024; |
| 75 | 75 |
| 76 const std::vector<char> data(kMaxValueSizeForTesting - kKeySize); | 76 const std::vector<char> data(kMaxValueSizeForTesting - kKeySize); |
| 77 const WebData value(&data.front(), data.size()); | 77 const WebData value(&data.front(), data.size()); |
| 78 const WebVector<WebBlobInfo> web_blob_info; | 78 const WebVector<WebBlobInfo> web_blob_info; |
| 79 const WebIDBKey key = WebIDBKey::createString( | 79 const WebIDBKey key = WebIDBKey::createString(blink::WebString::fromUTF16( |
| 80 base::string16(kKeySize / sizeof(base::string16::value_type), 'x')); | 80 base::string16(kKeySize / sizeof(base::string16::value_type), 'x'))); |
|
jam
2017/01/26 19:08:10
nit: use the WebString constructor that takes in a
kinuko
2017/01/27 05:33:02
It doesn't seem to have a convenient ctor for this
| |
| 81 | 81 |
| 82 const int64_t transaction_id = 1; | 82 const int64_t transaction_id = 1; |
| 83 const int64_t object_store_id = 2; | 83 const int64_t object_store_id = 2; |
| 84 | 84 |
| 85 StrictMock<MockWebIDBCallbacks> callbacks; | 85 StrictMock<MockWebIDBCallbacks> callbacks; |
| 86 EXPECT_CALL(callbacks, onError(_)).Times(1); | 86 EXPECT_CALL(callbacks, onError(_)).Times(1); |
| 87 | 87 |
| 88 WebIDBDatabaseImpl database_impl(nullptr, | 88 WebIDBDatabaseImpl database_impl(nullptr, |
| 89 base::ThreadTaskRunnerHandle::Get()); | 89 base::ThreadTaskRunnerHandle::Get()); |
| 90 database_impl.max_put_value_size_ = kMaxValueSizeForTesting; | 90 database_impl.max_put_value_size_ = kMaxValueSizeForTesting; |
| 91 database_impl.put(transaction_id, object_store_id, value, web_blob_info, key, | 91 database_impl.put(transaction_id, object_store_id, value, web_blob_info, key, |
| 92 blink::WebIDBPutModeAddOrUpdate, &callbacks, | 92 blink::WebIDBPutModeAddOrUpdate, &callbacks, |
| 93 WebVector<long long>(), WebVector<WebVector<WebIDBKey>>()); | 93 WebVector<long long>(), WebVector<WebVector<WebIDBKey>>()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace content | 96 } // namespace content |
| OLD | NEW |