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 "content/child/indexed_db/indexed_db_dispatcher.h" | 5 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/threading/thread_local.h" | 12 #include "base/threading/thread_local.h" |
13 #include "content/child/indexed_db/indexed_db_key_builders.h" | 13 #include "content/child/indexed_db/indexed_db_key_builders.h" |
14 #include "content/child/indexed_db/webidbcursor_impl.h" | 14 #include "content/child/indexed_db/webidbcursor_impl.h" |
15 #include "content/child/indexed_db/webidbdatabase_impl.h" | 15 #include "content/child/indexed_db/webidbdatabase_impl.h" |
16 #include "content/child/thread_safe_sender.h" | 16 #include "content/child/thread_safe_sender.h" |
17 #include "content/common/indexed_db/indexed_db_constants.h" | 17 #include "content/common/indexed_db/indexed_db_constants.h" |
18 #include "content/common/indexed_db/indexed_db_messages.h" | 18 #include "content/common/indexed_db/indexed_db_messages.h" |
19 #include "ipc/ipc_channel.h" | 19 #include "ipc/ipc_channel.h" |
20 #include "third_party/WebKit/public/platform/WebIDBDatabaseCallbacks.h" | 20 #include "third_party/WebKit/public/platform/WebIDBDatabaseCallbacks.h" |
21 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h" | 21 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h" |
22 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" | 22 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" |
23 | 23 |
24 using blink::WebBlobInfo; | |
24 using blink::WebData; | 25 using blink::WebData; |
25 using blink::WebIDBCallbacks; | 26 using blink::WebIDBCallbacks; |
26 using blink::WebIDBCursor; | 27 using blink::WebIDBCursor; |
27 using blink::WebIDBDatabase; | 28 using blink::WebIDBDatabase; |
28 using blink::WebIDBDatabaseCallbacks; | 29 using blink::WebIDBDatabaseCallbacks; |
29 using blink::WebIDBDatabaseError; | 30 using blink::WebIDBDatabaseError; |
30 using blink::WebIDBKey; | 31 using blink::WebIDBKey; |
31 using blink::WebIDBMetadata; | 32 using blink::WebIDBMetadata; |
32 using blink::WebString; | 33 using blink::WebString; |
33 using blink::WebVector; | 34 using blink::WebVector; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 params.key_range = key_range; | 318 params.key_range = key_range; |
318 params.key_only = key_only; | 319 params.key_only = key_only; |
319 Send(new IndexedDBHostMsg_DatabaseGet(params)); | 320 Send(new IndexedDBHostMsg_DatabaseGet(params)); |
320 } | 321 } |
321 | 322 |
322 void IndexedDBDispatcher::RequestIDBDatabasePut( | 323 void IndexedDBDispatcher::RequestIDBDatabasePut( |
323 int32 ipc_database_id, | 324 int32 ipc_database_id, |
324 int64 transaction_id, | 325 int64 transaction_id, |
325 int64 object_store_id, | 326 int64 object_store_id, |
326 const WebData& value, | 327 const WebData& value, |
328 const blink::WebVector<WebBlobInfo>& web_blob_info, | |
327 const IndexedDBKey& key, | 329 const IndexedDBKey& key, |
328 WebIDBDatabase::PutMode put_mode, | 330 WebIDBDatabase::PutMode put_mode, |
329 WebIDBCallbacks* callbacks, | 331 WebIDBCallbacks* callbacks, |
330 const WebVector<long long>& index_ids, | 332 const WebVector<long long>& index_ids, |
331 const WebVector<WebVector<WebIDBKey> >& index_keys) { | 333 const WebVector<WebVector<WebIDBKey> >& index_keys) { |
332 | 334 |
333 if (value.size() + key.size_estimate() > kMaxIDBValueSizeInBytes) { | 335 if (value.size() + key.size_estimate() > kMaxIDBValueSizeInBytes) { |
334 callbacks->onError(WebIDBDatabaseError( | 336 callbacks->onError(WebIDBDatabaseError( |
335 blink::WebIDBDatabaseExceptionUnknownError, | 337 blink::WebIDBDatabaseExceptionUnknownError, |
336 WebString::fromUTF8(base::StringPrintf( | 338 WebString::fromUTF8(base::StringPrintf( |
(...skipping 19 matching lines...) Expand all Loading... | |
356 params.index_keys.resize(index_ids.size()); | 358 params.index_keys.resize(index_ids.size()); |
357 for (size_t i = 0, len = index_ids.size(); i < len; ++i) { | 359 for (size_t i = 0, len = index_ids.size(); i < len; ++i) { |
358 params.index_keys[i].first = index_ids[i]; | 360 params.index_keys[i].first = index_ids[i]; |
359 params.index_keys[i].second.resize(index_keys[i].size()); | 361 params.index_keys[i].second.resize(index_keys[i].size()); |
360 for (size_t j = 0; j < index_keys[i].size(); ++j) { | 362 for (size_t j = 0; j < index_keys[i].size(); ++j) { |
361 params.index_keys[i].second[j] = | 363 params.index_keys[i].second[j] = |
362 IndexedDBKey(IndexedDBKeyBuilder::Build(index_keys[i][j])); | 364 IndexedDBKey(IndexedDBKeyBuilder::Build(index_keys[i][j])); |
363 } | 365 } |
364 } | 366 } |
365 | 367 |
368 params.blob_or_file_info.resize(web_blob_info.size()); | |
369 for (size_t i = 0; i < web_blob_info.size(); ++i) { | |
370 const WebBlobInfo& info = web_blob_info[i]; | |
371 params.blob_or_file_info[i].is_file = info.isFile(); | |
jsbell
2014/04/09 20:11:08
Would a local reference to params.blob_or_file_inf
ericu
2014/04/09 21:14:47
Yeah, a little. Done.
| |
372 if (info.isFile()) { | |
373 params.blob_or_file_info[i].file_path = info.filePath(); | |
374 params.blob_or_file_info[i].file_name = info.fileName(); | |
375 } else { | |
376 params.blob_or_file_info[i].size = info.size(); | |
377 } | |
378 params.blob_or_file_info[i].uuid = info.uuid().latin1(); | |
379 DCHECK(params.blob_or_file_info[i].uuid.size()); | |
380 params.blob_or_file_info[i].mime_type = info.type(); | |
381 } | |
382 | |
366 Send(new IndexedDBHostMsg_DatabasePut(params)); | 383 Send(new IndexedDBHostMsg_DatabasePut(params)); |
367 } | 384 } |
368 | 385 |
369 void IndexedDBDispatcher::RequestIDBDatabaseOpenCursor( | 386 void IndexedDBDispatcher::RequestIDBDatabaseOpenCursor( |
370 int32 ipc_database_id, | 387 int32 ipc_database_id, |
371 int64 transaction_id, | 388 int64 transaction_id, |
372 int64 object_store_id, | 389 int64 object_store_id, |
373 int64 index_id, | 390 int64 index_id, |
374 const IndexedDBKeyRange& key_range, | 391 const IndexedDBKeyRange& key_range, |
375 WebIDBCursor::Direction direction, | 392 WebIDBCursor::Direction direction, |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 typedef std::map<int32, WebIDBCursorImpl*>::iterator Iterator; | 745 typedef std::map<int32, WebIDBCursorImpl*>::iterator Iterator; |
729 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { | 746 for (Iterator i = cursors_.begin(); i != cursors_.end(); ++i) { |
730 if (i->first == ipc_exception_cursor_id || | 747 if (i->first == ipc_exception_cursor_id || |
731 i->second->transaction_id() != transaction_id) | 748 i->second->transaction_id() != transaction_id) |
732 continue; | 749 continue; |
733 i->second->ResetPrefetchCache(); | 750 i->second->ResetPrefetchCache(); |
734 } | 751 } |
735 } | 752 } |
736 | 753 |
737 } // namespace content | 754 } // namespace content |
OLD | NEW |