| 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/webidbfactory_impl.h" | 5 #include "content/child/indexed_db/webidbfactory_impl.h" |
| 6 | 6 |
| 7 #include "content/child/child_thread_impl.h" | 7 #include "content/child/child_thread_impl.h" |
| 8 #include "content/child/indexed_db/indexed_db_callbacks_impl.h" | 8 #include "content/child/indexed_db/indexed_db_callbacks_impl.h" |
| 9 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" | 9 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" |
| 10 #include "content/child/storage_util.h" | 10 #include "content/child/storage_util.h" |
| 11 #include "content/child/thread_safe_sender.h" | |
| 12 #include "content/public/child/worker_thread.h" | 11 #include "content/public/child/worker_thread.h" |
| 13 #include "ipc/ipc_sync_channel.h" | 12 #include "ipc/ipc_sync_channel.h" |
| 14 #include "mojo/public/cpp/bindings/strong_associated_binding.h" | 13 #include "mojo/public/cpp/bindings/strong_associated_binding.h" |
| 15 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 14 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 16 #include "third_party/WebKit/public/platform/WebString.h" | 15 #include "third_party/WebKit/public/platform/WebString.h" |
| 17 | 16 |
| 18 using blink::WebIDBCallbacks; | 17 using blink::WebIDBCallbacks; |
| 19 using blink::WebIDBDatabase; | 18 using blink::WebIDBDatabase; |
| 20 using blink::WebIDBDatabaseCallbacks; | 19 using blink::WebIDBDatabaseCallbacks; |
| 21 using blink::WebSecurityOrigin; | 20 using blink::WebSecurityOrigin; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 52 | 51 |
| 53 private: | 52 private: |
| 54 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; | 53 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; |
| 55 FactoryAssociatedPtr service_; | 54 FactoryAssociatedPtr service_; |
| 56 | 55 |
| 57 DISALLOW_COPY_AND_ASSIGN(IOThreadHelper); | 56 DISALLOW_COPY_AND_ASSIGN(IOThreadHelper); |
| 58 }; | 57 }; |
| 59 | 58 |
| 60 WebIDBFactoryImpl::WebIDBFactoryImpl( | 59 WebIDBFactoryImpl::WebIDBFactoryImpl( |
| 61 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, | 60 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, |
| 62 scoped_refptr<ThreadSafeSender> thread_safe_sender, | |
| 63 scoped_refptr<base::SingleThreadTaskRunner> io_runner) | 61 scoped_refptr<base::SingleThreadTaskRunner> io_runner) |
| 64 : io_helper_(new IOThreadHelper(std::move(sync_message_filter))), | 62 : io_helper_(new IOThreadHelper(std::move(sync_message_filter))), |
| 65 thread_safe_sender_(std::move(thread_safe_sender)), | |
| 66 io_runner_(std::move(io_runner)) {} | 63 io_runner_(std::move(io_runner)) {} |
| 67 | 64 |
| 68 WebIDBFactoryImpl::~WebIDBFactoryImpl() { | 65 WebIDBFactoryImpl::~WebIDBFactoryImpl() { |
| 69 io_runner_->DeleteSoon(FROM_HERE, io_helper_); | 66 io_runner_->DeleteSoon(FROM_HERE, io_helper_); |
| 70 } | 67 } |
| 71 | 68 |
| 72 void WebIDBFactoryImpl::getDatabaseNames(WebIDBCallbacks* callbacks, | 69 void WebIDBFactoryImpl::getDatabaseNames(WebIDBCallbacks* callbacks, |
| 73 const WebSecurityOrigin& origin) { | 70 const WebSecurityOrigin& origin) { |
| 74 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( | 71 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( |
| 75 base::WrapUnique(callbacks), IndexedDBCallbacksImpl::kNoTransaction, | 72 base::WrapUnique(callbacks), IndexedDBCallbacksImpl::kNoTransaction, |
| 76 io_runner_, thread_safe_sender_); | 73 nullptr, io_runner_); |
| 77 io_runner_->PostTask(FROM_HERE, base::Bind(&IOThreadHelper::GetDatabaseNames, | 74 io_runner_->PostTask(FROM_HERE, base::Bind(&IOThreadHelper::GetDatabaseNames, |
| 78 base::Unretained(io_helper_), | 75 base::Unretained(io_helper_), |
| 79 base::Passed(&callbacks_impl), | 76 base::Passed(&callbacks_impl), |
| 80 url::Origin(origin))); | 77 url::Origin(origin))); |
| 81 } | 78 } |
| 82 | 79 |
| 83 void WebIDBFactoryImpl::open(const WebString& name, | 80 void WebIDBFactoryImpl::open(const WebString& name, |
| 84 long long version, | 81 long long version, |
| 85 long long transaction_id, | 82 long long transaction_id, |
| 86 WebIDBCallbacks* callbacks, | 83 WebIDBCallbacks* callbacks, |
| 87 WebIDBDatabaseCallbacks* database_callbacks, | 84 WebIDBDatabaseCallbacks* database_callbacks, |
| 88 const WebSecurityOrigin& origin) { | 85 const WebSecurityOrigin& origin) { |
| 89 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( | 86 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( |
| 90 base::WrapUnique(callbacks), transaction_id, io_runner_, | 87 base::WrapUnique(callbacks), transaction_id, nullptr, io_runner_); |
| 91 thread_safe_sender_); | |
| 92 auto database_callbacks_impl = | 88 auto database_callbacks_impl = |
| 93 base::MakeUnique<IndexedDBDatabaseCallbacksImpl>( | 89 base::MakeUnique<IndexedDBDatabaseCallbacksImpl>( |
| 94 base::WrapUnique(database_callbacks), thread_safe_sender_); | 90 base::WrapUnique(database_callbacks)); |
| 95 io_runner_->PostTask( | 91 io_runner_->PostTask( |
| 96 FROM_HERE, | 92 FROM_HERE, |
| 97 base::Bind(&IOThreadHelper::Open, base::Unretained(io_helper_), | 93 base::Bind(&IOThreadHelper::Open, base::Unretained(io_helper_), |
| 98 WorkerThread::GetCurrentId(), base::string16(name), version, | 94 WorkerThread::GetCurrentId(), base::string16(name), version, |
| 99 transaction_id, base::Passed(&callbacks_impl), | 95 transaction_id, base::Passed(&callbacks_impl), |
| 100 base::Passed(&database_callbacks_impl), url::Origin(origin))); | 96 base::Passed(&database_callbacks_impl), url::Origin(origin))); |
| 101 } | 97 } |
| 102 | 98 |
| 103 void WebIDBFactoryImpl::deleteDatabase(const WebString& name, | 99 void WebIDBFactoryImpl::deleteDatabase(const WebString& name, |
| 104 WebIDBCallbacks* callbacks, | 100 WebIDBCallbacks* callbacks, |
| 105 const WebSecurityOrigin& origin) { | 101 const WebSecurityOrigin& origin) { |
| 106 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( | 102 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( |
| 107 base::WrapUnique(callbacks), IndexedDBCallbacksImpl::kNoTransaction, | 103 base::WrapUnique(callbacks), IndexedDBCallbacksImpl::kNoTransaction, |
| 108 io_runner_, thread_safe_sender_); | 104 nullptr, io_runner_); |
| 109 io_runner_->PostTask( | 105 io_runner_->PostTask( |
| 110 FROM_HERE, | 106 FROM_HERE, |
| 111 base::Bind(&IOThreadHelper::DeleteDatabase, base::Unretained(io_helper_), | 107 base::Bind(&IOThreadHelper::DeleteDatabase, base::Unretained(io_helper_), |
| 112 base::string16(name), base::Passed(&callbacks_impl), | 108 base::string16(name), base::Passed(&callbacks_impl), |
| 113 url::Origin(origin))); | 109 url::Origin(origin))); |
| 114 } | 110 } |
| 115 | 111 |
| 116 WebIDBFactoryImpl::IOThreadHelper::IOThreadHelper( | 112 WebIDBFactoryImpl::IOThreadHelper::IOThreadHelper( |
| 117 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter) | 113 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter) |
| 118 : sync_message_filter_(std::move(sync_message_filter)) {} | 114 : sync_message_filter_(std::move(sync_message_filter)) {} |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 164 |
| 169 void WebIDBFactoryImpl::IOThreadHelper::DeleteDatabase( | 165 void WebIDBFactoryImpl::IOThreadHelper::DeleteDatabase( |
| 170 const base::string16& name, | 166 const base::string16& name, |
| 171 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, | 167 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, |
| 172 const url::Origin& origin) { | 168 const url::Origin& origin) { |
| 173 GetService()->DeleteDatabase(GetCallbacksProxy(std::move(callbacks)), origin, | 169 GetService()->DeleteDatabase(GetCallbacksProxy(std::move(callbacks)), origin, |
| 174 name); | 170 name); |
| 175 } | 171 } |
| 176 | 172 |
| 177 } // namespace content | 173 } // namespace content |
| OLD | NEW |