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 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 DCHECK(!resultAsAny()); | 60 DCHECK(!resultAsAny()); |
61 } | 61 } |
62 | 62 |
63 IDBOpenDBRequest::~IDBOpenDBRequest() {} | 63 IDBOpenDBRequest::~IDBOpenDBRequest() {} |
64 | 64 |
65 DEFINE_TRACE(IDBOpenDBRequest) { | 65 DEFINE_TRACE(IDBOpenDBRequest) { |
66 visitor->trace(m_databaseCallbacks); | 66 visitor->trace(m_databaseCallbacks); |
67 IDBRequest::trace(visitor); | 67 IDBRequest::trace(visitor); |
68 } | 68 } |
69 | 69 |
| 70 void IDBOpenDBRequest::contextDestroyed() { |
| 71 IDBRequest::contextDestroyed(); |
| 72 if (m_databaseCallbacks) |
| 73 m_databaseCallbacks->detachWebCallbacks(); |
| 74 } |
| 75 |
70 const AtomicString& IDBOpenDBRequest::interfaceName() const { | 76 const AtomicString& IDBOpenDBRequest::interfaceName() const { |
71 return EventTargetNames::IDBOpenDBRequest; | 77 return EventTargetNames::IDBOpenDBRequest; |
72 } | 78 } |
73 | 79 |
74 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) { | 80 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) { |
75 IDB_TRACE("IDBOpenDBRequest::onBlocked()"); | 81 IDB_TRACE("IDBOpenDBRequest::onBlocked()"); |
76 if (!shouldEnqueueEvent()) | 82 if (!shouldEnqueueEvent()) |
77 return; | 83 return; |
78 Nullable<unsigned long long> newVersionNullable = | 84 Nullable<unsigned long long> newVersionNullable = |
79 (m_version == IDBDatabaseMetadata::DefaultVersion) | 85 (m_version == IDBDatabaseMetadata::DefaultVersion) |
80 ? Nullable<unsigned long long>() | 86 ? Nullable<unsigned long long>() |
81 : Nullable<unsigned long long>(m_version); | 87 : Nullable<unsigned long long>(m_version); |
82 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::blocked, | 88 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::blocked, |
83 oldVersion, newVersionNullable)); | 89 oldVersion, newVersionNullable)); |
84 } | 90 } |
85 | 91 |
86 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, | 92 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, |
87 std::unique_ptr<WebIDBDatabase> backend, | 93 std::unique_ptr<WebIDBDatabase> backend, |
88 const IDBDatabaseMetadata& metadata, | 94 const IDBDatabaseMetadata& metadata, |
89 WebIDBDataLoss dataLoss, | 95 WebIDBDataLoss dataLoss, |
90 String dataLossMessage) { | 96 String dataLossMessage) { |
91 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()"); | 97 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()"); |
92 if (m_contextStopped || !getExecutionContext()) { | |
93 std::unique_ptr<WebIDBDatabase> db = std::move(backend); | |
94 db->abort(m_transactionId); | |
95 db->close(); | |
96 return; | |
97 } | |
98 if (!shouldEnqueueEvent()) | 98 if (!shouldEnqueueEvent()) |
99 return; | 99 return; |
100 | 100 |
101 DCHECK(m_databaseCallbacks); | 101 DCHECK(m_databaseCallbacks); |
102 | 102 |
103 IDBDatabase* idbDatabase = IDBDatabase::create( | 103 IDBDatabase* idbDatabase = IDBDatabase::create( |
104 getExecutionContext(), std::move(backend), m_databaseCallbacks.release()); | 104 getExecutionContext(), std::move(backend), m_databaseCallbacks.release()); |
105 idbDatabase->setMetadata(metadata); | 105 idbDatabase->setMetadata(metadata); |
106 | 106 |
107 if (oldVersion == IDBDatabaseMetadata::NoVersion) { | 107 if (oldVersion == IDBDatabaseMetadata::NoVersion) { |
(...skipping 11 matching lines...) Expand all Loading... |
119 if (m_version == IDBDatabaseMetadata::NoVersion) | 119 if (m_version == IDBDatabaseMetadata::NoVersion) |
120 m_version = 1; | 120 m_version = 1; |
121 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::upgradeneeded, | 121 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::upgradeneeded, |
122 oldVersion, m_version, dataLoss, | 122 oldVersion, m_version, dataLoss, |
123 dataLossMessage)); | 123 dataLossMessage)); |
124 } | 124 } |
125 | 125 |
126 void IDBOpenDBRequest::onSuccess(std::unique_ptr<WebIDBDatabase> backend, | 126 void IDBOpenDBRequest::onSuccess(std::unique_ptr<WebIDBDatabase> backend, |
127 const IDBDatabaseMetadata& metadata) { | 127 const IDBDatabaseMetadata& metadata) { |
128 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); | 128 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); |
129 if (m_contextStopped || !getExecutionContext()) { | |
130 std::unique_ptr<WebIDBDatabase> db = std::move(backend); | |
131 if (db) | |
132 db->close(); | |
133 return; | |
134 } | |
135 if (!shouldEnqueueEvent()) | 129 if (!shouldEnqueueEvent()) |
136 return; | 130 return; |
137 | 131 |
138 IDBDatabase* idbDatabase = nullptr; | 132 IDBDatabase* idbDatabase = nullptr; |
139 if (resultAsAny()) { | 133 if (resultAsAny()) { |
140 // Previous onUpgradeNeeded call delivered the backend. | 134 // Previous onUpgradeNeeded call delivered the backend. |
141 DCHECK(!backend.get()); | 135 DCHECK(!backend.get()); |
142 idbDatabase = resultAsAny()->idbDatabase(); | 136 idbDatabase = resultAsAny()->idbDatabase(); |
143 DCHECK(idbDatabase); | 137 DCHECK(idbDatabase); |
144 DCHECK(!m_databaseCallbacks); | 138 DCHECK(!m_databaseCallbacks); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 dequeueEvent(event); | 178 dequeueEvent(event); |
185 setResult(nullptr); | 179 setResult(nullptr); |
186 onError(DOMException::create(AbortError, "The connection was closed.")); | 180 onError(DOMException::create(AbortError, "The connection was closed.")); |
187 return DispatchEventResult::CanceledBeforeDispatch; | 181 return DispatchEventResult::CanceledBeforeDispatch; |
188 } | 182 } |
189 | 183 |
190 return IDBRequest::dispatchEventInternal(event); | 184 return IDBRequest::dispatchEventInternal(event); |
191 } | 185 } |
192 | 186 |
193 } // namespace blink | 187 } // namespace blink |
OLD | NEW |