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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) | 64 void IDBOpenDBRequest::onBlocked(int64_t oldVersion) |
65 { | 65 { |
66 IDB_TRACE("IDBOpenDBRequest::onBlocked()"); | 66 IDB_TRACE("IDBOpenDBRequest::onBlocked()"); |
67 if (!shouldEnqueueEvent()) | 67 if (!shouldEnqueueEvent()) |
68 return; | 68 return; |
69 RefPtr<IDBAny> newVersionAny = (m_version == IDBDatabaseMetadata::DefaultInt
Version) ? IDBAny::createNull() : IDBAny::create(m_version); | 69 RefPtr<IDBAny> newVersionAny = (m_version == IDBDatabaseMetadata::DefaultInt
Version) ? IDBAny::createNull() : IDBAny::create(m_version); |
70 enqueueEvent(IDBVersionChangeEvent::create(IDBAny::create(oldVersion), newVe
rsionAny.release(), eventNames().blockedEvent)); | 70 enqueueEvent(IDBVersionChangeEvent::create(IDBAny::create(oldVersion), newVe
rsionAny.release(), eventNames().blockedEvent)); |
71 } | 71 } |
72 | 72 |
73 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, PassRefPtr<IDBDatabas
eBackendInterface> prpDatabaseBackend, const IDBDatabaseMetadata& metadata) | 73 void IDBOpenDBRequest::onUpgradeNeeded(int64_t oldVersion, PassRefPtr<IDBDatabas
eBackendInterface> prpDatabaseBackend, const IDBDatabaseMetadata& metadata, WebK
it::WebIDBCallbacks::DataLoss dataLoss) |
74 { | 74 { |
75 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()"); | 75 IDB_TRACE("IDBOpenDBRequest::onUpgradeNeeded()"); |
76 if (m_contextStopped || !scriptExecutionContext()) { | 76 if (m_contextStopped || !scriptExecutionContext()) { |
77 RefPtr<IDBDatabaseBackendInterface> db = prpDatabaseBackend; | 77 RefPtr<IDBDatabaseBackendInterface> db = prpDatabaseBackend; |
78 db->abort(m_transactionId); | 78 db->abort(m_transactionId); |
79 db->close(m_databaseCallbacks); | 79 db->close(m_databaseCallbacks); |
80 return; | 80 return; |
81 } | 81 } |
82 if (!shouldEnqueueEvent()) | 82 if (!shouldEnqueueEvent()) |
83 return; | 83 return; |
(...skipping 12 matching lines...) Expand all Loading... |
96 oldVersion = IDBDatabaseMetadata::DefaultIntVersion; | 96 oldVersion = IDBDatabaseMetadata::DefaultIntVersion; |
97 } | 97 } |
98 IDBDatabaseMetadata oldMetadata(metadata); | 98 IDBDatabaseMetadata oldMetadata(metadata); |
99 oldMetadata.intVersion = oldVersion; | 99 oldMetadata.intVersion = oldVersion; |
100 | 100 |
101 m_transaction = IDBTransaction::create(scriptExecutionContext(), m_transacti
onId, idbDatabase.get(), this, oldMetadata); | 101 m_transaction = IDBTransaction::create(scriptExecutionContext(), m_transacti
onId, idbDatabase.get(), this, oldMetadata); |
102 m_result = IDBAny::create(idbDatabase.release()); | 102 m_result = IDBAny::create(idbDatabase.release()); |
103 | 103 |
104 if (m_version == IDBDatabaseMetadata::NoIntVersion) | 104 if (m_version == IDBDatabaseMetadata::NoIntVersion) |
105 m_version = 1; | 105 m_version = 1; |
106 enqueueEvent(IDBVersionChangeEvent::create(IDBAny::create(oldVersion), IDBAn
y::create(m_version), eventNames().upgradeneededEvent)); | 106 enqueueEvent(IDBVersionChangeEvent::create(IDBAny::create(oldVersion), IDBAn
y::create(m_version), eventNames().upgradeneededEvent, dataLoss)); |
107 } | 107 } |
108 | 108 |
109 void IDBOpenDBRequest::onSuccess(PassRefPtr<IDBDatabaseBackendInterface> prpBack
end, const IDBDatabaseMetadata& metadata) | 109 void IDBOpenDBRequest::onSuccess(PassRefPtr<IDBDatabaseBackendInterface> prpBack
end, const IDBDatabaseMetadata& metadata) |
110 { | 110 { |
111 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); | 111 IDB_TRACE("IDBOpenDBRequest::onSuccess()"); |
112 if (m_contextStopped || !scriptExecutionContext()) { | 112 if (m_contextStopped || !scriptExecutionContext()) { |
113 RefPtr<IDBDatabaseBackendInterface> db = prpBackend; | 113 RefPtr<IDBDatabaseBackendInterface> db = prpBackend; |
114 db->close(m_databaseCallbacks); | 114 db->close(m_databaseCallbacks); |
115 return; | 115 return; |
116 } | 116 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 if (event->type() == eventNames().successEvent && m_result->type() == IDBAny
::IDBDatabaseType && m_result->idbDatabase()->isClosePending()) { | 151 if (event->type() == eventNames().successEvent && m_result->type() == IDBAny
::IDBDatabaseType && m_result->idbDatabase()->isClosePending()) { |
152 m_result.clear(); | 152 m_result.clear(); |
153 onError(IDBDatabaseError::create(IDBDatabaseException::AbortError, "The
connection was closed.")); | 153 onError(IDBDatabaseError::create(IDBDatabaseException::AbortError, "The
connection was closed.")); |
154 return false; | 154 return false; |
155 } | 155 } |
156 | 156 |
157 return IDBRequest::dispatchEvent(event); | 157 return IDBRequest::dispatchEvent(event); |
158 } | 158 } |
159 | 159 |
160 } // namespace WebCore | 160 } // namespace WebCore |
OLD | NEW |