OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
13 * | 13 * |
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef IDBOpenDBRequest_h | 26 #ifndef IDBOpenDBRequest_h |
27 #define IDBOpenDBRequest_h | 27 #define IDBOpenDBRequest_h |
28 | 28 |
| 29 #include "Source/modules/indexeddb/indexed_db.mojom-blink.h" |
29 #include "modules/ModulesExport.h" | 30 #include "modules/ModulesExport.h" |
30 #include "modules/indexeddb/IDBRequest.h" | 31 #include "modules/indexeddb/IDBRequest.h" |
31 #include "public/platform/modules/indexeddb/WebIDBDatabase.h" | 32 #include "mojo/public/cpp/bindings/binding.h" |
32 #include <memory> | |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 class IDBDatabaseCallbacks; | 36 class IDBDatabase; |
37 | 37 |
38 class MODULES_EXPORT IDBOpenDBRequest final : public IDBRequest { | 38 // A request to either open or delete a database. |
| 39 // |
| 40 // Note: This is an Oilpan managed object with an interface passed to Mojo. |
| 41 // TODO(cmumford): Update this note when the request is removed from IDBDatabase
ObserverImpl. |
| 42 class MODULES_EXPORT IDBOpenDBRequest final : public IDBRequest, WTF_NON_EXPORTE
D_BASE(public indexed_db::mojom::blink::OpenRequestObserver) |
| 43 { |
39 DEFINE_WRAPPERTYPEINFO(); | 44 DEFINE_WRAPPERTYPEINFO(); |
40 public: | 45 public: |
41 static IDBOpenDBRequest* create(ScriptState*, IDBDatabaseCallbacks*, int64_t
transactionId, int64_t version); | 46 static IDBOpenDBRequest* create(ScriptState*, int64_t transactionId, int64_t
version, indexed_db::mojom::blink::OpenRequestObserverRequest); |
42 ~IDBOpenDBRequest() override; | 47 ~IDBOpenDBRequest() override; |
43 DECLARE_VIRTUAL_TRACE(); | 48 DECLARE_VIRTUAL_TRACE(); |
44 | 49 |
45 using IDBRequest::onSuccess; | 50 using IDBRequest::onSuccess; |
46 | 51 |
47 void onBlocked(int64_t existingVersion) override; | 52 void onSuccess(std::unique_ptr<IDBDatabaseProxy>, const IDBDatabaseMetadata&
) override; |
48 void onUpgradeNeeded(int64_t oldVersion, std::unique_ptr<WebIDBDatabase>, co
nst IDBDatabaseMetadata&, WebIDBDataLoss, String dataLossMessage) override; | |
49 void onSuccess(std::unique_ptr<WebIDBDatabase>, const IDBDatabaseMetadata&)
override; | |
50 void onSuccess(int64_t oldVersion) override; | 53 void onSuccess(int64_t oldVersion) override; |
51 | 54 |
52 // EventTarget | 55 // EventTarget |
53 const AtomicString& interfaceName() const override; | 56 const AtomicString& interfaceName() const override; |
54 | 57 |
| 58 // indexed_db::mojom::blink::OpenRequestObserver: |
| 59 void OnBlocked(int64_t oldVersion) override; |
| 60 void OnUpgradeNeeded(int64_t oldVersion, indexed_db::mojom::blink::DatabaseP
tr, indexed_db::mojom::blink::DatabaseMetadataPtr, indexed_db::mojom::blink::Dat
aLossInfoPtr) override; |
| 61 |
| 62 IDBDatabase* getDatabase() const; |
| 63 |
| 64 void onOpenResult(indexed_db::mojom::blink::OpenResultPtr); |
| 65 |
55 DEFINE_ATTRIBUTE_EVENT_LISTENER(blocked); | 66 DEFINE_ATTRIBUTE_EVENT_LISTENER(blocked); |
56 DEFINE_ATTRIBUTE_EVENT_LISTENER(upgradeneeded); | 67 DEFINE_ATTRIBUTE_EVENT_LISTENER(upgradeneeded); |
57 | 68 |
58 protected: | 69 protected: |
59 bool shouldEnqueueEvent() const override; | 70 bool shouldEnqueueEvent() const override; |
60 | 71 |
61 // EventTarget | 72 // EventTarget |
62 DispatchEventResult dispatchEventInternal(Event*) override; | 73 DispatchEventResult dispatchEventInternal(Event*) override; |
63 | 74 |
64 private: | 75 private: |
65 IDBOpenDBRequest(ScriptState*, IDBDatabaseCallbacks*, int64_t transactionId,
int64_t version); | 76 IDBOpenDBRequest(ScriptState*, int64_t transactionId, int64_t version, index
ed_db::mojom::blink::OpenRequestObserverRequest); |
66 | 77 |
67 Member<IDBDatabaseCallbacks> m_databaseCallbacks; | 78 void onBlocked(int64_t existingVersion); |
| 79 void onUpgradeNeeded(int64_t oldVersion, std::unique_ptr<IDBDatabaseProxy>,
const IDBDatabaseMetadata&, WebIDBDataLoss, String dataLossMessage); |
| 80 |
68 const int64_t m_transactionId; | 81 const int64_t m_transactionId; |
69 int64_t m_version; | 82 int64_t m_version; |
| 83 mojo::Binding<indexed_db::mojom::blink::OpenRequestObserver> m_binding; |
70 }; | 84 }; |
71 | 85 |
72 } // namespace blink | 86 } // namespace blink |
73 | 87 |
74 #endif // IDBOpenDBRequest_h | 88 #endif // IDBOpenDBRequest_h |
OLD | NEW |