Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/WebIDBCallbacksImpl.cpp

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Address last nits and fix leaks in unit tests. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return wrapUnique(new WebIDBCallbacksImpl(request)); 60 return 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 InspectorInstrumentation::asyncTaskScheduled( 65 InspectorInstrumentation::asyncTaskScheduled(
66 m_request->getExecutionContext(), IndexedDBNames::IndexedDB, this, true); 66 m_request->getExecutionContext(), IndexedDBNames::IndexedDB, this, true);
67 } 67 }
68 68
69 WebIDBCallbacksImpl::~WebIDBCallbacksImpl() { 69 WebIDBCallbacksImpl::~WebIDBCallbacksImpl() {
70 InspectorInstrumentation::asyncTaskCanceled(m_request->getExecutionContext(), 70 if (m_request) {
71 this); 71 InspectorInstrumentation::asyncTaskCanceled(
72 m_request->getExecutionContext(), this);
73 m_request->webCallbacksDestroyed();
74 }
72 } 75 }
73 76
74 void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error) { 77 void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error) {
78 if (!m_request)
79 return;
80
75 InspectorInstrumentation::AsyncTask asyncTask( 81 InspectorInstrumentation::AsyncTask asyncTask(
76 m_request->getExecutionContext(), this); 82 m_request->getExecutionContext(), this);
77 m_request->onError(DOMException::create(error.code(), error.message())); 83 m_request->onError(DOMException::create(error.code(), error.message()));
78 } 84 }
79 85
80 void WebIDBCallbacksImpl::onSuccess(const WebVector<WebString>& webStringList) { 86 void WebIDBCallbacksImpl::onSuccess(const WebVector<WebString>& webStringList) {
87 if (!m_request)
88 return;
89
81 Vector<String> stringList; 90 Vector<String> stringList;
82 for (size_t i = 0; i < webStringList.size(); ++i) 91 for (size_t i = 0; i < webStringList.size(); ++i)
83 stringList.append(webStringList[i]); 92 stringList.append(webStringList[i]);
84 InspectorInstrumentation::AsyncTask asyncTask( 93 InspectorInstrumentation::AsyncTask asyncTask(
85 m_request->getExecutionContext(), this); 94 m_request->getExecutionContext(), this);
86 m_request->onSuccess(stringList); 95 m_request->onSuccess(stringList);
87 } 96 }
88 97
89 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, 98 void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor,
90 const WebIDBKey& key, 99 const WebIDBKey& key,
91 const WebIDBKey& primaryKey, 100 const WebIDBKey& primaryKey,
92 const WebIDBValue& value) { 101 const WebIDBValue& value) {
102 if (!m_request)
103 return;
104
93 InspectorInstrumentation::AsyncTask asyncTask( 105 InspectorInstrumentation::AsyncTask asyncTask(
94 m_request->getExecutionContext(), this); 106 m_request->getExecutionContext(), this);
95 m_request->onSuccess(wrapUnique(cursor), key, primaryKey, 107 m_request->onSuccess(wrapUnique(cursor), key, primaryKey,
96 IDBValue::create(value)); 108 IDBValue::create(value));
97 } 109 }
98 110
99 void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* backend, 111 void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* backend,
100 const WebIDBMetadata& metadata) { 112 const WebIDBMetadata& metadata) {
101 InspectorInstrumentation::AsyncTask asyncTask( 113 std::unique_ptr<WebIDBDatabase> db = wrapUnique(backend);
102 m_request->getExecutionContext(), this); 114 if (m_request) {
103 m_request->onSuccess(wrapUnique(backend), IDBDatabaseMetadata(metadata)); 115 InspectorInstrumentation::AsyncTask asyncTask(
116 m_request->getExecutionContext(), this);
117 m_request->onSuccess(std::move(db), IDBDatabaseMetadata(metadata));
118 } else if (db) {
119 db->close();
120 }
104 } 121 }
105 122
106 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key) { 123 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key) {
124 if (!m_request)
125 return;
126
107 InspectorInstrumentation::AsyncTask asyncTask( 127 InspectorInstrumentation::AsyncTask asyncTask(
108 m_request->getExecutionContext(), this); 128 m_request->getExecutionContext(), this);
109 m_request->onSuccess(key); 129 m_request->onSuccess(key);
110 } 130 }
111 131
112 void WebIDBCallbacksImpl::onSuccess(const WebIDBValue& value) { 132 void WebIDBCallbacksImpl::onSuccess(const WebIDBValue& value) {
133 if (!m_request)
134 return;
135
113 InspectorInstrumentation::AsyncTask asyncTask( 136 InspectorInstrumentation::AsyncTask asyncTask(
114 m_request->getExecutionContext(), this); 137 m_request->getExecutionContext(), this);
115 m_request->onSuccess(IDBValue::create(value)); 138 m_request->onSuccess(IDBValue::create(value));
116 } 139 }
117 140
118 void WebIDBCallbacksImpl::onSuccess(const WebVector<WebIDBValue>& values) { 141 void WebIDBCallbacksImpl::onSuccess(const WebVector<WebIDBValue>& values) {
142 if (!m_request)
143 return;
144
119 InspectorInstrumentation::AsyncTask asyncTask( 145 InspectorInstrumentation::AsyncTask asyncTask(
120 m_request->getExecutionContext(), this); 146 m_request->getExecutionContext(), this);
121 Vector<RefPtr<IDBValue>> idbValues(values.size()); 147 Vector<RefPtr<IDBValue>> idbValues(values.size());
122 for (size_t i = 0; i < values.size(); ++i) 148 for (size_t i = 0; i < values.size(); ++i)
123 idbValues[i] = IDBValue::create(values[i]); 149 idbValues[i] = IDBValue::create(values[i]);
124 m_request->onSuccess(idbValues); 150 m_request->onSuccess(idbValues);
125 } 151 }
126 152
127 void WebIDBCallbacksImpl::onSuccess(long long value) { 153 void WebIDBCallbacksImpl::onSuccess(long long value) {
154 if (!m_request)
155 return;
156
128 InspectorInstrumentation::AsyncTask asyncTask( 157 InspectorInstrumentation::AsyncTask asyncTask(
129 m_request->getExecutionContext(), this); 158 m_request->getExecutionContext(), this);
130 m_request->onSuccess(value); 159 m_request->onSuccess(value);
131 } 160 }
132 161
133 void WebIDBCallbacksImpl::onSuccess() { 162 void WebIDBCallbacksImpl::onSuccess() {
163 if (!m_request)
164 return;
165
134 InspectorInstrumentation::AsyncTask asyncTask( 166 InspectorInstrumentation::AsyncTask asyncTask(
135 m_request->getExecutionContext(), this); 167 m_request->getExecutionContext(), this);
136 m_request->onSuccess(); 168 m_request->onSuccess();
137 } 169 }
138 170
139 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key, 171 void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key,
140 const WebIDBKey& primaryKey, 172 const WebIDBKey& primaryKey,
141 const WebIDBValue& value) { 173 const WebIDBValue& value) {
174 if (!m_request)
175 return;
176
142 InspectorInstrumentation::AsyncTask asyncTask( 177 InspectorInstrumentation::AsyncTask asyncTask(
143 m_request->getExecutionContext(), this); 178 m_request->getExecutionContext(), this);
144 m_request->onSuccess(key, primaryKey, IDBValue::create(value)); 179 m_request->onSuccess(key, primaryKey, IDBValue::create(value));
145 } 180 }
146 181
147 void WebIDBCallbacksImpl::onBlocked(long long oldVersion) { 182 void WebIDBCallbacksImpl::onBlocked(long long oldVersion) {
183 if (!m_request)
184 return;
185
148 InspectorInstrumentation::AsyncTask asyncTask( 186 InspectorInstrumentation::AsyncTask asyncTask(
149 m_request->getExecutionContext(), this); 187 m_request->getExecutionContext(), this);
150 m_request->onBlocked(oldVersion); 188 m_request->onBlocked(oldVersion);
151 } 189 }
152 190
153 void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, 191 void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion,
154 WebIDBDatabase* database, 192 WebIDBDatabase* database,
155 const WebIDBMetadata& metadata, 193 const WebIDBMetadata& metadata,
156 unsigned short dataLoss, 194 unsigned short dataLoss,
157 WebString dataLossMessage) { 195 WebString dataLossMessage) {
158 InspectorInstrumentation::AsyncTask asyncTask( 196 std::unique_ptr<WebIDBDatabase> db = wrapUnique(database);
159 m_request->getExecutionContext(), this); 197 if (m_request) {
160 m_request->onUpgradeNeeded( 198 InspectorInstrumentation::AsyncTask asyncTask(
161 oldVersion, wrapUnique(database), IDBDatabaseMetadata(metadata), 199 m_request->getExecutionContext(), this);
162 static_cast<WebIDBDataLoss>(dataLoss), dataLossMessage); 200 m_request->onUpgradeNeeded(
201 oldVersion, std::move(db), IDBDatabaseMetadata(metadata),
202 static_cast<WebIDBDataLoss>(dataLoss), dataLossMessage);
203 } else {
204 db->close();
205 }
206 }
207
208 void WebIDBCallbacksImpl::detach() {
209 m_request.clear();
163 } 210 }
164 211
165 } // namespace blink 212 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698