Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: content/child/indexed_db/indexed_db_dispatcher_unittest.cc

Issue 229483003: WebBlobInfo plumbing for WebIDBDatabaseImpl::put. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rolled in Josh's feedback. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop/message_loop_proxy.h" 6 #include "base/message_loop/message_loop_proxy.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "content/child/indexed_db/indexed_db_dispatcher.h" 8 #include "content/child/indexed_db/indexed_db_dispatcher.h"
9 #include "content/child/indexed_db/webidbcursor_impl.h" 9 #include "content/child/indexed_db/webidbcursor_impl.h"
10 #include "content/child/thread_safe_sender.h" 10 #include "content/child/thread_safe_sender.h"
11 #include "content/common/indexed_db/indexed_db_key.h" 11 #include "content/common/indexed_db/indexed_db_key.h"
12 #include "content/common/indexed_db/indexed_db_key_range.h" 12 #include "content/common/indexed_db/indexed_db_key_range.h"
13 #include "content/common/indexed_db/indexed_db_messages.h" 13 #include "content/common/indexed_db/indexed_db_messages.h"
14 #include "ipc/ipc_sync_message_filter.h" 14 #include "ipc/ipc_sync_message_filter.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/WebKit/public/platform/WebBlobInfo.h"
16 #include "third_party/WebKit/public/platform/WebData.h" 17 #include "third_party/WebKit/public/platform/WebData.h"
17 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h" 18 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h"
18 19
20 using blink::WebBlobInfo;
19 using blink::WebData; 21 using blink::WebData;
20 using blink::WebIDBCallbacks; 22 using blink::WebIDBCallbacks;
21 using blink::WebIDBCursor; 23 using blink::WebIDBCursor;
22 using blink::WebIDBDatabase; 24 using blink::WebIDBDatabase;
23 using blink::WebIDBDatabaseError; 25 using blink::WebIDBDatabaseError;
24 using blink::WebIDBKey; 26 using blink::WebIDBKey;
25 using blink::WebVector; 27 using blink::WebVector;
26 28
27 namespace content { 29 namespace content {
28 namespace { 30 namespace {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; 66 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
65 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 67 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
66 68
67 private: 69 private:
68 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcherTest); 70 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcherTest);
69 }; 71 };
70 72
71 TEST_F(IndexedDBDispatcherTest, ValueSizeTest) { 73 TEST_F(IndexedDBDispatcherTest, ValueSizeTest) {
72 const std::vector<char> data(kMaxIDBValueSizeInBytes + 1); 74 const std::vector<char> data(kMaxIDBValueSizeInBytes + 1);
73 const WebData value(&data.front(), data.size()); 75 const WebData value(&data.front(), data.size());
76 const WebVector<WebBlobInfo> web_blob_info;
74 const int32 ipc_dummy_id = -1; 77 const int32 ipc_dummy_id = -1;
75 const int64 transaction_id = 1; 78 const int64 transaction_id = 1;
76 const int64 object_store_id = 2; 79 const int64 object_store_id = 2;
77 80
78 MockCallbacks callbacks; 81 MockCallbacks callbacks;
79 IndexedDBDispatcher dispatcher(thread_safe_sender_.get()); 82 IndexedDBDispatcher dispatcher(thread_safe_sender_.get());
80 IndexedDBKey key(0, blink::WebIDBKeyTypeNumber); 83 IndexedDBKey key(0, blink::WebIDBKeyTypeNumber);
81 dispatcher.RequestIDBDatabasePut(ipc_dummy_id, 84 dispatcher.RequestIDBDatabasePut(ipc_dummy_id,
82 transaction_id, 85 transaction_id,
83 object_store_id, 86 object_store_id,
84 value, 87 value,
88 web_blob_info,
85 key, 89 key,
86 WebIDBDatabase::AddOrUpdate, 90 WebIDBDatabase::AddOrUpdate,
87 &callbacks, 91 &callbacks,
88 WebVector<long long>(), 92 WebVector<long long>(),
89 WebVector<WebVector<WebIDBKey> >()); 93 WebVector<WebVector<WebIDBKey> >());
90 94
91 EXPECT_TRUE(callbacks.error_seen()); 95 EXPECT_TRUE(callbacks.error_seen());
92 } 96 }
93 97
94 TEST_F(IndexedDBDispatcherTest, KeyAndValueSizeTest) { 98 TEST_F(IndexedDBDispatcherTest, KeyAndValueSizeTest) {
95 const size_t kKeySize = 1024 * 1024; 99 const size_t kKeySize = 1024 * 1024;
96 100
97 const std::vector<char> data(kMaxIDBValueSizeInBytes - kKeySize); 101 const std::vector<char> data(kMaxIDBValueSizeInBytes - kKeySize);
98 const WebData value(&data.front(), data.size()); 102 const WebData value(&data.front(), data.size());
103 const WebVector<WebBlobInfo> web_blob_info;
99 const IndexedDBKey key( 104 const IndexedDBKey key(
100 base::string16(kKeySize / sizeof(base::string16::value_type), 'x')); 105 base::string16(kKeySize / sizeof(base::string16::value_type), 'x'));
101 106
102 const int32 ipc_dummy_id = -1; 107 const int32 ipc_dummy_id = -1;
103 const int64 transaction_id = 1; 108 const int64 transaction_id = 1;
104 const int64 object_store_id = 2; 109 const int64 object_store_id = 2;
105 110
106 MockCallbacks callbacks; 111 MockCallbacks callbacks;
107 IndexedDBDispatcher dispatcher(thread_safe_sender_.get()); 112 IndexedDBDispatcher dispatcher(thread_safe_sender_.get());
108 dispatcher.RequestIDBDatabasePut(ipc_dummy_id, 113 dispatcher.RequestIDBDatabasePut(ipc_dummy_id,
109 transaction_id, 114 transaction_id,
110 object_store_id, 115 object_store_id,
111 value, 116 value,
117 web_blob_info,
112 key, 118 key,
113 WebIDBDatabase::AddOrUpdate, 119 WebIDBDatabase::AddOrUpdate,
114 &callbacks, 120 &callbacks,
115 WebVector<long long>(), 121 WebVector<long long>(),
116 WebVector<WebVector<WebIDBKey> >()); 122 WebVector<WebVector<WebIDBKey> >());
117 123
118 EXPECT_TRUE(callbacks.error_seen()); 124 EXPECT_TRUE(callbacks.error_seen());
119 } 125 }
120 126
121 namespace { 127 namespace {
122 128
123 class CursorCallbacks : public WebIDBCallbacks { 129 class CursorCallbacks : public WebIDBCallbacks {
124 public: 130 public:
125 CursorCallbacks(scoped_ptr<WebIDBCursor>* cursor) : cursor_(cursor) {} 131 CursorCallbacks(scoped_ptr<WebIDBCursor>* cursor) : cursor_(cursor) {}
126 132
127 virtual void onSuccess(const WebData&) {} 133 virtual void onSuccess(const WebData&) OVERRIDE {}
128 virtual void onSuccess(WebIDBCursor* cursor, 134 virtual void onSuccess(WebIDBCursor* cursor,
129 const WebIDBKey& key, 135 const WebIDBKey& key,
130 const WebIDBKey& primaryKey, 136 const WebIDBKey& primaryKey,
131 const WebData& value) { 137 const WebData& value) OVERRIDE {
132 cursor_->reset(cursor); 138 cursor_->reset(cursor);
133 } 139 }
134 140
135 private: 141 private:
136 scoped_ptr<WebIDBCursor>* cursor_; 142 scoped_ptr<WebIDBCursor>* cursor_;
137 }; 143 };
138 144
139 } // namespace 145 } // namespace
140 146
141 TEST_F(IndexedDBDispatcherTest, CursorTransactionId) { 147 TEST_F(IndexedDBDispatcherTest, CursorTransactionId) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 cursor1_transaction_id); 323 cursor1_transaction_id);
318 324
319 EXPECT_EQ(2, cursor1->reset_count()); 325 EXPECT_EQ(2, cursor1->reset_count());
320 EXPECT_EQ(0, cursor2->reset_count()); 326 EXPECT_EQ(0, cursor2->reset_count());
321 327
322 cursor1.reset(); 328 cursor1.reset();
323 cursor2.reset(); 329 cursor2.reset();
324 } 330 }
325 331
326 } // namespace content 332 } // namespace content
OLDNEW
« no previous file with comments | « content/child/indexed_db/indexed_db_dispatcher.cc ('k') | content/child/indexed_db/webidbdatabase_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698