Index: content/browser/indexed_db/indexed_db_connection.h |
diff --git a/content/browser/indexed_db/indexed_db_connection.h b/content/browser/indexed_db/indexed_db_connection.h |
index 9c097a99f7f240323b178c09a28eaa498088cdb5..ee2ac507818fc74869b38d3e9e5d7c8432f5907d 100644 |
--- a/content/browser/indexed_db/indexed_db_connection.h |
+++ b/content/browser/indexed_db/indexed_db_connection.h |
@@ -5,29 +5,35 @@ |
#ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ |
#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ |
+#include <map> |
+#include <memory> |
+#include <string> |
+#include <vector> |
+ |
+#include "Source/modules/indexeddb/indexed_db.mojom.h" |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/weak_ptr.h" |
+#include "content/browser/indexed_db/indexed_db_change_handler.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_observer.h" |
+#include "mojo/public/cpp/bindings/binding_set.h" |
+#include "storage/common/quota/quota_status_code.h" |
namespace content { |
class IndexedDBDatabaseError; |
-class CONTENT_EXPORT IndexedDBConnection { |
+class CONTENT_EXPORT IndexedDBConnection |
+ : public ::indexed_db::mojom::Database { |
public: |
IndexedDBConnection(scoped_refptr<IndexedDBDatabase> db, |
- scoped_refptr<IndexedDBDatabaseCallbacks> callbacks); |
- virtual ~IndexedDBConnection(); |
+ scoped_refptr<IndexedDBChangeHandler> change_handler); |
+ ~IndexedDBConnection() override; |
// These methods are virtual to allow subclassing in unit tests. |
virtual void ForceClose(); |
- virtual void Close(); |
virtual bool IsConnected(); |
- void VersionChangeIgnored(); |
- |
virtual void ActivatePendingObservers( |
std::vector<std::unique_ptr<IndexedDBObserver>> pending_observers); |
// Removes observer listed in |remove_observer_ids| from active_observer of |
@@ -39,7 +45,9 @@ class CONTENT_EXPORT IndexedDBConnection { |
int32_t id() const { return id_; } |
IndexedDBDatabase* database() const { return database_.get(); } |
- IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); } |
+ IndexedDBChangeHandler* change_handler() const { |
+ return change_handler_.get(); |
+ } |
const std::vector<std::unique_ptr<IndexedDBObserver>>& active_observers() |
const { |
return active_observers_; |
@@ -48,18 +56,127 @@ class CONTENT_EXPORT IndexedDBConnection { |
return weak_factory_.GetWeakPtr(); |
} |
+ // ::indexed_db::mojom::Database: |
+ void CreateObjectStore(int64_t transaction_id, |
+ int64_t object_store_id, |
+ const std::string& name, |
+ const IndexedDBKeyPath& key_path, |
+ bool auto_increment) override; |
+ |
+ void DeleteObjectStore(int64_t transaction_id, |
+ int64_t object_store_id) override; |
+ |
+ void CreateTransaction( |
+ int64_t transaction_id, |
+ const std::vector<int64_t>& scope, |
+ ::indexed_db::mojom::TransactionMode transaction_mode) override; |
+ |
+ void Close() override; |
+ |
+ void VersionChangeIgnored() override; |
+ |
+ void Abort(int64_t transaction_id) override; |
+ |
+ void Commit(int64_t transaction_id) override; |
+ |
+ void CreateIndex(int64_t transaction_id, |
+ int64_t object_store_id, |
+ int64_t index_id, |
+ const std::string& name, |
+ const IndexedDBKeyPath& key_path, |
+ bool unique, |
+ bool multi_entry) override; |
+ |
+ void DeleteIndex(int64_t transaction_id, |
+ int64_t object_store_id, |
+ int64_t index_id) override; |
+ |
+ void Get(int64_t transaction_id, |
+ int64_t object_store_id, |
+ int64_t index_id, |
+ ::indexed_db::mojom::KeyRangePtr key_range, |
+ bool key_only, |
+ const GetCallback& callback) override; |
+ |
+ void GetAll(int64_t transaction_id, |
+ int64_t object_store_id, |
+ int64_t index_id, |
+ ::indexed_db::mojom::KeyRangePtr key_range, |
+ int64_t max_count, |
+ bool key_only) override; |
+ |
+ void Put(int64_t transaction_id, |
+ int64_t object_store_id, |
+ const std::vector<int8_t>& value, |
+ std::vector<::indexed_db::mojom::BlobInfoPtr> blob_info, |
+ ::indexed_db::mojom::KeyPtr key, |
+ ::indexed_db::mojom::PutMode put_mode, |
+ const std::vector<int64_t>& index_ids, |
+ std::vector<std::vector<::indexed_db::mojom::KeyPtr>> index_keys) |
+ override; |
+ |
+ void DeleteRange(int64_t transaction_id, |
+ int64_t object_store_id, |
+ ::indexed_db::mojom::KeyRangePtr key_range) override; |
+ |
+ void Clear(int64_t transaction_id, int64_t object_store_id) override; |
+ |
+ void SetIndexKeys(int64_t transaction_id, |
+ int64_t object_store_id, |
+ ::indexed_db::mojom::KeyPtr primary_key, |
+ const std::vector<int64_t>& index_ids, |
+ std::vector<std::vector<::indexed_db::mojom::KeyPtr>> |
+ index_keys) override; |
+ |
+ void SetIndexesReady(int64_t transaction_id, |
+ int64_t object_store_id, |
+ const std::vector<int64_t>& index_ids) override; |
+ |
+ void OpenCursor(int64_t transaction_id, |
+ int64_t object_store_id, |
+ int64_t index_id, |
+ ::indexed_db::mojom::KeyRangePtr key_range, |
+ ::indexed_db::mojom::CursorDirection direction, |
+ bool key_only, |
+ ::indexed_db::mojom::TaskType task_type) override; |
+ |
+ void Count(int64_t transaction_id, |
+ int64_t object_store_id, |
+ int64_t index_id, |
+ ::indexed_db::mojom::KeyRangePtr key_range) override; |
+ |
+ void AckReceivedBlobs(const std::vector<std::string>& uuids) override; |
+ |
+ void Bind(::indexed_db::mojom::DatabaseRequest request); |
+ |
+ void RegisterTransactionId(int64_t transaction_id, const url::Origin& origin); |
+ |
+ // Misc: |
+ void FinishTransaction(int64_t transaction_id, bool committed); |
+ IndexedDBContext* context() const; |
+ |
private: |
enum { kInvalidId = -1 }; |
+ |
+ void OnGotUsageAndQuotaForCommit(int64_t transaction_id, |
+ storage::QuotaStatusCode status, |
+ int64_t usage, |
+ int64_t quota); |
// id_ is ipc_database_id |
int32_t id_ = kInvalidId; |
// NULL in some unit tests, and after the connection is closed. |
scoped_refptr<IndexedDBDatabase> database_; |
+ std::map<int64_t, url::Origin> transaction_id_to_origin_; |
+ std::map<int64_t, uint64_t> transaction_id_to_size_; |
+ std::map<int64_t, int64_t> transaction_id_to_database_id_; |
- // The callbacks_ member is cleared when the connection is closed. |
+ // The change_handler_ member is cleared when the connection is closed. |
// May be NULL in unit tests. |
- scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; |
+ scoped_refptr<IndexedDBChangeHandler> change_handler_; |
std::vector<std::unique_ptr<IndexedDBObserver>> active_observers_; |
+ // TODO(cmumford): Is it possible to use StrongBinging? |
+ mojo::BindingSet<::indexed_db::mojom::Database> binding_; |
base::WeakPtrFactory<IndexedDBConnection> weak_factory_; |
DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection); |