| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_database_callbacks_impl.h" | 5 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" |
| 6 | 6 |
| 7 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 7 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
| 8 #include "content/child/indexed_db/indexed_db_key_builders.h" | 8 #include "content/child/indexed_db/indexed_db_key_builders.h" |
| 9 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal
lbacks.h" | 9 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseCal
lbacks.h" |
| 10 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr
or.h" | 10 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseErr
or.h" |
| 11 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBObservation
.h" | 11 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBObservation
.h" |
| 12 | 12 |
| 13 using blink::WebIDBDatabaseCallbacks; | 13 using blink::WebIDBDatabaseCallbacks; |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 void DeleteDatabaseCallbacks(WebIDBDatabaseCallbacks* callbacks) { | 19 void DeleteDatabaseCallbacks(WebIDBDatabaseCallbacks* callbacks) { |
| 20 IndexedDBDispatcher::ThreadSpecificInstance() | 20 IndexedDBDispatcher::ThreadSpecificInstance() |
| 21 ->UnregisterMojoOwnedDatabaseCallbacks(callbacks); | 21 ->UnregisterMojoOwnedDatabaseCallbacks(callbacks); |
| 22 delete callbacks; | 22 delete callbacks; |
| 23 } | 23 } |
| 24 | 24 |
| 25 void BuildErrorAndAbort(WebIDBDatabaseCallbacks* callbacks, | 25 void BuildErrorAndAbort(WebIDBDatabaseCallbacks* callbacks, |
| 26 int64_t transaction_id, | 26 int64_t transaction_id, |
| 27 int32_t code, | 27 int32_t code, |
| 28 const base::string16& message) { | 28 const base::string16& message) { |
| 29 callbacks->onAbort(transaction_id, blink::WebIDBDatabaseError(code, message)); | 29 callbacks->onAbort( |
| 30 transaction_id, |
| 31 blink::WebIDBDatabaseError(code, blink::WebString::fromUTF16(message))); |
| 30 } | 32 } |
| 31 | 33 |
| 32 void BuildObservationsAndNotify(WebIDBDatabaseCallbacks* callbacks, | 34 void BuildObservationsAndNotify(WebIDBDatabaseCallbacks* callbacks, |
| 33 indexed_db::mojom::ObserverChangesPtr changes) { | 35 indexed_db::mojom::ObserverChangesPtr changes) { |
| 34 std::vector<blink::WebIDBObservation> web_observations; | 36 std::vector<blink::WebIDBObservation> web_observations; |
| 35 for (const auto& observation : changes->observations) { | 37 for (const auto& observation : changes->observations) { |
| 36 blink::WebIDBObservation web_observation; | 38 blink::WebIDBObservation web_observation; |
| 37 web_observation.objectStoreId = observation->object_store_id; | 39 web_observation.objectStoreId = observation->object_store_id; |
| 38 web_observation.type = observation->type; | 40 web_observation.type = observation->type; |
| 39 web_observation.keyRange = | 41 web_observation.keyRange = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 92 } |
| 91 | 93 |
| 92 void IndexedDBDatabaseCallbacksImpl::Changes( | 94 void IndexedDBDatabaseCallbacksImpl::Changes( |
| 93 indexed_db::mojom::ObserverChangesPtr changes) { | 95 indexed_db::mojom::ObserverChangesPtr changes) { |
| 94 callback_runner_->PostTask(FROM_HERE, base::Bind(&BuildObservationsAndNotify, | 96 callback_runner_->PostTask(FROM_HERE, base::Bind(&BuildObservationsAndNotify, |
| 95 base::Unretained(callbacks_), | 97 base::Unretained(callbacks_), |
| 96 base::Passed(&changes))); | 98 base::Passed(&changes))); |
| 97 } | 99 } |
| 98 | 100 |
| 99 } // namespace content | 101 } // namespace content |
| OLD | NEW |