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

Unified Diff: content/browser/in_process_webkit/indexed_db_callbacks.cc

Issue 10896030: Change some IndexedDBCallbacks<> specializations to derived classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to ToT 2 Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/in_process_webkit/indexed_db_callbacks.cc
diff --git a/content/browser/in_process_webkit/indexed_db_callbacks.cc b/content/browser/in_process_webkit/indexed_db_callbacks.cc
index 291e2fbdb9dca42c07c2d106f3782b989179584c..f239ddd7f9a7526b8465d8da76dae926730569bb 100644
--- a/content/browser/in_process_webkit/indexed_db_callbacks.cc
+++ b/content/browser/in_process_webkit/indexed_db_callbacks.cc
@@ -11,6 +11,10 @@ using content::IndexedDBKey;
using content::IndexedDBKeyPath;
using content::SerializedScriptValue;
+namespace {
+const int32 kDatabaseNotAdded = -1;
+}
+
IndexedDBCallbacksBase::IndexedDBCallbacksBase(
IndexedDBDispatcherHost* dispatcher_host,
int32 thread_id,
@@ -37,8 +41,49 @@ void IndexedDBCallbacksBase::onBlocked() {
response_id_));
}
-template<>
-void IndexedDBCallbacks<WebKit::WebIDBDatabase>::onUpgradeNeeded(
+IndexedDBCallbacksTransaction::IndexedDBCallbacksTransaction(
+ IndexedDBDispatcherHost* dispatcher_host,
+ int32 thread_id,
+ int32 response_id,
+ const GURL& origin_url)
+ : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id),
+ origin_url_(origin_url) {
+}
+
+void IndexedDBCallbacksTransaction::onSuccess(
+ WebKit::WebIDBTransaction* idb_object) {
+ int32 object_id =
+ dispatcher_host()->Add(idb_object, thread_id(), origin_url_);
+ dispatcher_host()->Send(
+ new IndexedDBMsg_CallbacksSuccessIDBTransaction(thread_id(),
+ response_id(), object_id));
+}
+
+IndexedDBCallbacksDatabase::IndexedDBCallbacksDatabase(
+ IndexedDBDispatcherHost* dispatcher_host,
+ int32 thread_id,
+ int32 response_id,
+ const GURL& origin_url)
+ : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id),
+ origin_url_(origin_url),
+ database_id_(kDatabaseNotAdded) {
+}
+
+void IndexedDBCallbacksDatabase::onSuccess(
+ WebKit::WebIDBDatabase* idb_object) {
+ int32 object_id = database_id_;
+ if (object_id == kDatabaseNotAdded) {
+ object_id = dispatcher_host()->Add(idb_object, thread_id(), origin_url_);
+ } else {
+ // We already have this database and don't need a new copy of it.
+ delete idb_object;
+ }
+ dispatcher_host()->Send(
+ new IndexedDBMsg_CallbacksSuccessIDBDatabase(thread_id(), response_id(),
+ object_id));
+}
+
+void IndexedDBCallbacksDatabase::onUpgradeNeeded(
long long old_version,
WebKit::WebIDBTransaction* transaction,
WebKit::WebIDBDatabase* database) {

Powered by Google App Engine
This is Rietveld 408576698