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

Side by Side 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, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" 5 #include "content/browser/in_process_webkit/indexed_db_callbacks.h"
6 6
7 #include "content/common/indexed_db/indexed_db_messages.h" 7 #include "content/common/indexed_db/indexed_db_messages.h"
8 #include "webkit/quota/quota_manager.h" 8 #include "webkit/quota/quota_manager.h"
9 9
10 using content::IndexedDBKey; 10 using content::IndexedDBKey;
11 using content::IndexedDBKeyPath; 11 using content::IndexedDBKeyPath;
12 using content::SerializedScriptValue; 12 using content::SerializedScriptValue;
13 13
14 namespace {
15 const int32 kDatabaseNotAdded = -1;
16 }
17
14 IndexedDBCallbacksBase::IndexedDBCallbacksBase( 18 IndexedDBCallbacksBase::IndexedDBCallbacksBase(
15 IndexedDBDispatcherHost* dispatcher_host, 19 IndexedDBDispatcherHost* dispatcher_host,
16 int32 thread_id, 20 int32 thread_id,
17 int32 response_id) 21 int32 response_id)
18 : dispatcher_host_(dispatcher_host), 22 : dispatcher_host_(dispatcher_host),
19 response_id_(response_id), 23 response_id_(response_id),
20 thread_id_(thread_id) { 24 thread_id_(thread_id) {
21 } 25 }
22 26
23 IndexedDBCallbacksBase::~IndexedDBCallbacksBase() {} 27 IndexedDBCallbacksBase::~IndexedDBCallbacksBase() {}
24 28
25 void IndexedDBCallbacksBase::onError(const WebKit::WebIDBDatabaseError& error) { 29 void IndexedDBCallbacksBase::onError(const WebKit::WebIDBDatabaseError& error) {
26 dispatcher_host_->Send(new IndexedDBMsg_CallbacksError( 30 dispatcher_host_->Send(new IndexedDBMsg_CallbacksError(
27 thread_id_, response_id_, error.code(), error.message())); 31 thread_id_, response_id_, error.code(), error.message()));
28 } 32 }
29 33
30 void IndexedDBCallbacksBase::onBlocked(long long old_version) { 34 void IndexedDBCallbacksBase::onBlocked(long long old_version) {
31 dispatcher_host_->Send(new IndexedDBMsg_CallbacksIntBlocked( 35 dispatcher_host_->Send(new IndexedDBMsg_CallbacksIntBlocked(
32 thread_id_, response_id_, old_version)); 36 thread_id_, response_id_, old_version));
33 } 37 }
34 38
35 void IndexedDBCallbacksBase::onBlocked() { 39 void IndexedDBCallbacksBase::onBlocked() {
36 dispatcher_host_->Send(new IndexedDBMsg_CallbacksBlocked(thread_id_, 40 dispatcher_host_->Send(new IndexedDBMsg_CallbacksBlocked(thread_id_,
37 response_id_)); 41 response_id_));
38 } 42 }
39 43
40 template<> 44 IndexedDBCallbacksTransaction::IndexedDBCallbacksTransaction(
41 void IndexedDBCallbacks<WebKit::WebIDBDatabase>::onUpgradeNeeded( 45 IndexedDBDispatcherHost* dispatcher_host,
46 int32 thread_id,
47 int32 response_id,
48 const GURL& origin_url)
49 : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id),
50 origin_url_(origin_url) {
51 }
52
53 void IndexedDBCallbacksTransaction::onSuccess(
54 WebKit::WebIDBTransaction* idb_object) {
55 int32 object_id =
56 dispatcher_host()->Add(idb_object, thread_id(), origin_url_);
57 dispatcher_host()->Send(
58 new IndexedDBMsg_CallbacksSuccessIDBTransaction(thread_id(),
59 response_id(), object_id));
60 }
61
62 IndexedDBCallbacksDatabase::IndexedDBCallbacksDatabase(
63 IndexedDBDispatcherHost* dispatcher_host,
64 int32 thread_id,
65 int32 response_id,
66 const GURL& origin_url)
67 : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id),
68 origin_url_(origin_url),
69 database_id_(kDatabaseNotAdded) {
70 }
71
72 void IndexedDBCallbacksDatabase::onSuccess(
73 WebKit::WebIDBDatabase* idb_object) {
74 int32 object_id = database_id_;
75 if (object_id == kDatabaseNotAdded) {
76 object_id = dispatcher_host()->Add(idb_object, thread_id(), origin_url_);
77 } else {
78 // We already have this database and don't need a new copy of it.
79 delete idb_object;
80 }
81 dispatcher_host()->Send(
82 new IndexedDBMsg_CallbacksSuccessIDBDatabase(thread_id(), response_id(),
83 object_id));
84 }
85
86 void IndexedDBCallbacksDatabase::onUpgradeNeeded(
42 long long old_version, 87 long long old_version,
43 WebKit::WebIDBTransaction* transaction, 88 WebKit::WebIDBTransaction* transaction,
44 WebKit::WebIDBDatabase* database) { 89 WebKit::WebIDBDatabase* database) {
45 int32 transaction_id = dispatcher_host()->Add(transaction, thread_id(), 90 int32 transaction_id = dispatcher_host()->Add(transaction, thread_id(),
46 origin_url_); 91 origin_url_);
47 int32 database_id = dispatcher_host()->Add(database, thread_id(), 92 int32 database_id = dispatcher_host()->Add(database, thread_id(),
48 origin_url_); 93 origin_url_);
49 database_id_ = database_id; 94 database_id_ = database_id;
50 dispatcher_host()->Send( 95 dispatcher_host()->Send(
51 new IndexedDBMsg_CallbacksUpgradeNeeded( 96 new IndexedDBMsg_CallbacksUpgradeNeeded(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 198
154 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess( 199 void IndexedDBCallbacks<WebKit::WebSerializedScriptValue>::onSuccess(
155 const WebKit::WebSerializedScriptValue& value, 200 const WebKit::WebSerializedScriptValue& value,
156 const WebKit::WebIDBKey& primaryKey, 201 const WebKit::WebIDBKey& primaryKey,
157 const WebKit::WebIDBKeyPath& keyPath) { 202 const WebKit::WebIDBKeyPath& keyPath) {
158 dispatcher_host()->Send( 203 dispatcher_host()->Send(
159 new IndexedDBMsg_CallbacksSuccessSerializedScriptValueWithKey( 204 new IndexedDBMsg_CallbacksSuccessSerializedScriptValueWithKey(
160 thread_id(), response_id(), SerializedScriptValue(value), 205 thread_id(), response_id(), SerializedScriptValue(value),
161 IndexedDBKey(primaryKey), IndexedDBKeyPath(keyPath))); 206 IndexedDBKey(primaryKey), IndexedDBKeyPath(keyPath)));
162 } 207 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698