| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "modules/indexeddb/IDBCursorBackendInterface.h" | 42 #include "modules/indexeddb/IDBCursorBackendInterface.h" |
| 43 #include "modules/indexeddb/IDBDatabaseBackendInterface.h" | 43 #include "modules/indexeddb/IDBDatabaseBackendInterface.h" |
| 44 #include "modules/indexeddb/IDBDatabaseError.h" | 44 #include "modules/indexeddb/IDBDatabaseError.h" |
| 45 #include "modules/indexeddb/IDBMetadata.h" | 45 #include "modules/indexeddb/IDBMetadata.h" |
| 46 #include <public/WebData.h> | 46 #include <public/WebData.h> |
| 47 | 47 |
| 48 using namespace WebCore; | 48 using namespace WebCore; |
| 49 | 49 |
| 50 namespace WebKit { | 50 namespace WebKit { |
| 51 | 51 |
| 52 PassRefPtr<IDBCallbacksProxy> IDBCallbacksProxy::create(PassOwnPtr<WebIDBCallbac
ks> callbacks) | 52 IDBCallbacksProxy* IDBCallbacksProxy::create(PassOwnPtr<WebIDBCallbacks> callbac
ks) |
| 53 { | 53 { |
| 54 return adoptRef(new IDBCallbacksProxy(callbacks)); | 54 return new IDBCallbacksProxy(callbacks); |
| 55 } | 55 } |
| 56 | 56 |
| 57 IDBCallbacksProxy::IDBCallbacksProxy(PassOwnPtr<WebIDBCallbacks> callbacks) | 57 IDBCallbacksProxy::IDBCallbacksProxy(PassOwnPtr<WebIDBCallbacks> callbacks) |
| 58 : m_callbacks(callbacks) | 58 : m_callbacks(callbacks) |
| 59 , m_didComplete(false) | 59 , m_didComplete(false) |
| 60 , m_didCreateProxy(false) | 60 , m_didCreateProxy(false) |
| 61 { | 61 { |
| 62 } | 62 } |
| 63 | 63 |
| 64 IDBCallbacksProxy::~IDBCallbacksProxy() | 64 IDBCallbacksProxy::~IDBCallbacksProxy() |
| 65 { | 65 { |
| 66 // This cleans up the request's IPC id. | 66 // This cleans up the request's IPC id. |
| 67 if (!m_didComplete) | 67 if (!m_didComplete) |
| 68 m_callbacks->onError(WebIDBDatabaseError(WebIDBDatabaseExceptionAbortErr
or, WebString())); | 68 m_callbacks->onError(WebIDBDatabaseError(WebIDBDatabaseExceptionAbortErr
or, WebString())); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void IDBCallbacksProxy::onError(PassRefPtr<IDBDatabaseError> idbDatabaseError) | 71 void IDBCallbacksProxy::onError(PassRefPtr<IDBDatabaseError> idbDatabaseError) |
| 72 { | 72 { |
| 73 m_didComplete = true; | 73 m_didComplete = true; |
| 74 m_callbacks->onError(WebIDBDatabaseError(idbDatabaseError)); | 74 m_callbacks->onError(WebIDBDatabaseError(idbDatabaseError)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBCursorBackendInterface> idbCurso
rBackend, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<Shar
edBuffer> value) | 77 void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBCursorBackendInterface> idbCurso
rBackend, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<Shar
edBuffer> value) |
| 78 { | 78 { |
| 79 m_didComplete = true; | 79 m_didComplete = true; |
| 80 m_callbacks->onSuccess(new WebIDBCursorImpl(idbCursorBackend), key, primaryK
ey, WebData(value)); | 80 m_callbacks->onSuccess(new WebIDBCursorImpl(idbCursorBackend), key, primaryK
ey, WebData(value)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBDatabaseBackendInterface> backen
d, const IDBDatabaseMetadata& metadata) | 83 void IDBCallbacksProxy::onSuccess(IDBDatabaseBackendInterface* backend, const ID
BDatabaseMetadata& metadata) |
| 84 { | 84 { |
| 85 ASSERT(m_databaseCallbacks.get()); | 85 ASSERT(m_databaseCallbacks); |
| 86 m_didComplete = true; | 86 m_didComplete = true; |
| 87 WebIDBDatabaseImpl* impl = m_didCreateProxy ? 0 : new WebIDBDatabaseImpl(bac
kend, m_databaseCallbacks.release()); | 87 WebIDBDatabaseImpl* impl = m_didCreateProxy ? 0 : new WebIDBDatabaseImpl(bac
kend, m_databaseCallbacks.clear()); |
| 88 m_callbacks->onSuccess(impl, metadata); | 88 m_callbacks->onSuccess(impl, metadata); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBKey> idbKey) | 91 void IDBCallbacksProxy::onSuccess(PassRefPtr<IDBKey> idbKey) |
| 92 { | 92 { |
| 93 m_didComplete = true; | 93 m_didComplete = true; |
| 94 m_callbacks->onSuccess(WebIDBKey(idbKey)); | 94 m_callbacks->onSuccess(WebIDBKey(idbKey)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void IDBCallbacksProxy::onSuccess(const Vector<String>& stringList) | 97 void IDBCallbacksProxy::onSuccess(const Vector<String>& stringList) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 146 } |
| 147 | 147 |
| 148 m_callbacks->onSuccessWithPrefetch(webKeys, webPrimaryKeys, webValues); | 148 m_callbacks->onSuccessWithPrefetch(webKeys, webPrimaryKeys, webValues); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void IDBCallbacksProxy::onBlocked(int64_t existingVersion) | 151 void IDBCallbacksProxy::onBlocked(int64_t existingVersion) |
| 152 { | 152 { |
| 153 m_callbacks->onBlocked(existingVersion); | 153 m_callbacks->onBlocked(existingVersion); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void IDBCallbacksProxy::onUpgradeNeeded(int64_t oldVersion, PassRefPtr<IDBDataba
seBackendInterface> database, const IDBDatabaseMetadata& metadata) | 156 void IDBCallbacksProxy::onUpgradeNeeded(int64_t oldVersion, IDBDatabaseBackendIn
terface* database, const IDBDatabaseMetadata& metadata) |
| 157 { | 157 { |
| 158 ASSERT(m_databaseCallbacks); | 158 ASSERT(m_databaseCallbacks); |
| 159 m_didCreateProxy = true; | 159 m_didCreateProxy = true; |
| 160 m_callbacks->onUpgradeNeeded(oldVersion, new WebIDBDatabaseImpl(database, m_
databaseCallbacks), metadata); | 160 m_callbacks->onUpgradeNeeded(oldVersion, new WebIDBDatabaseImpl(database, m_
databaseCallbacks), metadata); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void IDBCallbacksProxy::setDatabaseCallbacks(PassRefPtr<IDBDatabaseCallbacksProx
y> databaseCallbacks) | 163 void IDBCallbacksProxy::setDatabaseCallbacks(IDBDatabaseCallbacksProxy* database
Callbacks) |
| 164 { | 164 { |
| 165 ASSERT(!m_databaseCallbacks); | 165 ASSERT(!m_databaseCallbacks); |
| 166 m_databaseCallbacks = databaseCallbacks; | 166 m_databaseCallbacks = databaseCallbacks; |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace WebKit | 169 } // namespace WebKit |
| OLD | NEW |