diff options
author | jsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-01 22:54:07 +0000 |
---|---|---|
committer | jsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-01 22:54:07 +0000 |
commit | 6abf88deaa410566ad4d57717e6fa204a9c85fb6 (patch) | |
tree | edfb54490e1814fc1b43686e4dc74b1815d02caf /content | |
parent | b5167a3a9773bd348e1ab49e12545d6a6bdc2205 (diff) | |
download | chromium_src-6abf88deaa410566ad4d57717e6fa204a9c85fb6.zip chromium_src-6abf88deaa410566ad4d57717e6fa204a9c85fb6.tar.gz chromium_src-6abf88deaa410566ad4d57717e6fa204a9c85fb6.tar.bz2 |
IndexedDB: Remove IndexedDBCallbacksWrapper
Eliminate another bit of cruft from the Blink migration by merging
IndexedDBCallbacks and IndexedDBCallbacksWrapper.
BUG=234278
R=alecflett@chromium.org,dgrogan@chromium.org
TBR=jam@chromium.org
Review URL: https://chromiumcodereview.appspot.com/18241003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
18 files changed, 536 insertions, 808 deletions
diff --git a/content/browser/indexed_db/indexed_db_callbacks.cc b/content/browser/indexed_db/indexed_db_callbacks.cc index 51d44e8..b0f063e 100644 --- a/content/browser/indexed_db/indexed_db_callbacks.cc +++ b/content/browser/indexed_db/indexed_db_callbacks.cc @@ -7,6 +7,8 @@ #include <algorithm> #include <vector> +#include "content/browser/indexed_db/indexed_db_cursor.h" +#include "content/browser/indexed_db/indexed_db_database_callbacks.h" #include "content/browser/indexed_db/indexed_db_database_error.h" #include "content/browser/indexed_db/indexed_db_metadata.h" #include "content/browser/indexed_db/webidbdatabase_impl.h" @@ -18,278 +20,318 @@ using WebKit::WebIDBCallbacks; namespace content { namespace { -const int32 kDatabaseNotAdded = -1; +const int32 kNoCursor = -1; +const int32 kNoDatabase = -1; +const int32 kNoDatabaseCallbacks = -1; +const int64 kNoTransaction = -1; } -IndexedDBCallbacksBase::IndexedDBCallbacksBase( - IndexedDBDispatcherHost* dispatcher_host, - int32 ipc_thread_id, - int32 ipc_callbacks_id) - : dispatcher_host_(dispatcher_host), +IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, + int32 ipc_thread_id, + int32 ipc_callbacks_id) + : did_complete_(false), + did_create_proxy_(false), + dispatcher_host_(dispatcher_host), ipc_callbacks_id_(ipc_callbacks_id), - ipc_thread_id_(ipc_thread_id) {} + ipc_thread_id_(ipc_thread_id), + ipc_cursor_id_(kNoCursor), + host_transaction_id_(kNoTransaction), + ipc_database_id_(kNoDatabase), + ipc_database_callbacks_id_(kNoDatabaseCallbacks) {} + +IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, + int32 ipc_thread_id, + int32 ipc_callbacks_id, + int32 ipc_cursor_id) + : did_complete_(false), + did_create_proxy_(false), + dispatcher_host_(dispatcher_host), + ipc_callbacks_id_(ipc_callbacks_id), + ipc_thread_id_(ipc_thread_id), + ipc_cursor_id_(ipc_cursor_id), + host_transaction_id_(kNoTransaction), + ipc_database_id_(kNoDatabase), + ipc_database_callbacks_id_(kNoDatabaseCallbacks) {} + +IndexedDBCallbacks::IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, + int32 ipc_thread_id, + int32 ipc_callbacks_id, + int32 ipc_database_callbacks_id, + int64 host_transaction_id, + const GURL& origin_url) + : did_complete_(false), + did_create_proxy_(false), + dispatcher_host_(dispatcher_host), + ipc_callbacks_id_(ipc_callbacks_id), + ipc_thread_id_(ipc_thread_id), + ipc_cursor_id_(kNoCursor), + host_transaction_id_(host_transaction_id), + origin_url_(origin_url), + ipc_database_id_(kNoDatabase), + ipc_database_callbacks_id_(ipc_database_callbacks_id) {} -IndexedDBCallbacksBase::~IndexedDBCallbacksBase() {} +IndexedDBCallbacks::~IndexedDBCallbacks() {} + +void IndexedDBCallbacks::OnError(const IndexedDBDatabaseError& error) { + DCHECK(dispatcher_host_); -void IndexedDBCallbacksBase::onError(const IndexedDBDatabaseError& error) { dispatcher_host_->Send(new IndexedDBMsg_CallbacksError( ipc_thread_id_, ipc_callbacks_id_, error.code(), error.message())); + dispatcher_host_ = NULL; } -void IndexedDBCallbacksBase::onBlocked(long long old_version) { - dispatcher_host_->Send(new IndexedDBMsg_CallbacksIntBlocked( - ipc_thread_id_, ipc_callbacks_id_, old_version)); -} +void IndexedDBCallbacks::OnSuccess(const std::vector<string16>& value) { + DCHECK(dispatcher_host_); -void IndexedDBCallbacksBase::onSuccess(const std::vector<string16>& value) { - NOTREACHED(); -} + DCHECK_EQ(kNoCursor, ipc_cursor_id_); + DCHECK_EQ(kNoTransaction, host_transaction_id_); + DCHECK_EQ(kNoDatabase, ipc_database_id_); + DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); -void IndexedDBCallbacksBase::onSuccess( - WebIDBDatabaseImpl* idb_object, - const IndexedDBDatabaseMetadata& metadata) { - NOTREACHED(); -} + std::vector<string16> list; + for (unsigned i = 0; i < value.size(); ++i) + list.push_back(value[i]); -void IndexedDBCallbacksBase::onUpgradeNeeded( - long long old_version, - WebIDBDatabaseImpl* database, - const IndexedDBDatabaseMetadata& /*metadata*/, - WebKit::WebIDBCallbacks::DataLoss data_loss) { - NOTREACHED(); + dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessStringList( + ipc_thread_id_, ipc_callbacks_id_, list)); + dispatcher_host_ = NULL; } -void IndexedDBCallbacksBase::onSuccess(IndexedDBCursor* idb_object, - const IndexedDBKey& key, - const IndexedDBKey& primaryKey, - std::vector<char>* value) { - NOTREACHED(); -} +void IndexedDBCallbacks::OnBlocked(int64 existing_version) { + DCHECK(dispatcher_host_); + DCHECK_EQ(kNoCursor, ipc_cursor_id_); -void IndexedDBCallbacksBase::onSuccess(const IndexedDBKey& key, - const IndexedDBKey& primaryKey, - std::vector<char>* value) { - NOTREACHED(); + dispatcher_host_->Send(new IndexedDBMsg_CallbacksIntBlocked( + ipc_thread_id_, ipc_callbacks_id_, existing_version)); } -void IndexedDBCallbacksBase::onSuccess(std::vector<char>* value) { - NOTREACHED(); -} +void IndexedDBCallbacks::OnUpgradeNeeded( + int64 old_version, + scoped_refptr<IndexedDBDatabase> database, + const IndexedDBDatabaseMetadata& metadata, + WebIDBCallbacks::DataLoss data_loss) { + DCHECK(dispatcher_host_); + DCHECK_EQ(kNoCursor, ipc_cursor_id_); + did_create_proxy_ = true; -void IndexedDBCallbacksBase::onSuccessWithPrefetch( - const std::vector<IndexedDBKey>& keys, - const std::vector<IndexedDBKey>& primaryKeys, - const std::vector<std::vector<char> >& values) { - NOTREACHED(); -} + WebIDBDatabaseImpl* web_database = + new WebIDBDatabaseImpl(database, database_callbacks_); -void IndexedDBCallbacksBase::onSuccess(const IndexedDBKey& value) { - NOTREACHED(); -} + dispatcher_host_->RegisterTransactionId(host_transaction_id_, origin_url_); + int32 ipc_database_id = + dispatcher_host_->Add(web_database, ipc_thread_id_, origin_url_); + ipc_database_id_ = ipc_database_id; + IndexedDBMsg_CallbacksUpgradeNeeded_Params params; + params.ipc_thread_id = ipc_thread_id_; + params.ipc_callbacks_id = ipc_callbacks_id_; + params.ipc_database_id = ipc_database_id; + params.ipc_database_callbacks_id = ipc_database_callbacks_id_; + params.old_version = old_version; + params.idb_metadata = IndexedDBDispatcherHost::ConvertMetadata(metadata); + params.data_loss = data_loss; + dispatcher_host_->Send(new IndexedDBMsg_CallbacksUpgradeNeeded(params)); -void IndexedDBCallbacksBase::onSuccess(std::vector<char>* value, - const IndexedDBKey& key, - const IndexedDBKeyPath& keyPath) { - NOTREACHED(); + database_callbacks_ = NULL; } -void IndexedDBCallbacksBase::onSuccess(long long value) { NOTREACHED(); } +void IndexedDBCallbacks::OnSuccess(scoped_refptr<IndexedDBDatabase> database, + const IndexedDBDatabaseMetadata& metadata) { + DCHECK(dispatcher_host_); + DCHECK_EQ(kNoCursor, ipc_cursor_id_); -void IndexedDBCallbacksBase::onSuccess() { NOTREACHED(); } + scoped_refptr<IndexedDBCallbacks> self(this); -IndexedDBCallbacksDatabase::IndexedDBCallbacksDatabase( - IndexedDBDispatcherHost* dispatcher_host, - int32 ipc_thread_id, - int32 ipc_callbacks_id, - int32 ipc_database_callbacks_id, - int64 host_transaction_id, - const GURL& origin_url) - : IndexedDBCallbacksBase(dispatcher_host, ipc_thread_id, ipc_callbacks_id), - host_transaction_id_(host_transaction_id), - origin_url_(origin_url), - ipc_database_id_(kDatabaseNotAdded), - ipc_database_callbacks_id_(ipc_database_callbacks_id) {} + WebIDBDatabaseImpl* impl = + did_create_proxy_ ? 0 + : new WebIDBDatabaseImpl(database, database_callbacks_); + database_callbacks_ = NULL; -void IndexedDBCallbacksDatabase::onSuccess( - WebIDBDatabaseImpl* idb_object, - const IndexedDBDatabaseMetadata& metadata) { int32 ipc_object_id = ipc_database_id_; - if (ipc_object_id == kDatabaseNotAdded) { - ipc_object_id = - dispatcher_host()->Add(idb_object, ipc_thread_id(), origin_url_); - } else { - // We already have this database and don't need a new copy of it. - delete idb_object; - } - const ::IndexedDBDatabaseMetadata idb_metadata = - IndexedDBDispatcherHost::ConvertMetadata(metadata); - - dispatcher_host()->Send( - new IndexedDBMsg_CallbacksSuccessIDBDatabase(ipc_thread_id(), - ipc_callbacks_id(), - ipc_database_callbacks_id_, - ipc_object_id, - idb_metadata)); + if (ipc_object_id == kNoDatabase) + ipc_object_id = dispatcher_host_->Add(impl, ipc_thread_id_, origin_url_); + + dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessIDBDatabase( + ipc_thread_id_, + ipc_callbacks_id_, + ipc_database_callbacks_id_, + ipc_object_id, + IndexedDBDispatcherHost::ConvertMetadata(metadata))); + dispatcher_host_ = NULL; } -void IndexedDBCallbacksDatabase::onUpgradeNeeded( - long long old_version, - WebIDBDatabaseImpl* database, - const IndexedDBDatabaseMetadata& metadata, - WebIDBCallbacks::DataLoss data_loss) { - dispatcher_host()->RegisterTransactionId(host_transaction_id_, origin_url_); - int32 ipc_database_id = - dispatcher_host()->Add(database, ipc_thread_id(), origin_url_); - ipc_database_id_ = ipc_database_id; - IndexedDBMsg_CallbacksUpgradeNeeded_Params params; - params.ipc_thread_id = ipc_thread_id(); - params.ipc_callbacks_id = ipc_callbacks_id(); - params.ipc_database_id = ipc_database_id; - params.ipc_database_callbacks_id = ipc_database_callbacks_id_; - params.old_version = old_version; - params.idb_metadata = IndexedDBDispatcherHost::ConvertMetadata(metadata); - params.data_loss = data_loss; - dispatcher_host()->Send(new IndexedDBMsg_CallbacksUpgradeNeeded(params)); +void IndexedDBCallbacks::SetDatabaseCallbacks( + scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks) { + database_callbacks_ = database_callbacks; } -void IndexedDBCallbacks<IndexedDBCursor>::onSuccess( - IndexedDBCursor* idb_cursor, - const IndexedDBKey& key, - const IndexedDBKey& primaryKey, - std::vector<char>* value) { - int32 ipc_object_id = dispatcher_host()->Add(idb_cursor); +void IndexedDBCallbacks::OnSuccess(scoped_refptr<IndexedDBCursor> cursor, + const IndexedDBKey& key, + const IndexedDBKey& primary_key, + std::vector<char>* value) { + DCHECK(dispatcher_host_); + + DCHECK_EQ(kNoTransaction, host_transaction_id_); + DCHECK_EQ(kNoDatabase, ipc_database_id_); + DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); + + int32 ipc_object_id = dispatcher_host_->Add(cursor); IndexedDBMsg_CallbacksSuccessIDBCursor_Params params; - params.ipc_thread_id = ipc_thread_id(); - params.ipc_callbacks_id = ipc_callbacks_id(); + params.ipc_thread_id = ipc_thread_id_; + params.ipc_callbacks_id = ipc_callbacks_id_; params.ipc_cursor_id = ipc_object_id; params.key = key; - params.primary_key = primaryKey; + params.primary_key = primary_key; if (value && !value->empty()) std::swap(params.value, *value); // TODO(alecflett): Avoid a copy here: the whole params object is // being copied into the message. - dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params)); -} + dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params)); -void IndexedDBCallbacks<IndexedDBCursor>::onSuccess(std::vector<char>* value) { - std::vector<char> value_copy; - if (value && !value->empty()) - std::swap(value_copy, *value); - dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessValue( - ipc_thread_id(), - ipc_callbacks_id(), - // TODO(alecflett): avoid a copy here. - value_copy)); + dispatcher_host_ = NULL; } -void IndexedDBCallbacks<IndexedDBCursor>::onSuccess( - const IndexedDBKey& key, - const IndexedDBKey& primaryKey, - std::vector<char>* value) { - DCHECK_NE(ipc_cursor_id_, -1); +void IndexedDBCallbacks::OnSuccess(const IndexedDBKey& key, + const IndexedDBKey& primary_key, + std::vector<char>* value) { + DCHECK(dispatcher_host_); + + DCHECK_NE(kNoCursor, ipc_cursor_id_); + DCHECK_EQ(kNoTransaction, host_transaction_id_); + DCHECK_EQ(kNoDatabase, ipc_database_id_); + DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); + IndexedDBCursor* idb_cursor = - dispatcher_host()->GetCursorFromId(ipc_cursor_id_); + dispatcher_host_->GetCursorFromId(ipc_cursor_id_); DCHECK(idb_cursor); if (!idb_cursor) return; IndexedDBMsg_CallbacksSuccessCursorContinue_Params params; - params.ipc_thread_id = ipc_thread_id(); - params.ipc_callbacks_id = ipc_callbacks_id(); + params.ipc_thread_id = ipc_thread_id_; + params.ipc_callbacks_id = ipc_callbacks_id_; params.ipc_cursor_id = ipc_cursor_id_; params.key = key; - params.primary_key = primaryKey; + params.primary_key = primary_key; if (value && !value->empty()) std::swap(params.value, *value); // TODO(alecflett): Avoid a copy here: the whole params object is // being copied into the message. - dispatcher_host()->Send( + dispatcher_host_->Send( new IndexedDBMsg_CallbacksSuccessCursorContinue(params)); + dispatcher_host_ = NULL; } -void IndexedDBCallbacks<IndexedDBCursor>::onSuccessWithPrefetch( +void IndexedDBCallbacks::OnSuccessWithPrefetch( const std::vector<IndexedDBKey>& keys, - const std::vector<IndexedDBKey>& primaryKeys, + const std::vector<IndexedDBKey>& primary_keys, const std::vector<std::vector<char> >& values) { - DCHECK_NE(ipc_cursor_id_, -1); + DCHECK_EQ(keys.size(), primary_keys.size()); + DCHECK_EQ(keys.size(), values.size()); + + DCHECK(dispatcher_host_); + + DCHECK_NE(kNoCursor, ipc_cursor_id_); + DCHECK_EQ(kNoTransaction, host_transaction_id_); + DCHECK_EQ(kNoDatabase, ipc_database_id_); + DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); std::vector<IndexedDBKey> msgKeys; std::vector<IndexedDBKey> msgPrimaryKeys; for (size_t i = 0; i < keys.size(); ++i) { msgKeys.push_back(keys[i]); - msgPrimaryKeys.push_back(primaryKeys[i]); + msgPrimaryKeys.push_back(primary_keys[i]); } IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params params; - params.ipc_thread_id = ipc_thread_id(); - params.ipc_callbacks_id = ipc_callbacks_id(); + params.ipc_thread_id = ipc_thread_id_; + params.ipc_callbacks_id = ipc_callbacks_id_; params.ipc_cursor_id = ipc_cursor_id_; params.keys = msgKeys; params.primary_keys = msgPrimaryKeys; params.values = values; - dispatcher_host()->Send( + dispatcher_host_->Send( new IndexedDBMsg_CallbacksSuccessCursorPrefetch(params)); + dispatcher_host_ = NULL; } -void IndexedDBCallbacks<IndexedDBKey>::onSuccess(const IndexedDBKey& value) { - dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIndexedDBKey( - ipc_thread_id(), ipc_callbacks_id(), IndexedDBKey(value))); -} +void IndexedDBCallbacks::OnSuccess(std::vector<char>* value, + const IndexedDBKey& key, + const IndexedDBKeyPath& key_path) { + DCHECK(dispatcher_host_); -void IndexedDBCallbacks<std::vector<string16> >::onSuccess( - const std::vector<string16>& value) { + DCHECK_EQ(kNoCursor, ipc_cursor_id_); + DCHECK_EQ(kNoTransaction, host_transaction_id_); + DCHECK_EQ(kNoDatabase, ipc_database_id_); + DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); - std::vector<string16> list; - for (unsigned i = 0; i < value.size(); ++i) - list.push_back(value[i]); - - dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessStringList( - ipc_thread_id(), ipc_callbacks_id(), list)); -} - -void IndexedDBCallbacks<std::vector<char> >::onSuccess( - std::vector<char>* value) { std::vector<char> value_copy; if (value && !value->empty()) std::swap(value_copy, *value); - dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessValue( - ipc_thread_id(), - ipc_callbacks_id(), - // TODO(alecflett): avoid a copy here - value_copy)); + dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessValueWithKey( + ipc_thread_id_, + ipc_callbacks_id_, + // TODO(alecflett): Avoid a copy here. + value_copy, + key, + key_path)); + dispatcher_host_ = NULL; } -void IndexedDBCallbacks<std::vector<char> >::onSuccess( - std::vector<char>* value, - const IndexedDBKey& primaryKey, - const IndexedDBKeyPath& keyPath) { +void IndexedDBCallbacks::OnSuccess(std::vector<char>* value) { + DCHECK(dispatcher_host_); + + DCHECK_EQ(kNoTransaction, host_transaction_id_); + DCHECK_EQ(kNoDatabase, ipc_database_id_); + DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); + std::vector<char> value_copy; if (value && !value->empty()) std::swap(value_copy, *value); - dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessValueWithKey( - ipc_thread_id(), - ipc_callbacks_id(), - // TODO(alecflett): Avoid a copy here. - value_copy, - IndexedDBKey(primaryKey), - IndexedDBKeyPath(keyPath))); + dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessValue( + ipc_thread_id_, + ipc_callbacks_id_, + // TODO(alecflett): avoid a copy here. + value_copy)); + dispatcher_host_ = NULL; } -void IndexedDBCallbacks<std::vector<char> >::onSuccess(long long value) { - dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessInteger( - ipc_thread_id(), ipc_callbacks_id(), value)); +void IndexedDBCallbacks::OnSuccess(const IndexedDBKey& value) { + DCHECK(dispatcher_host_); + + DCHECK_EQ(kNoCursor, ipc_cursor_id_); + DCHECK_EQ(kNoTransaction, host_transaction_id_); + DCHECK_EQ(kNoDatabase, ipc_database_id_); + DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); + + dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessIndexedDBKey( + ipc_thread_id_, ipc_callbacks_id_, value)); + dispatcher_host_ = NULL; } -void IndexedDBCallbacks<std::vector<char> >::onSuccess() { - dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessUndefined( - ipc_thread_id(), ipc_callbacks_id())); +void IndexedDBCallbacks::OnSuccess(int64 value) { + DCHECK(dispatcher_host_); + + DCHECK_EQ(kNoCursor, ipc_cursor_id_); + DCHECK_EQ(kNoTransaction, host_transaction_id_); + DCHECK_EQ(kNoDatabase, ipc_database_id_); + DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); + + dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessInteger( + ipc_thread_id_, ipc_callbacks_id_, value)); + dispatcher_host_ = NULL; } -void IndexedDBCallbacks<std::vector<char> >::onSuccess( - const IndexedDBKey& value) { - dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIndexedDBKey( - ipc_thread_id(), ipc_callbacks_id(), value)); +void IndexedDBCallbacks::OnSuccess() { + DCHECK(dispatcher_host_); + + DCHECK_EQ(kNoTransaction, host_transaction_id_); + DCHECK_EQ(kNoDatabase, ipc_database_id_); + DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_); + + dispatcher_host_->Send(new IndexedDBMsg_CallbacksSuccessUndefined( + ipc_thread_id_, ipc_callbacks_id_)); + dispatcher_host_ = NULL; } } // namespace content diff --git a/content/browser/indexed_db/indexed_db_callbacks.h b/content/browser/indexed_db/indexed_db_callbacks.h index 499691a..6ed751c 100644 --- a/content/browser/indexed_db/indexed_db_callbacks.h +++ b/content/browser/indexed_db/indexed_db_callbacks.h @@ -5,203 +5,163 @@ #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ +#include <string> +#include <vector> + #include "base/basictypes.h" +#include "base/logging.h" #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "base/strings/string16.h" +#include "content/browser/indexed_db/indexed_db_database_error.h" #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" +#include "content/common/indexed_db/indexed_db_key.h" +#include "content/common/indexed_db/indexed_db_key_path.h" #include "googleurl/src/gurl.h" #include "third_party/WebKit/public/platform/WebIDBCallbacks.h" #include "third_party/WebKit/public/platform/WebIDBDatabase.h" namespace content { class IndexedDBCursor; -class IndexedDBDatabaseError; +class IndexedDBDatabase; +class IndexedDBDatabaseCallbacks; class WebIDBDatabaseImpl; struct IndexedDBDatabaseMetadata; -class IndexedDBCallbacksBase { +class CONTENT_EXPORT IndexedDBCallbacks + : public base::RefCounted<IndexedDBCallbacks> { public: - virtual ~IndexedDBCallbacksBase(); - - virtual void onError(const IndexedDBDatabaseError& error); - virtual void onBlocked(long long old_version); - - // implemented by subclasses, but need to be called later - virtual void onSuccess(const std::vector<string16>& value); - virtual void onSuccess(WebIDBDatabaseImpl* idb_object, - const IndexedDBDatabaseMetadata& metadata); - virtual void onUpgradeNeeded(long long old_version, - WebIDBDatabaseImpl* database, - const IndexedDBDatabaseMetadata&, - WebKit::WebIDBCallbacks::DataLoss data_loss); - virtual void onSuccess(IndexedDBCursor* idb_object, - const IndexedDBKey& key, - const IndexedDBKey& primaryKey, - std::vector<char>* value); - virtual void onSuccess(const IndexedDBKey& key, - const IndexedDBKey& primaryKey, - std::vector<char>* value); - virtual void onSuccess(std::vector<char>* value); - virtual void onSuccessWithPrefetch( - const std::vector<IndexedDBKey>& keys, - const std::vector<IndexedDBKey>& primaryKeys, - const std::vector<std::vector<char> >& values); - virtual void onSuccess(const IndexedDBKey& value); - virtual void onSuccess(std::vector<char>* value, - const IndexedDBKey& key, - const IndexedDBKeyPath& keyPath); - virtual void onSuccess(long long value); - virtual void onSuccess(); + // Simple payload responses + static scoped_refptr<IndexedDBCallbacks> Create( + IndexedDBDispatcherHost* dispatcher_host, + int32 ipc_thread_id, + int32 ipc_callbacks_id) { + return make_scoped_refptr(new IndexedDBCallbacks( + dispatcher_host, ipc_thread_id, ipc_callbacks_id)); + } - protected: - IndexedDBCallbacksBase(IndexedDBDispatcherHost* dispatcher_host, - int32 ipc_thread_id, - int32 ipc_callbacks_id); - IndexedDBDispatcherHost* dispatcher_host() const { - return dispatcher_host_.get(); + // IndexedDBCursor responses + static scoped_refptr<IndexedDBCallbacks> Create( + IndexedDBDispatcherHost* dispatcher_host, + int32 ipc_thread_id, + int32 ipc_callbacks_id, + int32 ipc_cursor_id) { + return make_scoped_refptr(new IndexedDBCallbacks( + dispatcher_host, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); + } + // IndexedDBDatabase responses + static scoped_refptr<IndexedDBCallbacks> Create( + IndexedDBDispatcherHost* dispatcher_host, + int32 ipc_thread_id, + int32 ipc_callbacks_id, + int32 ipc_database_callbacks_id, + int64 host_transaction_id, + const GURL& origin_url) { + return make_scoped_refptr(new IndexedDBCallbacks(dispatcher_host, + ipc_thread_id, + ipc_callbacks_id, + ipc_database_callbacks_id, + host_transaction_id, + origin_url)); } - int32 ipc_thread_id() const { return ipc_thread_id_; } - int32 ipc_callbacks_id() const { return ipc_callbacks_id_; } - private: - scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; - int32 ipc_callbacks_id_; - int32 ipc_thread_id_; + virtual void OnError(const IndexedDBDatabaseError& error); - DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacksBase); -}; + // IndexedDBFactory::GetDatabaseNames + virtual void OnSuccess(const std::vector<string16>& string); -// TODO(dgrogan): Remove this class and change the remaining specializations -// into subclasses of IndexedDBCallbacksBase. -template <class WebObjectType> -class IndexedDBCallbacks : public IndexedDBCallbacksBase { - DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); -}; + // IndexedDBFactory::Open / DeleteDatabase + virtual void OnBlocked(int64 existing_version); -class IndexedDBCallbacksDatabase : public IndexedDBCallbacksBase { - public: - IndexedDBCallbacksDatabase(IndexedDBDispatcherHost* dispatcher_host, - int32 ipc_thread_id, - int32 ipc_callbacks_id, - int32 ipc_database_callbacks_id, - int64 host_transaction_id, - const GURL& origin_url); - - virtual void onSuccess(WebIDBDatabaseImpl* idb_object, - const IndexedDBDatabaseMetadata& metadata) OVERRIDE; - virtual void onUpgradeNeeded(long long old_version, - WebIDBDatabaseImpl* database, - const IndexedDBDatabaseMetadata&, - WebKit::WebIDBCallbacks::DataLoss data_loss) - OVERRIDE; + // IndexedDBFactory::Open + virtual void OnUpgradeNeeded( + int64 old_version, + scoped_refptr<IndexedDBDatabase> db, + const content::IndexedDBDatabaseMetadata& metadata, + WebKit::WebIDBCallbacks::DataLoss data_loss); + virtual void OnSuccess(scoped_refptr<IndexedDBDatabase> db, + const content::IndexedDBDatabaseMetadata& metadata); + void SetDatabaseCallbacks( + scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks); - private: - int64 host_transaction_id_; - GURL origin_url_; - int32 ipc_database_id_; - int32 ipc_database_callbacks_id_; - DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacksDatabase); -}; - -// IndexedDBCursor uses: -// * onSuccess(IndexedDBCursor*, WebIDBKey, WebIDBKey, WebData) -// when an openCursor()/openKeyCursor() call has succeeded, -// * onSuccess(WebIDBKey, WebIDBKey, WebData) -// when an advance()/continue() call has succeeded, or -// * onSuccess() -// to indicate it does not contain any data, i.e., there is no key within -// the key range, or it has reached the end. -template <> -class IndexedDBCallbacks<IndexedDBCursor> : public IndexedDBCallbacksBase { - public: - IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, - int32 ipc_thread_id, - int32 ipc_callbacks_id, - int32 ipc_cursor_id) - : IndexedDBCallbacksBase(dispatcher_host, - ipc_thread_id, - ipc_callbacks_id), - ipc_cursor_id_(ipc_cursor_id) {} - - virtual void onSuccess(IndexedDBCursor* idb_object, + // IndexedDBDatabase::OpenCursor + virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor, const IndexedDBKey& key, - const IndexedDBKey& primaryKey, + const IndexedDBKey& primary_key, std::vector<char>* value); - virtual void onSuccess(const IndexedDBKey& key, - const IndexedDBKey& primaryKey, + + // IndexedDBCursor::Continue / Advance + virtual void OnSuccess(const IndexedDBKey& key, + const IndexedDBKey& primary_key, std::vector<char>* value); - virtual void onSuccess(std::vector<char>* value); - virtual void onSuccessWithPrefetch( + + // IndexedDBCursor::PrefetchContinue + virtual void OnSuccessWithPrefetch( const std::vector<IndexedDBKey>& keys, - const std::vector<IndexedDBKey>& primaryKeys, + const std::vector<IndexedDBKey>& primary_keys, const std::vector<std::vector<char> >& values); - private: - // The id of the cursor this callback concerns, or -1 if the cursor - // does not exist yet. - int32 ipc_cursor_id_; + // IndexedDBDatabase::Get (with key injection) + virtual void OnSuccess(std::vector<char>* data, + const IndexedDBKey& key, + const IndexedDBKeyPath& key_path); - DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); -}; + // IndexedDBDatabase::Get + virtual void OnSuccess(std::vector<char>* value); -// WebIDBKey is implemented in WebKit as opposed to being an interface Chromium -// implements. Thus we pass a const ___& version and thus we need this -// specialization. -template <> -class IndexedDBCallbacks<IndexedDBKey> : public IndexedDBCallbacksBase { - public: - IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, - int32 ipc_thread_id, - int32 ipc_callbacks_id) - : IndexedDBCallbacksBase(dispatcher_host, - ipc_thread_id, - ipc_callbacks_id) {} + // IndexedDBDatabase::Put / IndexedDBCursor::Update + virtual void OnSuccess(const IndexedDBKey& value); - virtual void onSuccess(const IndexedDBKey& value); + // IndexedDBDatabase::Count + virtual void OnSuccess(int64 value); - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); -}; + // IndexedDBDatabase::Delete + // IndexedDBCursor::Continue / Advance (when complete) + virtual void OnSuccess(); -template <> -class IndexedDBCallbacks< - std::vector<string16> > : public IndexedDBCallbacksBase { - public: + protected: + virtual ~IndexedDBCallbacks(); + + // Simple payload responses IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, int32 ipc_thread_id, - int32 ipc_callbacks_id) - : IndexedDBCallbacksBase(dispatcher_host, - ipc_thread_id, - ipc_callbacks_id) {} - - virtual void onSuccess(const std::vector<string16>& value); - - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); -}; + int32 ipc_callbacks_id); -// WebData is implemented in WebKit as opposed to being an interface -// Chromium implements. Thus we pass a const ___& version and thus we -// need this specialization. -template <> -class IndexedDBCallbacks<std::vector<char> > : public IndexedDBCallbacksBase { - public: + // IndexedDBCursor responses IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, int32 ipc_thread_id, - int32 ipc_callbacks_id) - : IndexedDBCallbacksBase(dispatcher_host, - ipc_thread_id, - ipc_callbacks_id) {} + int32 ipc_callbacks_id, + int32 ipc_cursor_id); - virtual void onSuccess(std::vector<char>* value); - virtual void onSuccess(std::vector<char>* value, - const IndexedDBKey& key, - const IndexedDBKeyPath& keyPath); - virtual void onSuccess(long long value); - virtual void onSuccess(); - virtual void onSuccess(const IndexedDBKey& value); + // IndexedDBDatabase responses + IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, + int32 ipc_thread_id, + int32 ipc_callbacks_id, + int32 ipc_database_callbacks_id, + int64 host_transaction_id, + const GURL& origin_url); private: - DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); + friend class base::RefCounted<IndexedDBCallbacks>; + + scoped_ptr<WebIDBDatabaseImpl> web_database_impl_; + scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_; + bool did_complete_; + bool did_create_proxy_; + + // Originally from IndexedDBCallbacks: + scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; + int32 ipc_callbacks_id_; + int32 ipc_thread_id_; + + // IndexedDBCursor callbacks ------------------------ + int32 ipc_cursor_id_; + + // IndexedDBDatabase callbacks ------------------------ + int64 host_transaction_id_; + GURL origin_url_; + int32 ipc_database_id_; + int32 ipc_database_callbacks_id_; }; } // namespace content diff --git a/content/browser/indexed_db/indexed_db_callbacks_wrapper.cc b/content/browser/indexed_db/indexed_db_callbacks_wrapper.cc deleted file mode 100644 index 3de1a08..0000000 --- a/content/browser/indexed_db/indexed_db_callbacks_wrapper.cc +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" - -#include "content/browser/indexed_db/indexed_db_callbacks.h" -#include "content/browser/indexed_db/indexed_db_cursor.h" -#include "content/browser/indexed_db/indexed_db_database_callbacks.h" -#include "content/browser/indexed_db/indexed_db_metadata.h" -#include "content/browser/indexed_db/webidbdatabase_impl.h" - -namespace content { - -using WebKit::WebIDBCallbacks; - -IndexedDBCallbacksWrapper::IndexedDBCallbacksWrapper( - IndexedDBCallbacksBase* callbacks) - : callbacks_(callbacks), did_complete_(false), did_create_proxy_(false) {} - -IndexedDBCallbacksWrapper::~IndexedDBCallbacksWrapper() {} - -void IndexedDBCallbacksWrapper::OnError(const IndexedDBDatabaseError& error) { - DCHECK(callbacks_); - callbacks_->onError(error); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::OnSuccess(const std::vector<string16>& value) { - DCHECK(callbacks_); - callbacks_->onSuccess(value); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::OnSuccess(scoped_refptr<IndexedDBCursor> cursor, - const IndexedDBKey& key, - const IndexedDBKey& primary_key, - std::vector<char>* value) { - DCHECK(callbacks_); - callbacks_->onSuccess(cursor, key, primary_key, value); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::OnSuccess(const IndexedDBKey& key) { - DCHECK(callbacks_); - callbacks_->onSuccess(key); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::OnSuccess(std::vector<char>* value) { - DCHECK(callbacks_); - callbacks_->onSuccess(value); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::OnSuccess(std::vector<char>* value, - const IndexedDBKey& key, - const IndexedDBKeyPath& key_path) { - DCHECK(callbacks_); - callbacks_->onSuccess(value, key, key_path); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::OnSuccess(int64 value) { - DCHECK(callbacks_); - callbacks_->onSuccess(value); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::OnSuccess() { - DCHECK(callbacks_); - callbacks_->onSuccess(); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::OnSuccess(const IndexedDBKey& key, - const IndexedDBKey& primary_key, - std::vector<char>* value) { - DCHECK(callbacks_); - callbacks_->onSuccess(key, primary_key, value); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::OnSuccessWithPrefetch( - const std::vector<IndexedDBKey>& keys, - const std::vector<IndexedDBKey>& primary_keys, - const std::vector<std::vector<char> >& values) { - DCHECK_EQ(keys.size(), primary_keys.size()); - DCHECK_EQ(keys.size(), values.size()); - - DCHECK(callbacks_); - callbacks_->onSuccessWithPrefetch(keys, primary_keys, values); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::OnBlocked(int64 existing_version) { - DCHECK(callbacks_); - callbacks_->onBlocked(existing_version); -} - -void IndexedDBCallbacksWrapper::OnUpgradeNeeded( - int64 old_version, - scoped_refptr<IndexedDBDatabase> database, - const IndexedDBDatabaseMetadata& metadata, - WebIDBCallbacks::DataLoss data_loss) { - DCHECK(callbacks_); - did_create_proxy_ = true; - callbacks_->onUpgradeNeeded( - old_version, - new WebIDBDatabaseImpl(database, database_callbacks_), - metadata, - data_loss); - database_callbacks_ = NULL; -} - -void IndexedDBCallbacksWrapper::OnSuccess( - scoped_refptr<IndexedDBDatabase> database, - const IndexedDBDatabaseMetadata& metadata) { - DCHECK(callbacks_); - scoped_refptr<IndexedDBCallbacksWrapper> self(this); - - WebIDBDatabaseImpl* impl = - did_create_proxy_ ? 0 - : new WebIDBDatabaseImpl(database, database_callbacks_); - database_callbacks_ = NULL; - - callbacks_->onSuccess(impl, metadata); - callbacks_.reset(); -} - -void IndexedDBCallbacksWrapper::SetDatabaseCallbacks( - scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks) { - database_callbacks_ = database_callbacks; -} -} // namespace content diff --git a/content/browser/indexed_db/indexed_db_callbacks_wrapper.h b/content/browser/indexed_db/indexed_db_callbacks_wrapper.h deleted file mode 100644 index 98f119b..0000000 --- a/content/browser/indexed_db/indexed_db_callbacks_wrapper.h +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_WRAPPER_H_ -#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_WRAPPER_H_ - -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "base/logging.h" -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "content/browser/indexed_db/indexed_db_database_callbacks.h" -#include "content/browser/indexed_db/indexed_db_database_error.h" -#include "content/common/indexed_db/indexed_db_key.h" -#include "content/common/indexed_db/indexed_db_key_path.h" -#include "third_party/WebKit/public/platform/WebIDBCallbacks.h" - -namespace content { -class IndexedDBCallbacksBase; -class IndexedDBCursor; -class IndexedDBDatabase; -class WebIDBDatabaseImpl; -struct IndexedDBDatabaseMetadata; - -class CONTENT_EXPORT IndexedDBCallbacksWrapper - : public base::RefCounted<IndexedDBCallbacksWrapper> { - public: - static scoped_refptr<IndexedDBCallbacksWrapper> Create( - IndexedDBCallbacksBase* callbacks) { - return make_scoped_refptr(new IndexedDBCallbacksWrapper(callbacks)); - } - - virtual void OnError(const IndexedDBDatabaseError& error); - // From IDBFactory.webkitGetDatabaseNames() - virtual void OnSuccess(const std::vector<string16>& string); - // From IDBObjectStore/IDBIndex.openCursor(), - // IDBIndex.openKeyCursor() - virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor, - const IndexedDBKey& key, - const IndexedDBKey& primary_key, - std::vector<char>* value); - // From IDBObjectStore.add()/put(), IDBIndex.getKey() - virtual void OnSuccess(const IndexedDBKey& key); - // From IDBObjectStore/IDBIndex.get()/count(), and various methods - // that yield null/undefined. - virtual void OnSuccess(std::vector<char>* value); - // From IDBObjectStore/IDBIndex.get() (with key injection) - virtual void OnSuccess(std::vector<char>* data, - const IndexedDBKey& key, - const IndexedDBKeyPath& key_path); - // From IDBObjectStore/IDBIndex.count() - virtual void OnSuccess(int64 value); - - // From IDBFactor.deleteDatabase(), - // IDBObjectStore/IDBIndex.get(), IDBObjectStore.delete(), - // IDBObjectStore.clear() - virtual void OnSuccess(); - - // From IDBCursor.advance()/continue() - virtual void OnSuccess(const IndexedDBKey& key, - const IndexedDBKey& primary_key, - std::vector<char>* value); - // From IDBCursor.advance()/continue() - virtual void OnSuccessWithPrefetch( - const std::vector<IndexedDBKey>& keys, - const std::vector<IndexedDBKey>& primary_keys, - const std::vector<std::vector<char> >& values); - // From IDBFactory.open()/deleteDatabase() - virtual void OnBlocked(int64 existing_version); - // From IDBFactory.open() - virtual void OnUpgradeNeeded( - int64 old_version, - scoped_refptr<IndexedDBDatabase> db, - const content::IndexedDBDatabaseMetadata& metadata, - WebKit::WebIDBCallbacks::DataLoss data_loss); - virtual void OnSuccess(scoped_refptr<IndexedDBDatabase> db, - const content::IndexedDBDatabaseMetadata& metadata); - virtual void SetDatabaseCallbacks( - scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks); - - protected: - virtual ~IndexedDBCallbacksWrapper(); - explicit IndexedDBCallbacksWrapper(IndexedDBCallbacksBase* callbacks); - - private: - friend class base::RefCounted<IndexedDBCallbacksWrapper>; - scoped_ptr<WebIDBDatabaseImpl> web_database_impl_; - scoped_ptr<IndexedDBCallbacksBase> callbacks_; - scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_; - bool did_complete_; - bool did_create_proxy_; -}; - -} // namespace content - -#endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_WRAPPER_H_ diff --git a/content/browser/indexed_db/indexed_db_cursor.cc b/content/browser/indexed_db/indexed_db_cursor.cc index 162407b..179797e 100644 --- a/content/browser/indexed_db/indexed_db_cursor.cc +++ b/content/browser/indexed_db/indexed_db_cursor.cc @@ -5,13 +5,10 @@ #include "content/browser/indexed_db/indexed_db_cursor.h" #include "base/logging.h" -#include "content/browser/indexed_db/indexed_db_backing_store.h" -#include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" -#include "content/browser/indexed_db/indexed_db_database.h" +#include "content/browser/indexed_db/indexed_db_callbacks.h" #include "content/browser/indexed_db/indexed_db_database_error.h" #include "content/browser/indexed_db/indexed_db_tracing.h" #include "content/browser/indexed_db/indexed_db_transaction.h" -#include "content/common/indexed_db/indexed_db_key_range.h" namespace content { @@ -20,14 +17,14 @@ class IndexedDBCursor::CursorIterationOperation public: CursorIterationOperation(scoped_refptr<IndexedDBCursor> cursor, scoped_ptr<IndexedDBKey> key, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) + scoped_refptr<IndexedDBCallbacks> callbacks) : cursor_(cursor), key_(key.Pass()), callbacks_(callbacks) {} virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; private: scoped_refptr<IndexedDBCursor> cursor_; scoped_ptr<IndexedDBKey> key_; - scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + scoped_refptr<IndexedDBCallbacks> callbacks_; }; class IndexedDBCursor::CursorAdvanceOperation @@ -35,23 +32,22 @@ class IndexedDBCursor::CursorAdvanceOperation public: CursorAdvanceOperation(scoped_refptr<IndexedDBCursor> cursor, uint32 count, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) + scoped_refptr<IndexedDBCallbacks> callbacks) : cursor_(cursor), count_(count), callbacks_(callbacks) {} virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; private: scoped_refptr<IndexedDBCursor> cursor_; uint32 count_; - scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + scoped_refptr<IndexedDBCallbacks> callbacks_; }; class IndexedDBCursor::CursorPrefetchIterationOperation : public IndexedDBTransaction::Operation { public: - CursorPrefetchIterationOperation( - scoped_refptr<IndexedDBCursor> cursor, - int number_to_fetch, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) + CursorPrefetchIterationOperation(scoped_refptr<IndexedDBCursor> cursor, + int number_to_fetch, + scoped_refptr<IndexedDBCallbacks> callbacks) : cursor_(cursor), number_to_fetch_(number_to_fetch), callbacks_(callbacks) {} @@ -60,7 +56,7 @@ class IndexedDBCursor::CursorPrefetchIterationOperation private: scoped_refptr<IndexedDBCursor> cursor_; int number_to_fetch_; - scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + scoped_refptr<IndexedDBCallbacks> callbacks_; }; IndexedDBCursor::IndexedDBCursor( @@ -82,16 +78,15 @@ IndexedDBCursor::~IndexedDBCursor() { void IndexedDBCursor::ContinueFunction( scoped_ptr<IndexedDBKey> key, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { + scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE("IndexedDBCursor::Continue"); transaction_->ScheduleTask( task_type_, new CursorIterationOperation(this, key.Pass(), callbacks)); } -void IndexedDBCursor::Advance( - uint32 count, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { +void IndexedDBCursor::Advance(uint32 count, + scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE("IndexedDBCursor::Advance"); transaction_->ScheduleTask( @@ -128,7 +123,7 @@ void IndexedDBCursor::CursorIterationOperation::Perform( void IndexedDBCursor::PrefetchContinue( int number_to_fetch, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { + scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE("IndexedDBCursor::PrefetchContinue"); transaction_->ScheduleTask( diff --git a/content/browser/indexed_db/indexed_db_cursor.h b/content/browser/indexed_db/indexed_db_cursor.h index 290d920..9dcae0d 100644 --- a/content/browser/indexed_db/indexed_db_cursor.h +++ b/content/browser/indexed_db/indexed_db_cursor.h @@ -16,7 +16,6 @@ namespace content { -class IndexedDBDatabase; class IndexedDBTransaction; class CONTENT_EXPORT IndexedDBCursor @@ -42,12 +41,11 @@ class CONTENT_EXPORT IndexedDBCursor } // IndexedDBCursor - void Advance(uint32 count, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks); + void Advance(uint32 count, scoped_refptr<IndexedDBCallbacks> callbacks); void ContinueFunction(scoped_ptr<IndexedDBKey> key, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); void PrefetchContinue(int number_to_fetch, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); void PrefetchReset(int used_prefetches, int unused_prefetches); const IndexedDBKey& key() const { return cursor_->key(); } diff --git a/content/browser/indexed_db/indexed_db_database.cc b/content/browser/indexed_db/indexed_db_database.cc index 05c515a..4568b9b 100644 --- a/content/browser/indexed_db/indexed_db_database.cc +++ b/content/browser/indexed_db/indexed_db_database.cc @@ -63,7 +63,7 @@ class IndexedDBDatabase::VersionChangeOperation scoped_refptr<IndexedDBDatabase> database, int64 transaction_id, int64 version, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, WebKit::WebIDBCallbacks::DataLoss data_loss) : database_(database), @@ -78,7 +78,7 @@ class IndexedDBDatabase::VersionChangeOperation scoped_refptr<IndexedDBDatabase> database_; int64 transaction_id_; int64 version_; - scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + scoped_refptr<IndexedDBCallbacks> callbacks_; scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_; WebKit::WebIDBCallbacks::DataLoss data_loss_; }; @@ -199,7 +199,7 @@ class GetOperation : public IndexedDBTransaction::Operation { const bool auto_increment, scoped_ptr<IndexedDBKeyRange> key_range, indexed_db::CursorType cursor_type, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) + scoped_refptr<IndexedDBCallbacks> callbacks) : backing_store_(backing_store), database_id_(database_id), object_store_id_(object_store_id), @@ -208,8 +208,7 @@ class GetOperation : public IndexedDBTransaction::Operation { auto_increment_(auto_increment), key_range_(key_range.Pass()), cursor_type_(cursor_type), - callbacks_(callbacks) { - } + callbacks_(callbacks) {} virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; private: @@ -221,7 +220,7 @@ class GetOperation : public IndexedDBTransaction::Operation { const bool auto_increment_; const scoped_ptr<IndexedDBKeyRange> key_range_; const indexed_db::CursorType cursor_type_; - const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + const scoped_refptr<IndexedDBCallbacks> callbacks_; }; class PutOperation : public IndexedDBTransaction::Operation { @@ -232,7 +231,7 @@ class PutOperation : public IndexedDBTransaction::Operation { std::vector<char>* value, scoped_ptr<IndexedDBKey> key, IndexedDBDatabase::PutMode put_mode, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, const std::vector<int64>& index_ids, const std::vector<IndexedDBDatabase::IndexKeys>& index_keys) : backing_store_(backing_store), @@ -254,7 +253,7 @@ class PutOperation : public IndexedDBTransaction::Operation { std::vector<char> value_; scoped_ptr<IndexedDBKey> key_; const IndexedDBDatabase::PutMode put_mode_; - const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + const scoped_refptr<IndexedDBCallbacks> callbacks_; const std::vector<int64> index_ids_; const std::vector<IndexedDBDatabase::IndexKeys> index_keys_; }; @@ -279,7 +278,7 @@ class OpenCursorOperation : public IndexedDBTransaction::Operation { indexed_db::CursorDirection direction, indexed_db::CursorType cursor_type, IndexedDBDatabase::TaskType task_type, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) + scoped_refptr<IndexedDBCallbacks> callbacks) : backing_store_(backing_store), database_id_(database_id), object_store_id_(object_store_id), @@ -300,7 +299,7 @@ class OpenCursorOperation : public IndexedDBTransaction::Operation { const indexed_db::CursorDirection direction_; const indexed_db::CursorType cursor_type_; const IndexedDBDatabase::TaskType task_type_; - const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + const scoped_refptr<IndexedDBCallbacks> callbacks_; }; class CountOperation : public IndexedDBTransaction::Operation { @@ -310,7 +309,7 @@ class CountOperation : public IndexedDBTransaction::Operation { int64 object_store_id, int64 index_id, scoped_ptr<IndexedDBKeyRange> key_range, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) + scoped_refptr<IndexedDBCallbacks> callbacks) : backing_store_(backing_store), database_id_(database_id), object_store_id_(object_store_id), @@ -325,7 +324,7 @@ class CountOperation : public IndexedDBTransaction::Operation { const int64 object_store_id_; const int64 index_id_; const scoped_ptr<IndexedDBKeyRange> key_range_; - const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + const scoped_refptr<IndexedDBCallbacks> callbacks_; }; class DeleteRangeOperation : public IndexedDBTransaction::Operation { @@ -334,7 +333,7 @@ class DeleteRangeOperation : public IndexedDBTransaction::Operation { int64 database_id, int64 object_store_id, scoped_ptr<IndexedDBKeyRange> key_range, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) + scoped_refptr<IndexedDBCallbacks> callbacks) : backing_store_(backing_store), database_id_(database_id), object_store_id_(object_store_id), @@ -347,7 +346,7 @@ class DeleteRangeOperation : public IndexedDBTransaction::Operation { const int64 database_id_; const int64 object_store_id_; const scoped_ptr<IndexedDBKeyRange> key_range_; - const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + const scoped_refptr<IndexedDBCallbacks> callbacks_; }; class ClearOperation : public IndexedDBTransaction::Operation { @@ -355,7 +354,7 @@ class ClearOperation : public IndexedDBTransaction::Operation { ClearOperation(scoped_refptr<IndexedDBBackingStore> backing_store, int64 database_id, int64 object_store_id, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) + scoped_refptr<IndexedDBCallbacks> callbacks) : backing_store_(backing_store), database_id_(database_id), object_store_id_(object_store_id), @@ -366,21 +365,20 @@ class ClearOperation : public IndexedDBTransaction::Operation { const scoped_refptr<IndexedDBBackingStore> backing_store_; const int64 database_id_; const int64 object_store_id_; - const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + const scoped_refptr<IndexedDBCallbacks> callbacks_; }; class IndexedDBDatabase::PendingOpenCall { public: - PendingOpenCall( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, - scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, - int64 transaction_id, - int64 version) + PendingOpenCall(scoped_refptr<IndexedDBCallbacks> callbacks, + scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, + int64 transaction_id, + int64 version) : callbacks_(callbacks), database_callbacks_(database_callbacks), version_(version), transaction_id_(transaction_id) {} - scoped_refptr<IndexedDBCallbacksWrapper> Callbacks() { return callbacks_; } + scoped_refptr<IndexedDBCallbacks> Callbacks() { return callbacks_; } scoped_refptr<IndexedDBDatabaseCallbacks> DatabaseCallbacks() { return database_callbacks_; } @@ -388,7 +386,7 @@ class IndexedDBDatabase::PendingOpenCall { int64 TransactionId() const { return transaction_id_; } private: - scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + scoped_refptr<IndexedDBCallbacks> callbacks_; scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_; int64 version_; const int64 transaction_id_; @@ -396,12 +394,12 @@ class IndexedDBDatabase::PendingOpenCall { class IndexedDBDatabase::PendingDeleteCall { public: - explicit PendingDeleteCall(scoped_refptr<IndexedDBCallbacksWrapper> callbacks) + explicit PendingDeleteCall(scoped_refptr<IndexedDBCallbacks> callbacks) : callbacks_(callbacks) {} - scoped_refptr<IndexedDBCallbacksWrapper> Callbacks() { return callbacks_; } + scoped_refptr<IndexedDBCallbacks> Callbacks() { return callbacks_; } private: - scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; + scoped_refptr<IndexedDBCallbacks> callbacks_; }; scoped_refptr<IndexedDBDatabase> IndexedDBDatabase::Create( @@ -702,13 +700,12 @@ void IndexedDBDatabase::Abort(int64 transaction_id, transactions_[transaction_id]->Abort(error); } -void IndexedDBDatabase::Get( - int64 transaction_id, - int64 object_store_id, - int64 index_id, - scoped_ptr<IndexedDBKeyRange> key_range, - bool key_only, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { +void IndexedDBDatabase::Get(int64 transaction_id, + int64 object_store_id, + int64 index_id, + scoped_ptr<IndexedDBKeyRange> key_range, + bool key_only, + scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE("IndexedDBDatabase::Get"); TransactionMap::const_iterator trans_iterator = transactions_.find(transaction_id); @@ -904,7 +901,7 @@ void IndexedDBDatabase::Put(int64 transaction_id, std::vector<char>* value, scoped_ptr<IndexedDBKey> key, PutMode put_mode, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, const std::vector<int64>& index_ids, const std::vector<IndexKeys>& index_keys) { IDB_TRACE("IndexedDBDatabase::Put"); @@ -983,18 +980,17 @@ void PutOperation::Perform(IndexedDBTransaction* transaction) { ScopedVector<IndexWriter> index_writers; string16 error_message; bool obeys_constraints = false; - bool backing_store_success = - MakeIndexWriters(transaction, - backing_store_.get(), - database_id_, - object_store_, - *key, - key_was_generated, - index_ids_, - index_keys_, - &index_writers, - &error_message, - &obeys_constraints); + bool backing_store_success = MakeIndexWriters(transaction, + backing_store_.get(), + database_id_, + object_store_, + *key, + key_was_generated, + index_ids_, + index_keys_, + &index_writers, + &error_message, + &obeys_constraints); if (!backing_store_success) { callbacks_->OnError(IndexedDBDatabaseError( WebKit::WebIDBDatabaseExceptionUnknownError, @@ -1159,7 +1155,7 @@ void IndexedDBDatabase::OpenCursor( indexed_db::CursorDirection direction, bool key_only, TaskType task_type, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { + scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE("IndexedDBDatabase::OpenCursor"); TransactionMap::const_iterator trans_iterator = transactions_.find(transaction_id); @@ -1232,12 +1228,11 @@ void OpenCursorOperation::Perform(IndexedDBTransaction* transaction) { cursor, cursor->key(), cursor->primary_key(), cursor->Value()); } -void IndexedDBDatabase::Count( - int64 transaction_id, - int64 object_store_id, - int64 index_id, - scoped_ptr<IndexedDBKeyRange> key_range, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { +void IndexedDBDatabase::Count(int64 transaction_id, + int64 object_store_id, + int64 index_id, + scoped_ptr<IndexedDBKeyRange> key_range, + scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE("IndexedDBDatabase::Count"); TransactionMap::const_iterator trans_iterator = transactions_.find(transaction_id); @@ -1292,7 +1287,7 @@ void IndexedDBDatabase::DeleteRange( int64 transaction_id, int64 object_store_id, scoped_ptr<IndexedDBKeyRange> key_range, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { + scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE("IndexedDBDatabase::DeleteRange"); TransactionMap::const_iterator trans_iterator = transactions_.find(transaction_id); @@ -1331,10 +1326,9 @@ void DeleteRangeOperation::Perform(IndexedDBTransaction* transaction) { callbacks_->OnSuccess(); } -void IndexedDBDatabase::Clear( - int64 transaction_id, - int64 object_store_id, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { +void IndexedDBDatabase::Clear(int64 transaction_id, + int64 object_store_id, + scoped_refptr<IndexedDBCallbacks> callbacks) { IDB_TRACE("IndexedDBDatabase::Clear"); TransactionMap::const_iterator trans_iterator = transactions_.find(transaction_id); @@ -1536,7 +1530,7 @@ bool IndexedDBDatabase::IsOpenConnectionBlocked() const { } void IndexedDBDatabase::OpenConnection( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int64 transaction_id, int64 version) { @@ -1547,7 +1541,7 @@ void IndexedDBDatabase::OpenConnection( } void IndexedDBDatabase::OpenConnection( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int64 transaction_id, int64 version, @@ -1634,7 +1628,7 @@ void IndexedDBDatabase::OpenConnection( } void IndexedDBDatabase::RunVersionChangeTransaction( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int64 transaction_id, int64 requested_version, @@ -1671,7 +1665,7 @@ void IndexedDBDatabase::RunVersionChangeTransaction( } void IndexedDBDatabase::RunVersionChangeTransactionFinal( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int64 transaction_id, int64 requested_version) { @@ -1685,7 +1679,7 @@ void IndexedDBDatabase::RunVersionChangeTransactionFinal( } void IndexedDBDatabase::RunVersionChangeTransactionFinal( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int64 transaction_id, int64 requested_version, @@ -1713,7 +1707,7 @@ void IndexedDBDatabase::RunVersionChangeTransactionFinal( } void IndexedDBDatabase::DeleteDatabase( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { + scoped_refptr<IndexedDBCallbacks> callbacks) { if (IsDeleteDatabaseBlocked()) { for (DatabaseCallbacksSet::const_iterator it = @@ -1740,7 +1734,7 @@ bool IndexedDBDatabase::IsDeleteDatabaseBlocked() const { } void IndexedDBDatabase::DeleteDatabaseFinal( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { + scoped_refptr<IndexedDBCallbacks> callbacks) { DCHECK(!IsDeleteDatabaseBlocked()); DCHECK(backing_store_.get()); if (!backing_store_->DeleteDatabase(metadata_.name)) { diff --git a/content/browser/indexed_db/indexed_db_database.h b/content/browser/indexed_db/indexed_db_database.h index abafb50..8ddccb0 100644 --- a/content/browser/indexed_db/indexed_db_database.h +++ b/content/browser/indexed_db/indexed_db_database.h @@ -12,14 +12,13 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "content/browser/indexed_db/indexed_db.h" -#include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" +#include "content/browser/indexed_db/indexed_db_callbacks.h" #include "content/browser/indexed_db/indexed_db_metadata.h" #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" #include "content/browser/indexed_db/list_set.h" namespace content { -class IndexedDBCallbacksWrapper; class IndexedDBDatabaseCallbacks; class IndexedDBBackingStore; class IndexedDBFactory; @@ -64,17 +63,17 @@ class CONTENT_EXPORT IndexedDBDatabase void RemoveIndex(int64 object_store_id, int64 index_id); void OpenConnection( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int64 transaction_id, int64 version); void OpenConnection( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int64 transaction_id, int64 version, WebKit::WebIDBCallbacks::DataLoss data_loss); - void DeleteDatabase(scoped_refptr<IndexedDBCallbacksWrapper> callbacks); + void DeleteDatabase(scoped_refptr<IndexedDBCallbacks> callbacks); const IndexedDBDatabaseMetadata& metadata() const { return metadata_; } void CreateObjectStore(int64 transaction_id, @@ -83,11 +82,10 @@ class CONTENT_EXPORT IndexedDBDatabase const IndexedDBKeyPath& key_path, bool auto_increment); void DeleteObjectStore(int64 transaction_id, int64 object_store_id); - void CreateTransaction( - int64 transaction_id, - scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, - const std::vector<int64>& object_store_ids, - uint16 mode); + void CreateTransaction(int64 transaction_id, + scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, + const std::vector<int64>& object_store_ids, + uint16 mode); void Close(scoped_refptr<IndexedDBDatabaseCallbacks> callbacks); void Commit(int64 transaction_id); @@ -117,13 +115,13 @@ class CONTENT_EXPORT IndexedDBDatabase int64 index_id, scoped_ptr<IndexedDBKeyRange> key_range, bool key_only, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); void Put(int64 transaction_id, int64 object_store_id, std::vector<char>* value, scoped_ptr<IndexedDBKey> key, PutMode mode, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, const std::vector<int64>& index_ids, const std::vector<IndexKeys>& index_keys); void SetIndexKeys(int64 transaction_id, @@ -141,19 +139,19 @@ class CONTENT_EXPORT IndexedDBDatabase indexed_db::CursorDirection, bool key_only, TaskType task_type, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); void Count(int64 transaction_id, int64 object_store_id, int64 index_id, scoped_ptr<IndexedDBKeyRange> key_range, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); void DeleteRange(int64 transaction_id, int64 object_store_id, scoped_ptr<IndexedDBKeyRange> key_range, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); void Clear(int64 transaction_id, int64 object_store_id, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); private: friend class base::RefCounted<IndexedDBDatabase>; @@ -167,18 +165,18 @@ class CONTENT_EXPORT IndexedDBDatabase bool IsOpenConnectionBlocked() const; bool OpenInternal(); void RunVersionChangeTransaction( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int64 transaction_id, int64 requested_version, WebKit::WebIDBCallbacks::DataLoss data_loss); void RunVersionChangeTransactionFinal( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int64 transaction_id, int64 requested_version); void RunVersionChangeTransactionFinal( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, int64 transaction_id, int64 requested_version, @@ -187,7 +185,7 @@ class CONTENT_EXPORT IndexedDBDatabase void ProcessPendingCalls(); bool IsDeleteDatabaseBlocked() const; - void DeleteDatabaseFinal(scoped_refptr<IndexedDBCallbacksWrapper> callbacks); + void DeleteDatabaseFinal(scoped_refptr<IndexedDBCallbacks> callbacks); class VersionChangeOperation; diff --git a/content/browser/indexed_db/indexed_db_database_unittest.cc b/content/browser/indexed_db/indexed_db_database_unittest.cc index 6beac11..f88dc5d 100644 --- a/content/browser/indexed_db/indexed_db_database_unittest.cc +++ b/content/browser/indexed_db/indexed_db_database_unittest.cc @@ -12,7 +12,7 @@ #include "base/strings/utf_string_conversions.h" #include "content/browser/indexed_db/indexed_db.h" #include "content/browser/indexed_db/indexed_db_backing_store.h" -#include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" +#include "content/browser/indexed_db/indexed_db_callbacks.h" #include "content/browser/indexed_db/indexed_db_cursor.h" #include "content/browser/indexed_db/indexed_db_database.h" #include "content/browser/indexed_db/indexed_db_database_callbacks.h" @@ -31,15 +31,15 @@ TEST(IndexedDBDatabaseTest, BackingStoreRetention) { IndexedDBFactory* factory = 0; scoped_refptr<IndexedDBDatabase> db = IndexedDBDatabase::Create(ASCIIToUTF16("db"), - backing_store.get(), - factory, - ASCIIToUTF16("uniqueid")); + backing_store.get(), + factory, + ASCIIToUTF16("uniqueid")); EXPECT_FALSE(backing_store->HasOneRef()); // local and db db = NULL; EXPECT_TRUE(backing_store->HasOneRef()); // local } -class MockIDBCallbacks : public IndexedDBCallbacksWrapper { +class MockIDBCallbacks : public IndexedDBCallbacks { public: static scoped_refptr<MockIDBCallbacks> Create() { return make_scoped_refptr(new MockIDBCallbacks()); @@ -72,7 +72,7 @@ class MockIDBCallbacks : public IndexedDBCallbacksWrapper { private: virtual ~MockIDBCallbacks() { EXPECT_TRUE(was_success_db_called_); } MockIDBCallbacks() - : IndexedDBCallbacksWrapper(NULL), was_success_db_called_(false) {} + : IndexedDBCallbacks(NULL, 0, 0), was_success_db_called_(false) {} bool was_success_db_called_; }; @@ -101,9 +101,9 @@ TEST(IndexedDBDatabaseTest, ConnectionLifecycle) { IndexedDBFactory* factory = 0; scoped_refptr<IndexedDBDatabase> db = IndexedDBDatabase::Create(ASCIIToUTF16("db"), - backing_store.get(), - factory, - ASCIIToUTF16("uniqueid")); + backing_store.get(), + factory, + ASCIIToUTF16("uniqueid")); EXPECT_FALSE(backing_store->HasOneRef()); // local and db @@ -155,8 +155,7 @@ class MockIDBDatabaseCallbacks : public IndexedDBDatabaseCallbacks { private: MockIDBDatabaseCallbacks() - : IndexedDBDatabaseCallbacks(NULL, 0, 0), - was_abort_called_(false) {} + : IndexedDBDatabaseCallbacks(NULL, 0, 0), was_abort_called_(false) {} virtual ~MockIDBDatabaseCallbacks() { EXPECT_TRUE(was_abort_called_); } bool was_abort_called_; }; @@ -169,9 +168,9 @@ TEST(IndexedDBDatabaseTest, ForcedClose) { IndexedDBFactory* factory = 0; scoped_refptr<IndexedDBDatabase> backend = IndexedDBDatabase::Create(ASCIIToUTF16("db"), - backing_store.get(), - factory, - ASCIIToUTF16("uniqueid")); + backing_store.get(), + factory, + ASCIIToUTF16("uniqueid")); EXPECT_FALSE(backing_store->HasOneRef()); // local and db diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.cc b/content/browser/indexed_db/indexed_db_dispatcher_host.cc index 239af5c..9790ffd 100644 --- a/content/browser/indexed_db/indexed_db_dispatcher_host.cc +++ b/content/browser/indexed_db/indexed_db_dispatcher_host.cc @@ -161,8 +161,7 @@ int64 IndexedDBDispatcherHost::RendererTransactionId( return host_transaction_id & 0xffffffff; } -IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId( - int32 ipc_cursor_id) { +IndexedDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 ipc_cursor_id) { DCHECK(indexed_db_context_->TaskRunner()->RunsTasksOnCurrentThread()); return cursor_dispatcher_host_->map_.Lookup(ipc_cursor_id); } @@ -215,9 +214,8 @@ void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( base::FilePath indexed_db_path = indexed_db_context_->data_path(); Context()->GetIDBFactory()->GetDatabaseNames( - IndexedDBCallbacksWrapper::Create( - new IndexedDBCallbacks<std::vector<string16> >( - this, params.ipc_thread_id, params.ipc_callbacks_id)), + IndexedDBCallbacks::Create( + this, params.ipc_thread_id, params.ipc_callbacks_id), base::UTF8ToUTF16(params.database_identifier), indexed_db_path); } @@ -234,24 +232,23 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen( // TODO(dgrogan): Don't let a non-existing database be opened (and therefore // created) if this origin is already over quota. - scoped_refptr<IndexedDBCallbacksWrapper> callbacks_proxy = - IndexedDBCallbacksWrapper::Create( - new IndexedDBCallbacksDatabase(this, - params.ipc_thread_id, - params.ipc_callbacks_id, - params.ipc_database_callbacks_id, - host_transaction_id, - origin_url)); - scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_proxy = + scoped_refptr<IndexedDBCallbacks> callbacks = + IndexedDBCallbacks::Create(this, + params.ipc_thread_id, + params.ipc_callbacks_id, + params.ipc_database_callbacks_id, + host_transaction_id, + origin_url); + scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks = IndexedDBDatabaseCallbacks::Create( this, params.ipc_thread_id, params.ipc_database_callbacks_id); - callbacks_proxy->SetDatabaseCallbacks(database_callbacks_proxy); + callbacks->SetDatabaseCallbacks(database_callbacks); Context()->GetIDBFactory()-> Open(params.name, params.version, host_transaction_id, - callbacks_proxy, - database_callbacks_proxy, + callbacks, + database_callbacks, base::UTF8ToUTF16(params.database_identifier), indexed_db_path); } @@ -262,9 +259,8 @@ void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( base::FilePath indexed_db_path = indexed_db_context_->data_path(); Context()->GetIDBFactory()->DeleteDatabase( params.name, - IndexedDBCallbacksWrapper::Create( - new IndexedDBCallbacks<std::vector<char> >( - this, params.ipc_thread_id, params.ipc_callbacks_id)), + IndexedDBCallbacks::Create( + this, params.ipc_thread_id, params.ipc_callbacks_id), base::UTF8ToUTF16(params.database_identifier), indexed_db_path); } @@ -329,9 +325,7 @@ ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( } template <typename MapType> -void IndexedDBDispatcherHost::DestroyObject( - MapType* map, - int32 ipc_object_id) { +void IndexedDBDispatcherHost::DestroyObject(MapType* map, int32 ipc_object_id) { GetOrTerminateProcess(map, ipc_object_id); map->Remove(ipc_object_id); } @@ -473,9 +467,7 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction( int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); database->createTransaction( - host_transaction_id, - params.object_store_ids, - params.mode); + host_transaction_id, params.object_store_ids, params.mode); transaction_database_map_[host_transaction_id] = params.ipc_database_id; parent_->RegisterTransactionId(host_transaction_id, database_url_map_[params.ipc_database_id]); @@ -512,15 +504,14 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnGet( if (!database) return; - scoped_ptr<IndexedDBCallbacksBase> callbacks( - new IndexedDBCallbacks<std::vector<char> >( - parent_, params.ipc_thread_id, params.ipc_callbacks_id)); + scoped_refptr<IndexedDBCallbacks> callbacks(IndexedDBCallbacks::Create( + parent_, params.ipc_thread_id, params.ipc_callbacks_id)); database->get(parent_->HostTransactionId(params.transaction_id), params.object_store_id, params.index_id, params.key_range, params.key_only, - callbacks.release()); + callbacks); } void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( @@ -532,9 +523,8 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( parent_->GetOrTerminateProcess(&map_, params.ipc_database_id); if (!database) return; - scoped_ptr<IndexedDBCallbacksBase> callbacks( - new IndexedDBCallbacks<IndexedDBKey>( - parent_, params.ipc_thread_id, params.ipc_callbacks_id)); + scoped_refptr<IndexedDBCallbacks> callbacks(IndexedDBCallbacks::Create( + parent_, params.ipc_thread_id, params.ipc_callbacks_id)); int64 host_transaction_id = parent_->HostTransactionId(params.transaction_id); // TODO(alecflett): Avoid a copy here. @@ -544,7 +534,7 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnPut( &value_copy, params.key, params.put_mode, - callbacks.release(), + callbacks, params.index_ids, params.index_keys); TransactionIDToSizeMap* map = @@ -605,9 +595,8 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( if (!database) return; - scoped_ptr<IndexedDBCallbacksBase> callbacks( - new IndexedDBCallbacks<IndexedDBCursor>( - parent_, params.ipc_thread_id, params.ipc_callbacks_id, -1)); + scoped_refptr<IndexedDBCallbacks> callbacks(IndexedDBCallbacks::Create( + parent_, params.ipc_thread_id, params.ipc_callbacks_id, -1)); database->openCursor(parent_->HostTransactionId(params.transaction_id), params.object_store_id, params.index_id, @@ -615,7 +604,7 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpenCursor( params.direction, params.key_only, params.task_type, - callbacks.release()); + callbacks); } void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( @@ -627,14 +616,13 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCount( if (!database) return; - scoped_ptr<IndexedDBCallbacksBase> callbacks( - new IndexedDBCallbacks<std::vector<char> >( - parent_, params.ipc_thread_id, params.ipc_callbacks_id)); + scoped_refptr<IndexedDBCallbacks> callbacks(IndexedDBCallbacks::Create( + parent_, params.ipc_thread_id, params.ipc_callbacks_id)); database->count(parent_->HostTransactionId(params.transaction_id), params.object_store_id, params.index_id, params.key_range, - callbacks.release()); + callbacks); } void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( @@ -646,13 +634,12 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteRange( if (!database) return; - scoped_ptr<IndexedDBCallbacksBase> callbacks( - new IndexedDBCallbacks<std::vector<char> >( - parent_, params.ipc_thread_id, params.ipc_callbacks_id)); + scoped_refptr<IndexedDBCallbacks> callbacks(IndexedDBCallbacks::Create( + parent_, params.ipc_thread_id, params.ipc_callbacks_id)); database->deleteRange(parent_->HostTransactionId(params.transaction_id), params.object_store_id, params.key_range, - callbacks.release()); + callbacks); } void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( @@ -668,13 +655,11 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear( if (!database) return; - scoped_ptr<IndexedDBCallbacksBase> callbacks( - new IndexedDBCallbacks<std::vector<char> >( - parent_, ipc_thread_id, ipc_callbacks_id)); + scoped_refptr<IndexedDBCallbacks> callbacks( + IndexedDBCallbacks::Create(parent_, ipc_thread_id, ipc_callbacks_id)); - database->clear(parent_->HostTransactionId(transaction_id), - object_store_id, - callbacks.release()); + database->clear( + parent_->HostTransactionId(transaction_id), object_store_id, callbacks); } void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnAbort( @@ -805,8 +790,8 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnAdvance( idb_cursor->Advance( count, - IndexedDBCallbacksWrapper::Create(new IndexedDBCallbacks<IndexedDBCursor>( - parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id))); + IndexedDBCallbacks::Create( + parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); } void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( @@ -823,8 +808,8 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnContinue( idb_cursor->ContinueFunction( make_scoped_ptr(new IndexedDBKey(key)), - IndexedDBCallbacksWrapper::Create(new IndexedDBCallbacks<IndexedDBCursor>( - parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id))); + IndexedDBCallbacks::Create( + parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); } void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch( @@ -841,8 +826,8 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetch( idb_cursor->PrefetchContinue( n, - IndexedDBCallbacksWrapper::Create(new IndexedDBCallbacks<IndexedDBCursor>( - parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id))); + IndexedDBCallbacks::Create( + parent_, ipc_thread_id, ipc_callbacks_id, ipc_cursor_id)); } void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrefetchReset( diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.h b/content/browser/indexed_db/indexed_db_dispatcher_host.h index d541989d..e17b220 100644 --- a/content/browser/indexed_db/indexed_db_dispatcher_host.h +++ b/content/browser/indexed_db/indexed_db_dispatcher_host.h @@ -60,8 +60,8 @@ class IndexedDBDispatcherHost : public BrowserMessageFilter { // A shortcut for accessing our context. IndexedDBContextImpl* Context() { return indexed_db_context_.get(); } - // The various IndexedDBCallbacks children call these methods to add the - // results into the applicable map. See below for more details. + // IndexedDBCallbacks call these methods to add the results into the + // applicable map. See below for more details. int32 Add(IndexedDBCursor* idb_cursor); int32 Add(WebIDBDatabaseImpl* idb_database, int32 ipc_thread_id, diff --git a/content/browser/indexed_db/indexed_db_factory.cc b/content/browser/indexed_db/indexed_db_factory.cc index b000add..24240e6 100644 --- a/content/browser/indexed_db/indexed_db_factory.cc +++ b/content/browser/indexed_db/indexed_db_factory.cc @@ -51,7 +51,7 @@ void IndexedDBFactory::RemoveIDBDatabaseBackend( } void IndexedDBFactory::GetDatabaseNames( - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, const string16& database_identifier, const base::FilePath& data_directory) { IDB_TRACE("IndexedDBFactory::GetDatabaseNames"); @@ -72,7 +72,7 @@ void IndexedDBFactory::GetDatabaseNames( void IndexedDBFactory::DeleteDatabase( const string16& name, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, const string16& database_identifier, const base::FilePath& data_directory) { IDB_TRACE("IndexedDBFactory::DeleteDatabase"); @@ -88,7 +88,6 @@ void IndexedDBFactory::DeleteDatabase( return; } - // TODO(dgrogan): Plumb data_loss back to script eventually? WebKit::WebIDBCallbacks::DataLoss data_loss; scoped_refptr<IndexedDBBackingStore> backing_store = @@ -157,7 +156,7 @@ void IndexedDBFactory::Open( const string16& name, int64 version, int64 transaction_id, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, const string16& database_identifier, const base::FilePath& data_directory) { diff --git a/content/browser/indexed_db/indexed_db_factory.h b/content/browser/indexed_db/indexed_db_factory.h index 142008b..1b76d79 100644 --- a/content/browser/indexed_db/indexed_db_factory.h +++ b/content/browser/indexed_db/indexed_db_factory.h @@ -13,7 +13,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" -#include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" +#include "content/browser/indexed_db/indexed_db_callbacks.h" #include "content/browser/indexed_db/indexed_db_database_callbacks.h" #include "content/browser/indexed_db/indexed_db_factory.h" #include "content/common/content_export.h" @@ -33,19 +33,19 @@ class CONTENT_EXPORT IndexedDBFactory // Notifications from weak pointers. void RemoveIDBDatabaseBackend(const string16& unique_identifier); - void GetDatabaseNames(scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + void GetDatabaseNames(scoped_refptr<IndexedDBCallbacks> callbacks, const string16& database_identifier, const base::FilePath& data_directory); void Open(const string16& name, int64 version, int64 transaction_id, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, const string16& database_identifier, const base::FilePath& data_directory); void DeleteDatabase(const string16& name, - scoped_refptr<IndexedDBCallbacksWrapper> callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, const string16& database_identifier, const base::FilePath& data_directory); diff --git a/content/browser/indexed_db/indexed_db_index_writer.h b/content/browser/indexed_db/indexed_db_index_writer.h index 516c4dee..2ea1c98 100644 --- a/content/browser/indexed_db/indexed_db_index_writer.h +++ b/content/browser/indexed_db/indexed_db_index_writer.h @@ -17,7 +17,6 @@ namespace content { -class IndexedDBDatabase; class IndexedDBTransaction; struct IndexedDBObjectStoreMetadata; diff --git a/content/browser/indexed_db/indexed_db_transaction.h b/content/browser/indexed_db/indexed_db_transaction.h index 698d21f..6c78022 100644 --- a/content/browser/indexed_db/indexed_db_transaction.h +++ b/content/browser/indexed_db/indexed_db_transaction.h @@ -20,7 +20,6 @@ namespace content { -class IndexedDBDatabase; class IndexedDBCursor; class IndexedDBDatabaseCallbacks; diff --git a/content/browser/indexed_db/webidbdatabase_impl.cc b/content/browser/indexed_db/webidbdatabase_impl.cc index 5661777..04e6e85 100644 --- a/content/browser/indexed_db/webidbdatabase_impl.cc +++ b/content/browser/indexed_db/webidbdatabase_impl.cc @@ -8,10 +8,8 @@ #include "base/basictypes.h" #include "base/logging.h" -#include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" +#include "content/browser/indexed_db/indexed_db_callbacks.h" #include "content/browser/indexed_db/indexed_db_cursor.h" -#include "content/browser/indexed_db/indexed_db_database.h" -#include "content/browser/indexed_db/indexed_db_database_callbacks.h" #include "content/browser/indexed_db/indexed_db_database_error.h" #include "content/browser/indexed_db/indexed_db_metadata.h" #include "content/common/indexed_db/indexed_db_key_range.h" @@ -86,14 +84,15 @@ void WebIDBDatabaseImpl::commit(long long transaction_id) { database_backend_->Commit(transaction_id); } -void WebIDBDatabaseImpl::openCursor(long long transaction_id, - long long object_store_id, - long long index_id, - const IndexedDBKeyRange& key_range, - unsigned short direction, - bool key_only, - WebKit::WebIDBDatabase::TaskType task_type, - IndexedDBCallbacksBase* callbacks) { +void WebIDBDatabaseImpl::openCursor( + long long transaction_id, + long long object_store_id, + long long index_id, + const IndexedDBKeyRange& key_range, + unsigned short direction, + bool key_only, + WebKit::WebIDBDatabase::TaskType task_type, + scoped_refptr<IndexedDBCallbacks> callbacks) { if (database_backend_.get()) database_backend_->OpenCursor( transaction_id, @@ -103,20 +102,20 @@ void WebIDBDatabaseImpl::openCursor(long long transaction_id, static_cast<indexed_db::CursorDirection>(direction), key_only, static_cast<IndexedDBDatabase::TaskType>(task_type), - IndexedDBCallbacksWrapper::Create(callbacks)); + callbacks); } void WebIDBDatabaseImpl::count(long long transaction_id, long long object_store_id, long long index_id, const IndexedDBKeyRange& key_range, - IndexedDBCallbacksBase* callbacks) { + scoped_refptr<IndexedDBCallbacks> callbacks) { if (database_backend_.get()) database_backend_->Count(transaction_id, object_store_id, index_id, make_scoped_ptr(new IndexedDBKeyRange(key_range)), - IndexedDBCallbacksWrapper::Create(callbacks)); + callbacks); } void WebIDBDatabaseImpl::get(long long transaction_id, @@ -124,14 +123,14 @@ void WebIDBDatabaseImpl::get(long long transaction_id, long long index_id, const IndexedDBKeyRange& key_range, bool key_only, - IndexedDBCallbacksBase* callbacks) { + scoped_refptr<IndexedDBCallbacks> callbacks) { if (database_backend_.get()) database_backend_->Get(transaction_id, object_store_id, index_id, make_scoped_ptr(new IndexedDBKeyRange(key_range)), key_only, - IndexedDBCallbacksWrapper::Create(callbacks)); + callbacks); } void WebIDBDatabaseImpl::put(long long transaction_id, @@ -139,7 +138,7 @@ void WebIDBDatabaseImpl::put(long long transaction_id, std::vector<char>* value, const IndexedDBKey& key, WebKit::WebIDBDatabase::PutMode put_mode, - IndexedDBCallbacksBase* callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, const std::vector<int64>& index_ids, const std::vector<IndexKeys>& index_keys) { if (!database_backend_.get()) @@ -152,7 +151,7 @@ void WebIDBDatabaseImpl::put(long long transaction_id, value, make_scoped_ptr(new IndexedDBKey(key)), static_cast<IndexedDBDatabase::PutMode>(put_mode), - IndexedDBCallbacksWrapper::Create(callbacks), + callbacks, index_ids, index_keys); } @@ -189,25 +188,24 @@ void WebIDBDatabaseImpl::setIndexesReady( transaction_id, object_store_id, index_ids); } -void WebIDBDatabaseImpl::deleteRange(long long transaction_id, - long long object_store_id, - const IndexedDBKeyRange& key_range, - IndexedDBCallbacksBase* callbacks) { +void WebIDBDatabaseImpl::deleteRange( + long long transaction_id, + long long object_store_id, + const IndexedDBKeyRange& key_range, + scoped_refptr<IndexedDBCallbacks> callbacks) { if (database_backend_.get()) database_backend_->DeleteRange( transaction_id, object_store_id, make_scoped_ptr(new IndexedDBKeyRange(key_range)), - IndexedDBCallbacksWrapper::Create(callbacks)); + callbacks); } void WebIDBDatabaseImpl::clear(long long transaction_id, long long object_store_id, - IndexedDBCallbacksBase* callbacks) { + scoped_refptr<IndexedDBCallbacks> callbacks) { if (database_backend_.get()) - database_backend_->Clear(transaction_id, - object_store_id, - IndexedDBCallbacksWrapper::Create(callbacks)); + database_backend_->Clear(transaction_id, object_store_id, callbacks); } void WebIDBDatabaseImpl::createIndex(long long transaction_id, diff --git a/content/browser/indexed_db/webidbdatabase_impl.h b/content/browser/indexed_db/webidbdatabase_impl.h index 78e0695..613b1af 100644 --- a/content/browser/indexed_db/webidbdatabase_impl.h +++ b/content/browser/indexed_db/webidbdatabase_impl.h @@ -7,19 +7,17 @@ #include "base/memory/ref_counted.h" #include "content/browser/indexed_db/indexed_db_database.h" +#include "content/browser/indexed_db/indexed_db_database_callbacks.h" #include "third_party/WebKit/public/platform/WebIDBDatabase.h" namespace content { -class IndexedDBCallbacksBase; -class IndexedDBDatabase; -class IndexedDBDatabaseCallbacks; +class IndexedDBCallbacks; class IndexedDBDatabaseError; class CONTENT_EXPORT WebIDBDatabaseImpl { public: - WebIDBDatabaseImpl( - scoped_refptr<IndexedDBDatabase> db, - scoped_refptr<IndexedDBDatabaseCallbacks> callbacks); + WebIDBDatabaseImpl(scoped_refptr<IndexedDBDatabase> db, + scoped_refptr<IndexedDBDatabaseCallbacks> callbacks); virtual ~WebIDBDatabaseImpl(); typedef std::vector<IndexedDBKey> IndexKeys; @@ -46,13 +44,13 @@ class CONTENT_EXPORT WebIDBDatabaseImpl { long long index_id, const IndexedDBKeyRange& range, bool key_only, - IndexedDBCallbacksBase* callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); virtual void put(long long transaction_id, long long object_store_id, std::vector<char>* value, const IndexedDBKey& key, WebKit::WebIDBDatabase::PutMode mode, - IndexedDBCallbacksBase* callbacks, + scoped_refptr<IndexedDBCallbacks> callbacks, const std::vector<int64>& index_ids, const std::vector<IndexKeys>& index_keys); virtual void setIndexKeys(long long transaction_id, @@ -70,19 +68,19 @@ class CONTENT_EXPORT WebIDBDatabaseImpl { unsigned short direction, bool key_only, WebKit::WebIDBDatabase::TaskType task_type, - IndexedDBCallbacksBase* callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); virtual void count(long long transaction_id, long long object_store_id, long long index_id, const IndexedDBKeyRange& range, - IndexedDBCallbacksBase* callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); virtual void deleteRange(long long transaction_id, long long object_store_id, const IndexedDBKeyRange& range, - IndexedDBCallbacksBase* callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); virtual void clear(long long transaction_id, long long object_store_id, - IndexedDBCallbacksBase* callbacks); + scoped_refptr<IndexedDBCallbacks> callbacks); virtual void createIndex(long long transaction_id, long long object_store_id, diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 735e951..b88bf5a 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -555,8 +555,6 @@ 'browser/indexed_db/indexed_db_backing_store.h', 'browser/indexed_db/indexed_db_callbacks.cc', 'browser/indexed_db/indexed_db_callbacks.h', - 'browser/indexed_db/indexed_db_callbacks_wrapper.cc', - 'browser/indexed_db/indexed_db_callbacks_wrapper.h', 'browser/indexed_db/indexed_db_context_impl.cc', 'browser/indexed_db/indexed_db_context_impl.h', 'browser/indexed_db/indexed_db_cursor.cc', |