| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * 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 * | 10 * |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 std::unique_ptr<WebIDBCallbacksImpl> WebIDBCallbacksImpl::create( | 58 std::unique_ptr<WebIDBCallbacksImpl> WebIDBCallbacksImpl::create( |
| 59 IDBRequest* request) { | 59 IDBRequest* request) { |
| 60 return WTF::wrapUnique(new WebIDBCallbacksImpl(request)); | 60 return WTF::wrapUnique(new WebIDBCallbacksImpl(request)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 WebIDBCallbacksImpl::WebIDBCallbacksImpl(IDBRequest* request) | 63 WebIDBCallbacksImpl::WebIDBCallbacksImpl(IDBRequest* request) |
| 64 : m_request(request) { | 64 : m_request(request) { |
| 65 probe::asyncTaskScheduled(m_request->getExecutionContext(), | 65 probe::asyncTaskScheduled(m_request->getExecutionContext(), |
| 66 IndexedDBNames::IndexedDB, this, true); | 66 IndexedDBNames::IndexedDB, this); |
| 67 } | 67 } |
| 68 | 68 |
| 69 WebIDBCallbacksImpl::~WebIDBCallbacksImpl() { | 69 WebIDBCallbacksImpl::~WebIDBCallbacksImpl() { |
| 70 if (m_request) { | 70 if (m_request) { |
| 71 probe::asyncTaskCanceled(m_request->getExecutionContext(), this); | 71 probe::asyncTaskCanceled(m_request->getExecutionContext(), this); |
| 72 m_request->webCallbacksDestroyed(); | 72 m_request->webCallbacksDestroyed(); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error) { | 76 void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error) { |
| 77 if (!m_request) | 77 if (!m_request) |
| 78 return; | 78 return; |
| 79 | 79 |
| 80 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 80 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, "error"); |
| 81 m_request->onError(DOMException::create(error.code(), error.message())); | 81 m_request->onError(DOMException::create(error.code(), error.message())); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void WebIDBCallbacksImpl::onSuccess(const WebVector<WebString>& webStringList) { | 84 void WebIDBCallbacksImpl::onSuccess(const WebVector<WebString>& webStringList) { |
| 85 if (!m_request) | 85 if (!m_request) |
| 86 return; | 86 return; |
| 87 | 87 |
| 88 Vector<String> stringList; | 88 Vector<String> stringList; |
| 89 for (size_t i = 0; i < webStringList.size(); ++i) | 89 for (size_t i = 0; i < webStringList.size(); ++i) |
| 90 stringList.push_back(webStringList[i]); | 90 stringList.push_back(webStringList[i]); |
| 91 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 91 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, "success"); |
| 92 m_request->onSuccess(stringList); | 92 m_request->onSuccess(stringList); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, | 95 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, |
| 96 const WebIDBKey& key, | 96 const WebIDBKey& key, |
| 97 const WebIDBKey& primaryKey, | 97 const WebIDBKey& primaryKey, |
| 98 const WebIDBValue& value) { | 98 const WebIDBValue& value) { |
| 99 if (!m_request) | 99 if (!m_request) |
| 100 return; | 100 return; |
| 101 | 101 |
| 102 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 102 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, "success"); |
| 103 m_request->onSuccess(WTF::wrapUnique(cursor), key, primaryKey, | 103 m_request->onSuccess(WTF::wrapUnique(cursor), key, primaryKey, |
| 104 IDBValue::create(value, m_request->isolate())); | 104 IDBValue::create(value, m_request->isolate())); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* backend, | 107 void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* backend, |
| 108 const WebIDBMetadata& metadata) { | 108 const WebIDBMetadata& metadata) { |
| 109 std::unique_ptr<WebIDBDatabase> db = WTF::wrapUnique(backend); | 109 std::unique_ptr<WebIDBDatabase> db = WTF::wrapUnique(backend); |
| 110 if (m_request) { | 110 if (m_request) { |
| 111 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 111 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, |
| 112 "success"); |
| 112 m_request->onSuccess(std::move(db), IDBDatabaseMetadata(metadata)); | 113 m_request->onSuccess(std::move(db), IDBDatabaseMetadata(metadata)); |
| 113 } else if (db) { | 114 } else if (db) { |
| 114 db->close(); | 115 db->close(); |
| 115 } | 116 } |
| 116 } | 117 } |
| 117 | 118 |
| 118 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key) { | 119 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key) { |
| 119 if (!m_request) | 120 if (!m_request) |
| 120 return; | 121 return; |
| 121 | 122 |
| 122 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 123 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, "success"); |
| 123 m_request->onSuccess(key); | 124 m_request->onSuccess(key); |
| 124 } | 125 } |
| 125 | 126 |
| 126 void WebIDBCallbacksImpl::onSuccess(const WebIDBValue& value) { | 127 void WebIDBCallbacksImpl::onSuccess(const WebIDBValue& value) { |
| 127 if (!m_request) | 128 if (!m_request) |
| 128 return; | 129 return; |
| 129 | 130 |
| 130 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 131 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, "success"); |
| 131 m_request->onSuccess(IDBValue::create(value, m_request->isolate())); | 132 m_request->onSuccess(IDBValue::create(value, m_request->isolate())); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void WebIDBCallbacksImpl::onSuccess(const WebVector<WebIDBValue>& values) { | 135 void WebIDBCallbacksImpl::onSuccess(const WebVector<WebIDBValue>& values) { |
| 135 if (!m_request) | 136 if (!m_request) |
| 136 return; | 137 return; |
| 137 | 138 |
| 138 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 139 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, "success"); |
| 139 Vector<RefPtr<IDBValue>> idbValues(values.size()); | 140 Vector<RefPtr<IDBValue>> idbValues(values.size()); |
| 140 for (size_t i = 0; i < values.size(); ++i) | 141 for (size_t i = 0; i < values.size(); ++i) |
| 141 idbValues[i] = IDBValue::create(values[i], m_request->isolate()); | 142 idbValues[i] = IDBValue::create(values[i], m_request->isolate()); |
| 142 m_request->onSuccess(idbValues); | 143 m_request->onSuccess(idbValues); |
| 143 } | 144 } |
| 144 | 145 |
| 145 void WebIDBCallbacksImpl::onSuccess(long long value) { | 146 void WebIDBCallbacksImpl::onSuccess(long long value) { |
| 146 if (!m_request) | 147 if (!m_request) |
| 147 return; | 148 return; |
| 148 | 149 |
| 149 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 150 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, "success"); |
| 150 m_request->onSuccess(value); | 151 m_request->onSuccess(value); |
| 151 } | 152 } |
| 152 | 153 |
| 153 void WebIDBCallbacksImpl::onSuccess() { | 154 void WebIDBCallbacksImpl::onSuccess() { |
| 154 if (!m_request) | 155 if (!m_request) |
| 155 return; | 156 return; |
| 156 | 157 |
| 157 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 158 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, "success"); |
| 158 m_request->onSuccess(); | 159 m_request->onSuccess(); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, | 162 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, |
| 162 const WebIDBKey& primaryKey, | 163 const WebIDBKey& primaryKey, |
| 163 const WebIDBValue& value) { | 164 const WebIDBValue& value) { |
| 164 if (!m_request) | 165 if (!m_request) |
| 165 return; | 166 return; |
| 166 | 167 |
| 167 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 168 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, "success"); |
| 168 m_request->onSuccess(key, primaryKey, | 169 m_request->onSuccess(key, primaryKey, |
| 169 IDBValue::create(value, m_request->isolate())); | 170 IDBValue::create(value, m_request->isolate())); |
| 170 } | 171 } |
| 171 | 172 |
| 172 void WebIDBCallbacksImpl::onBlocked(long long oldVersion) { | 173 void WebIDBCallbacksImpl::onBlocked(long long oldVersion) { |
| 173 if (!m_request) | 174 if (!m_request) |
| 174 return; | 175 return; |
| 175 | 176 |
| 176 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 177 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, "blocked"); |
| 177 m_request->onBlocked(oldVersion); | 178 m_request->onBlocked(oldVersion); |
| 178 } | 179 } |
| 179 | 180 |
| 180 void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, | 181 void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, |
| 181 WebIDBDatabase* database, | 182 WebIDBDatabase* database, |
| 182 const WebIDBMetadata& metadata, | 183 const WebIDBMetadata& metadata, |
| 183 unsigned short dataLoss, | 184 unsigned short dataLoss, |
| 184 WebString dataLossMessage) { | 185 WebString dataLossMessage) { |
| 185 std::unique_ptr<WebIDBDatabase> db = WTF::wrapUnique(database); | 186 std::unique_ptr<WebIDBDatabase> db = WTF::wrapUnique(database); |
| 186 if (m_request) { | 187 if (m_request) { |
| 187 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this); | 188 probe::AsyncTask asyncTask(m_request->getExecutionContext(), this, |
| 189 "upgradeNeeded"); |
| 188 m_request->onUpgradeNeeded( | 190 m_request->onUpgradeNeeded( |
| 189 oldVersion, std::move(db), IDBDatabaseMetadata(metadata), | 191 oldVersion, std::move(db), IDBDatabaseMetadata(metadata), |
| 190 static_cast<WebIDBDataLoss>(dataLoss), dataLossMessage); | 192 static_cast<WebIDBDataLoss>(dataLoss), dataLossMessage); |
| 191 } else { | 193 } else { |
| 192 db->close(); | 194 db->close(); |
| 193 } | 195 } |
| 194 } | 196 } |
| 195 | 197 |
| 196 void WebIDBCallbacksImpl::detach() { | 198 void WebIDBCallbacksImpl::detach() { |
| 197 m_request.clear(); | 199 m_request.clear(); |
| 198 } | 200 } |
| 199 | 201 |
| 200 } // namespace blink | 202 } // namespace blink |
| OLD | NEW |