| 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" | |
| 8 #include "content/child/indexed_db/indexed_db_callbacks_impl.h" | 7 #include "content/child/indexed_db/indexed_db_callbacks_impl.h" |
| 9 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" | 8 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" |
| 10 #include "content/child/storage_util.h" | 9 #include "content/child/storage_util.h" |
| 11 #include "content/public/child/worker_thread.h" | |
| 12 #include "ipc/ipc_sync_channel.h" | 10 #include "ipc/ipc_sync_channel.h" |
| 13 #include "mojo/public/cpp/bindings/strong_associated_binding.h" | 11 #include "mojo/public/cpp/bindings/strong_associated_binding.h" |
| 14 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 12 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 15 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
| 16 | 14 |
| 17 using blink::WebIDBCallbacks; | 15 using blink::WebIDBCallbacks; |
| 18 using blink::WebIDBDatabase; | 16 using blink::WebIDBDatabase; |
| 19 using blink::WebIDBDatabaseCallbacks; | 17 using blink::WebIDBDatabaseCallbacks; |
| 20 using blink::WebSecurityOrigin; | 18 using blink::WebSecurityOrigin; |
| 21 using blink::WebString; | 19 using blink::WebString; |
| 22 using indexed_db::mojom::CallbacksAssociatedPtrInfo; | 20 using indexed_db::mojom::CallbacksAssociatedPtrInfo; |
| 23 using indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo; | 21 using indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo; |
| 24 using indexed_db::mojom::FactoryAssociatedPtr; | 22 using indexed_db::mojom::FactoryAssociatedPtr; |
| 25 | 23 |
| 26 namespace content { | 24 namespace content { |
| 27 | 25 |
| 28 class WebIDBFactoryImpl::IOThreadHelper { | 26 class WebIDBFactoryImpl::IOThreadHelper { |
| 29 public: | 27 public: |
| 30 IOThreadHelper(scoped_refptr<IPC::SyncMessageFilter> sync_message_filter); | 28 IOThreadHelper(scoped_refptr<IPC::SyncMessageFilter> sync_message_filter); |
| 31 ~IOThreadHelper(); | 29 ~IOThreadHelper(); |
| 32 | 30 |
| 33 FactoryAssociatedPtr& GetService(); | 31 FactoryAssociatedPtr& GetService(); |
| 34 CallbacksAssociatedPtrInfo GetCallbacksProxy( | 32 CallbacksAssociatedPtrInfo GetCallbacksProxy( |
| 35 std::unique_ptr<IndexedDBCallbacksImpl> callbacks); | 33 std::unique_ptr<IndexedDBCallbacksImpl> callbacks); |
| 36 DatabaseCallbacksAssociatedPtrInfo GetDatabaseCallbacksProxy( | 34 DatabaseCallbacksAssociatedPtrInfo GetDatabaseCallbacksProxy( |
| 37 std::unique_ptr<IndexedDBDatabaseCallbacksImpl> callbacks); | 35 std::unique_ptr<IndexedDBDatabaseCallbacksImpl> callbacks); |
| 38 | 36 |
| 39 void GetDatabaseNames(std::unique_ptr<IndexedDBCallbacksImpl> callbacks, | 37 void GetDatabaseNames(std::unique_ptr<IndexedDBCallbacksImpl> callbacks, |
| 40 const url::Origin& origin); | 38 const url::Origin& origin); |
| 41 void Open(int32_t worker_thread, | 39 void Open(const base::string16& name, |
| 42 const base::string16& name, | |
| 43 int64_t version, | 40 int64_t version, |
| 44 int64_t transaction_id, | 41 int64_t transaction_id, |
| 45 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, | 42 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, |
| 46 std::unique_ptr<IndexedDBDatabaseCallbacksImpl> database_callbacks, | 43 std::unique_ptr<IndexedDBDatabaseCallbacksImpl> database_callbacks, |
| 47 const url::Origin& origin); | 44 const url::Origin& origin); |
| 48 void DeleteDatabase(const base::string16& name, | 45 void DeleteDatabase(const base::string16& name, |
| 49 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, | 46 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, |
| 50 const url::Origin& origin); | 47 const url::Origin& origin); |
| 51 | 48 |
| 52 private: | 49 private: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 WebIDBDatabaseCallbacks* database_callbacks, | 81 WebIDBDatabaseCallbacks* database_callbacks, |
| 85 const WebSecurityOrigin& origin) { | 82 const WebSecurityOrigin& origin) { |
| 86 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( | 83 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( |
| 87 base::WrapUnique(callbacks), transaction_id, nullptr, io_runner_); | 84 base::WrapUnique(callbacks), transaction_id, nullptr, io_runner_); |
| 88 auto database_callbacks_impl = | 85 auto database_callbacks_impl = |
| 89 base::MakeUnique<IndexedDBDatabaseCallbacksImpl>( | 86 base::MakeUnique<IndexedDBDatabaseCallbacksImpl>( |
| 90 base::WrapUnique(database_callbacks)); | 87 base::WrapUnique(database_callbacks)); |
| 91 io_runner_->PostTask( | 88 io_runner_->PostTask( |
| 92 FROM_HERE, | 89 FROM_HERE, |
| 93 base::Bind(&IOThreadHelper::Open, base::Unretained(io_helper_), | 90 base::Bind(&IOThreadHelper::Open, base::Unretained(io_helper_), |
| 94 WorkerThread::GetCurrentId(), base::string16(name), version, | 91 base::string16(name), version, transaction_id, |
| 95 transaction_id, base::Passed(&callbacks_impl), | 92 base::Passed(&callbacks_impl), |
| 96 base::Passed(&database_callbacks_impl), url::Origin(origin))); | 93 base::Passed(&database_callbacks_impl), url::Origin(origin))); |
| 97 } | 94 } |
| 98 | 95 |
| 99 void WebIDBFactoryImpl::deleteDatabase(const WebString& name, | 96 void WebIDBFactoryImpl::deleteDatabase(const WebString& name, |
| 100 WebIDBCallbacks* callbacks, | 97 WebIDBCallbacks* callbacks, |
| 101 const WebSecurityOrigin& origin) { | 98 const WebSecurityOrigin& origin) { |
| 102 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( | 99 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( |
| 103 base::WrapUnique(callbacks), IndexedDBCallbacksImpl::kNoTransaction, | 100 base::WrapUnique(callbacks), IndexedDBCallbacksImpl::kNoTransaction, |
| 104 nullptr, io_runner_); | 101 nullptr, io_runner_); |
| 105 io_runner_->PostTask( | 102 io_runner_->PostTask( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 140 } |
| 144 | 141 |
| 145 void WebIDBFactoryImpl::IOThreadHelper::GetDatabaseNames( | 142 void WebIDBFactoryImpl::IOThreadHelper::GetDatabaseNames( |
| 146 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, | 143 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, |
| 147 const url::Origin& origin) { | 144 const url::Origin& origin) { |
| 148 GetService()->GetDatabaseNames(GetCallbacksProxy(std::move(callbacks)), | 145 GetService()->GetDatabaseNames(GetCallbacksProxy(std::move(callbacks)), |
| 149 origin); | 146 origin); |
| 150 } | 147 } |
| 151 | 148 |
| 152 void WebIDBFactoryImpl::IOThreadHelper::Open( | 149 void WebIDBFactoryImpl::IOThreadHelper::Open( |
| 153 int32_t worker_thread, | |
| 154 const base::string16& name, | 150 const base::string16& name, |
| 155 int64_t version, | 151 int64_t version, |
| 156 int64_t transaction_id, | 152 int64_t transaction_id, |
| 157 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, | 153 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, |
| 158 std::unique_ptr<IndexedDBDatabaseCallbacksImpl> database_callbacks, | 154 std::unique_ptr<IndexedDBDatabaseCallbacksImpl> database_callbacks, |
| 159 const url::Origin& origin) { | 155 const url::Origin& origin) { |
| 160 GetService()->Open(worker_thread, GetCallbacksProxy(std::move(callbacks)), | 156 GetService()->Open(GetCallbacksProxy(std::move(callbacks)), |
| 161 GetDatabaseCallbacksProxy(std::move(database_callbacks)), | 157 GetDatabaseCallbacksProxy(std::move(database_callbacks)), |
| 162 origin, name, version, transaction_id); | 158 origin, name, version, transaction_id); |
| 163 } | 159 } |
| 164 | 160 |
| 165 void WebIDBFactoryImpl::IOThreadHelper::DeleteDatabase( | 161 void WebIDBFactoryImpl::IOThreadHelper::DeleteDatabase( |
| 166 const base::string16& name, | 162 const base::string16& name, |
| 167 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, | 163 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, |
| 168 const url::Origin& origin) { | 164 const url::Origin& origin) { |
| 169 GetService()->DeleteDatabase(GetCallbacksProxy(std::move(callbacks)), origin, | 165 GetService()->DeleteDatabase(GetCallbacksProxy(std::move(callbacks)), origin, |
| 170 name); | 166 name); |
| 171 } | 167 } |
| 172 | 168 |
| 173 } // namespace content | 169 } // namespace content |
| OLD | NEW |