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

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

Issue 2586483002: Use explicit WebString <-> string16 conversion methods in storage API files (Closed)
Patch Set: '' Created 4 years 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
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 "content/child/indexed_db/webidbdatabase_impl.h" 5 #include "content/child/indexed_db/webidbdatabase_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "content/child/indexed_db/indexed_db_callbacks_impl.h" 14 #include "content/child/indexed_db/indexed_db_callbacks_impl.h"
15 #include "content/child/indexed_db/indexed_db_dispatcher.h" 15 #include "content/child/indexed_db/indexed_db_dispatcher.h"
16 #include "content/child/indexed_db/indexed_db_key_builders.h" 16 #include "content/child/indexed_db/indexed_db_key_builders.h"
17 #include "mojo/public/cpp/bindings/strong_associated_binding.h" 17 #include "mojo/public/cpp/bindings/strong_associated_binding.h"
18 #include "third_party/WebKit/public/platform/FilePathConversion.h"
18 #include "third_party/WebKit/public/platform/WebBlobInfo.h" 19 #include "third_party/WebKit/public/platform/WebBlobInfo.h"
19 #include "third_party/WebKit/public/platform/WebString.h" 20 #include "third_party/WebKit/public/platform/WebString.h"
20 #include "third_party/WebKit/public/platform/WebVector.h" 21 #include "third_party/WebKit/public/platform/WebVector.h"
21 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr or.h" 22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr or.h"
22 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h" 23 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseExc eption.h"
23 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyPath.h" 24 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBKeyPath.h"
24 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBMetadata.h" 25 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBMetadata.h"
25 26
26 using blink::WebBlobInfo; 27 using blink::WebBlobInfo;
27 using blink::WebIDBCallbacks; 28 using blink::WebIDBCallbacks;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 173 }
173 174
174 void WebIDBDatabaseImpl::createObjectStore(long long transaction_id, 175 void WebIDBDatabaseImpl::createObjectStore(long long transaction_id,
175 long long object_store_id, 176 long long object_store_id,
176 const WebString& name, 177 const WebString& name,
177 const WebIDBKeyPath& key_path, 178 const WebIDBKeyPath& key_path,
178 bool auto_increment) { 179 bool auto_increment) {
179 io_runner_->PostTask( 180 io_runner_->PostTask(
180 FROM_HERE, 181 FROM_HERE,
181 base::Bind(&IOThreadHelper::CreateObjectStore, base::Unretained(helper_), 182 base::Bind(&IOThreadHelper::CreateObjectStore, base::Unretained(helper_),
182 transaction_id, object_store_id, base::string16(name), 183 transaction_id, object_store_id, name.utf16(),
183 IndexedDBKeyPathBuilder::Build(key_path), auto_increment)); 184 IndexedDBKeyPathBuilder::Build(key_path), auto_increment));
184 } 185 }
185 186
186 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id, 187 void WebIDBDatabaseImpl::deleteObjectStore(long long transaction_id,
187 long long object_store_id) { 188 long long object_store_id) {
188 io_runner_->PostTask(FROM_HERE, base::Bind(&IOThreadHelper::DeleteObjectStore, 189 io_runner_->PostTask(FROM_HERE, base::Bind(&IOThreadHelper::DeleteObjectStore,
189 base::Unretained(helper_), 190 base::Unretained(helper_),
190 transaction_id, object_store_id)); 191 transaction_id, object_store_id));
191 } 192 }
192 193
193 void WebIDBDatabaseImpl::renameObjectStore(long long transaction_id, 194 void WebIDBDatabaseImpl::renameObjectStore(long long transaction_id,
194 long long object_store_id, 195 long long object_store_id,
195 const blink::WebString& new_name) { 196 const blink::WebString& new_name) {
196 io_runner_->PostTask( 197 io_runner_->PostTask(
197 FROM_HERE, 198 FROM_HERE,
198 base::Bind(&IOThreadHelper::RenameObjectStore, base::Unretained(helper_), 199 base::Bind(&IOThreadHelper::RenameObjectStore, base::Unretained(helper_),
199 transaction_id, object_store_id, base::string16(new_name))); 200 transaction_id, object_store_id, new_name.utf16()));
200 } 201 }
201 202
202 void WebIDBDatabaseImpl::createTransaction( 203 void WebIDBDatabaseImpl::createTransaction(
203 long long transaction_id, 204 long long transaction_id,
204 const WebVector<long long>& object_store_ids, 205 const WebVector<long long>& object_store_ids,
205 blink::WebIDBTransactionMode mode) { 206 blink::WebIDBTransactionMode mode) {
206 io_runner_->PostTask( 207 io_runner_->PostTask(
207 FROM_HERE, 208 FROM_HERE,
208 base::Bind(&IOThreadHelper::CreateTransaction, base::Unretained(helper_), 209 base::Bind(&IOThreadHelper::CreateTransaction, base::Unretained(helper_),
209 transaction_id, std::vector<int64_t>(object_store_ids.begin(), 210 transaction_id, std::vector<int64_t>(object_store_ids.begin(),
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 IndexedDBDispatcher::ThreadSpecificInstance()->ResetCursorPrefetchCaches( 312 IndexedDBDispatcher::ThreadSpecificInstance()->ResetCursorPrefetchCaches(
312 transaction_id, nullptr); 313 transaction_id, nullptr);
313 314
314 auto mojo_value = indexed_db::mojom::Value::New(); 315 auto mojo_value = indexed_db::mojom::Value::New();
315 mojo_value->bits.assign(value.data(), value.data() + value.size()); 316 mojo_value->bits.assign(value.data(), value.data() + value.size());
316 mojo_value->blob_or_file_info.reserve(web_blob_info.size()); 317 mojo_value->blob_or_file_info.reserve(web_blob_info.size());
317 for (const WebBlobInfo& info : web_blob_info) { 318 for (const WebBlobInfo& info : web_blob_info) {
318 auto blob_info = indexed_db::mojom::BlobInfo::New(); 319 auto blob_info = indexed_db::mojom::BlobInfo::New();
319 if (info.isFile()) { 320 if (info.isFile()) {
320 blob_info->file = indexed_db::mojom::FileInfo::New(); 321 blob_info->file = indexed_db::mojom::FileInfo::New();
321 blob_info->file->path = 322 blob_info->file->path = blink::WebStringToFilePath(info.filePath());
322 base::FilePath::FromUTF8Unsafe(info.filePath().utf8()); 323 blob_info->file->name = info.fileName().utf16();
323 blob_info->file->name = info.fileName();
324 blob_info->file->last_modified = 324 blob_info->file->last_modified =
325 base::Time::FromDoubleT(info.lastModified()); 325 base::Time::FromDoubleT(info.lastModified());
326 } 326 }
327 blob_info->size = info.size(); 327 blob_info->size = info.size();
328 blob_info->uuid = info.uuid().latin1(); 328 blob_info->uuid = info.uuid().latin1();
329 DCHECK(blob_info->uuid.size()); 329 DCHECK(blob_info->uuid.size());
330 blob_info->mime_type = info.type(); 330 blob_info->mime_type = info.type().utf16();
331 mojo_value->blob_or_file_info.push_back(std::move(blob_info)); 331 mojo_value->blob_or_file_info.push_back(std::move(blob_info));
332 } 332 }
333 333
334 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( 334 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>(
335 base::WrapUnique(callbacks), transaction_id, nullptr, io_runner_); 335 base::WrapUnique(callbacks), transaction_id, nullptr, io_runner_);
336 io_runner_->PostTask( 336 io_runner_->PostTask(
337 FROM_HERE, 337 FROM_HERE,
338 base::Bind(&IOThreadHelper::Put, base::Unretained(helper_), 338 base::Bind(&IOThreadHelper::Put, base::Unretained(helper_),
339 transaction_id, object_store_id, base::Passed(&mojo_value), 339 transaction_id, object_store_id, base::Passed(&mojo_value),
340 key, put_mode, base::Passed(&callbacks_impl), 340 key, put_mode, base::Passed(&callbacks_impl),
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 void WebIDBDatabaseImpl::createIndex(long long transaction_id, 439 void WebIDBDatabaseImpl::createIndex(long long transaction_id,
440 long long object_store_id, 440 long long object_store_id,
441 long long index_id, 441 long long index_id,
442 const WebString& name, 442 const WebString& name,
443 const WebIDBKeyPath& key_path, 443 const WebIDBKeyPath& key_path,
444 bool unique, 444 bool unique,
445 bool multi_entry) { 445 bool multi_entry) {
446 io_runner_->PostTask( 446 io_runner_->PostTask(
447 FROM_HERE, 447 FROM_HERE,
448 base::Bind(&IOThreadHelper::CreateIndex, base::Unretained(helper_), 448 base::Bind(&IOThreadHelper::CreateIndex, base::Unretained(helper_),
449 transaction_id, object_store_id, index_id, 449 transaction_id, object_store_id, index_id, name.utf16(),
450 base::string16(name), IndexedDBKeyPathBuilder::Build(key_path), 450 IndexedDBKeyPathBuilder::Build(key_path), unique,
451 unique, multi_entry)); 451 multi_entry));
452 } 452 }
453 453
454 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id, 454 void WebIDBDatabaseImpl::deleteIndex(long long transaction_id,
455 long long object_store_id, 455 long long object_store_id,
456 long long index_id) { 456 long long index_id) {
457 io_runner_->PostTask( 457 io_runner_->PostTask(
458 FROM_HERE, 458 FROM_HERE,
459 base::Bind(&IOThreadHelper::DeleteIndex, base::Unretained(helper_), 459 base::Bind(&IOThreadHelper::DeleteIndex, base::Unretained(helper_),
460 transaction_id, object_store_id, index_id)); 460 transaction_id, object_store_id, index_id));
461 } 461 }
462 462
463 void WebIDBDatabaseImpl::renameIndex(long long transaction_id, 463 void WebIDBDatabaseImpl::renameIndex(long long transaction_id,
464 long long object_store_id, 464 long long object_store_id,
465 long long index_id, 465 long long index_id,
466 const WebString& new_name) { 466 const WebString& new_name) {
467 io_runner_->PostTask( 467 io_runner_->PostTask(
468 FROM_HERE, 468 FROM_HERE,
469 base::Bind(&IOThreadHelper::RenameIndex, base::Unretained(helper_), 469 base::Bind(&IOThreadHelper::RenameIndex, base::Unretained(helper_),
470 transaction_id, object_store_id, index_id, new_name)); 470 transaction_id, object_store_id, index_id, new_name.utf16()));
471 } 471 }
472 472
473 void WebIDBDatabaseImpl::abort(long long transaction_id) { 473 void WebIDBDatabaseImpl::abort(long long transaction_id) {
474 io_runner_->PostTask( 474 io_runner_->PostTask(
475 FROM_HERE, base::Bind(&IOThreadHelper::Abort, base::Unretained(helper_), 475 FROM_HERE, base::Bind(&IOThreadHelper::Abort, base::Unretained(helper_),
476 transaction_id)); 476 transaction_id));
477 } 477 }
478 478
479 void WebIDBDatabaseImpl::commit(long long transaction_id) { 479 void WebIDBDatabaseImpl::commit(long long transaction_id) {
480 io_runner_->PostTask( 480 io_runner_->PostTask(
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 std::unique_ptr<IndexedDBCallbacksImpl> callbacks) { 691 std::unique_ptr<IndexedDBCallbacksImpl> callbacks) {
692 CallbacksAssociatedPtrInfo ptr_info; 692 CallbacksAssociatedPtrInfo ptr_info;
693 indexed_db::mojom::CallbacksAssociatedRequest request; 693 indexed_db::mojom::CallbacksAssociatedRequest request;
694 database_.associated_group()->CreateAssociatedInterface( 694 database_.associated_group()->CreateAssociatedInterface(
695 mojo::AssociatedGroup::WILL_PASS_PTR, &ptr_info, &request); 695 mojo::AssociatedGroup::WILL_PASS_PTR, &ptr_info, &request);
696 mojo::MakeStrongAssociatedBinding(std::move(callbacks), std::move(request)); 696 mojo::MakeStrongAssociatedBinding(std::move(callbacks), std::move(request));
697 return ptr_info; 697 return ptr_info;
698 } 698 }
699 699
700 } // namespace content 700 } // namespace content
OLDNEW
« no previous file with comments | « content/child/indexed_db/indexed_db_key_builders.cc ('k') | content/child/indexed_db/webidbfactory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698