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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 const AtomicString& IDBOpenDBRequest::interfaceName() const | 67 const AtomicString& IDBOpenDBRequest::interfaceName() const |
68 { | 68 { |
69 return EventTargetNames::IDBOpenDBRequest; | 69 return EventTargetNames::IDBOpenDBRequest; |
70 } | 70 } |
71 | 71 |
72 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) | 72 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) |
73 { | 73 { |
74 IDB_TRACE("IDBOpenDBRequest::onBlocked()"); | 74 IDB_TRACE("IDBOpenDBRequest::onBlocked()"); |
75 if (!shouldEnqueueEvent()) | 75 if (!shouldEnqueueEvent()) |
76 return; | 76 return; |
77 Nullable<unsigned long long> newVersionNullable = (m_version == IDBDatabaseM
etadata::DefaultIntVersion) ? Nullable<unsigned long long>() : Nullable<unsigned
long long>(m_version); | 77 Nullable<unsigned long long> newVersionNullable = (m_version == IDBDatabaseM
etadata::DefaultVersion) ? Nullable<unsigned long long>() : Nullable<unsigned lo
ng long>(m_version); |
78 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::blocked, oldVersi
on, newVersionNullable)); | 78 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::blocked, oldVersi
on, newVersionNullable)); |
79 } | 79 } |
80 | 80 |
81 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, PassOwnPtr<WebIDBData
base> backend, const IDBDatabaseMetadata& metadata, WebIDBDataLoss dataLoss, Str
ing dataLossMessage) | 81 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, PassOwnPtr<WebIDBData
base> backend, const IDBDatabaseMetadata& metadata, WebIDBDataLoss dataLoss, Str
ing dataLossMessage) |
82 { | 82 { |
83 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()"); | 83 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()"); |
84 if (m_contextStopped || !executionContext()) { | 84 if (m_contextStopped || !executionContext()) { |
85 OwnPtr<WebIDBDatabase> db = backend; | 85 OwnPtr<WebIDBDatabase> db = backend; |
86 db->abort(m_transactionId); | 86 db->abort(m_transactionId); |
87 db->close(); | 87 db->close(); |
88 return; | 88 return; |
89 } | 89 } |
90 if (!shouldEnqueueEvent()) | 90 if (!shouldEnqueueEvent()) |
91 return; | 91 return; |
92 | 92 |
93 ASSERT(m_databaseCallbacks); | 93 ASSERT(m_databaseCallbacks); |
94 | 94 |
95 IDBDatabase* idbDatabase = IDBDatabase::create(executionContext(), backend,
m_databaseCallbacks.release()); | 95 IDBDatabase* idbDatabase = IDBDatabase::create(executionContext(), backend,
m_databaseCallbacks.release()); |
96 idbDatabase->setMetadata(metadata); | 96 idbDatabase->setMetadata(metadata); |
97 | 97 |
98 if (oldVersion == IDBDatabaseMetadata::NoIntVersion) { | 98 if (oldVersion == IDBDatabaseMetadata::NoVersion) { |
99 // This database hasn't had an integer version before. | 99 // This database hasn't had a version before. |
100 oldVersion = IDBDatabaseMetadata::DefaultIntVersion; | 100 oldVersion = IDBDatabaseMetadata::DefaultVersion; |
101 } | 101 } |
102 IDBDatabaseMetadata oldMetadata(metadata); | 102 IDBDatabaseMetadata oldMetadata(metadata); |
103 oldMetadata.intVersion = oldVersion; | 103 oldMetadata.version = oldVersion; |
104 | 104 |
105 m_transaction = IDBTransaction::create(scriptState(), m_transactionId, idbDa
tabase, this, oldMetadata); | 105 m_transaction = IDBTransaction::create(scriptState(), m_transactionId, idbDa
tabase, this, oldMetadata); |
106 setResult(IDBAny::create(idbDatabase)); | 106 setResult(IDBAny::create(idbDatabase)); |
107 | 107 |
108 if (m_version == IDBDatabaseMetadata::NoIntVersion) | 108 if (m_version == IDBDatabaseMetadata::NoVersion) |
109 m_version = 1; | 109 m_version = 1; |
110 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::upgradeneeded, ol
dVersion, m_version, dataLoss, dataLossMessage)); | 110 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::upgradeneeded, ol
dVersion, m_version, dataLoss, dataLossMessage)); |
111 } | 111 } |
112 | 112 |
113 void IDBOpenDBRequest::onSuccess(PassOwnPtr<WebIDBDatabase> backend, const IDBDa
tabaseMetadata& metadata) | 113 void IDBOpenDBRequest::onSuccess(PassOwnPtr<WebIDBDatabase> backend, const IDBDa
tabaseMetadata& metadata) |
114 { | 114 { |
115 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); | 115 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); |
116 if (m_contextStopped || !executionContext()) { | 116 if (m_contextStopped || !executionContext()) { |
117 OwnPtr<WebIDBDatabase> db = backend; | 117 OwnPtr<WebIDBDatabase> db = backend; |
118 if (db) | 118 if (db) |
(...skipping 18 matching lines...) Expand all Loading... |
137 } | 137 } |
138 idbDatabase->setMetadata(metadata); | 138 idbDatabase->setMetadata(metadata); |
139 enqueueEvent(Event::create(EventTypeNames::success)); | 139 enqueueEvent(Event::create(EventTypeNames::success)); |
140 } | 140 } |
141 | 141 |
142 void IDBOpenDBRequest::onSuccess(int64_t oldVersion) | 142 void IDBOpenDBRequest::onSuccess(int64_t oldVersion) |
143 { | 143 { |
144 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); | 144 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); |
145 if (!shouldEnqueueEvent()) | 145 if (!shouldEnqueueEvent()) |
146 return; | 146 return; |
147 if (oldVersion == IDBDatabaseMetadata::NoIntVersion) { | 147 if (oldVersion == IDBDatabaseMetadata::NoVersion) { |
148 // This database hasn't had an integer version before. | 148 // This database hasn't had an integer version before. |
149 oldVersion = IDBDatabaseMetadata::DefaultIntVersion; | 149 oldVersion = IDBDatabaseMetadata::DefaultVersion; |
150 } | 150 } |
151 setResult(IDBAny::createUndefined()); | 151 setResult(IDBAny::createUndefined()); |
152 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::success, oldVersi
on, Nullable<unsigned long long>())); | 152 enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::success, oldVersi
on, Nullable<unsigned long long>())); |
153 } | 153 } |
154 | 154 |
155 bool IDBOpenDBRequest::shouldEnqueueEvent() const | 155 bool IDBOpenDBRequest::shouldEnqueueEvent() const |
156 { | 156 { |
157 if (m_contextStopped || !executionContext()) | 157 if (m_contextStopped || !executionContext()) |
158 return false; | 158 return false; |
159 ASSERT(m_readyState == PENDING || m_readyState == DONE); | 159 ASSERT(m_readyState == PENDING || m_readyState == DONE); |
(...skipping 10 matching lines...) Expand all Loading... |
170 dequeueEvent(event.get()); | 170 dequeueEvent(event.get()); |
171 setResult(nullptr); | 171 setResult(nullptr); |
172 onError(DOMException::create(AbortError, "The connection was closed.")); | 172 onError(DOMException::create(AbortError, "The connection was closed.")); |
173 return false; | 173 return false; |
174 } | 174 } |
175 | 175 |
176 return IDBRequest::dispatchEventInternal(event); | 176 return IDBRequest::dispatchEventInternal(event); |
177 } | 177 } |
178 | 178 |
179 } // namespace blink | 179 } // namespace blink |
OLD | NEW |