1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_CALLBACKS_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_CALLBACKS_H_ 7 8 #include <stdint.h> 9 10 #include <memory> 11 12 #include "base/macros.h" 13 #include "base/memory/scoped_refptr.h" 14 #include "base/sequence_checker.h" 15 #include "content/common/content_export.h" 16 #include "mojo/public/cpp/bindings/associated_remote.h" 17 #include "mojo/public/cpp/bindings/pending_associated_remote.h" 18 #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom.h" 19 20 namespace content { 21 class IndexedDBContextImpl; 22 class IndexedDBDatabaseError; 23 class IndexedDBTransaction; 24 25 // Expected to be constructed/called/deleted on IDB sequence. 26 class CONTENT_EXPORT IndexedDBDatabaseCallbacks 27 : public base::RefCounted<IndexedDBDatabaseCallbacks> { 28 public: 29 IndexedDBDatabaseCallbacks( 30 scoped_refptr<IndexedDBContextImpl> context, 31 mojo::PendingAssociatedRemote<blink::mojom::IDBDatabaseCallbacks> 32 callbacks_remote, 33 base::SequencedTaskRunner* idb_runner); 34 35 virtual void OnForcedClose(); 36 virtual void OnVersionChange(int64_t old_version, int64_t new_version); 37 38 virtual void OnAbort(const IndexedDBTransaction& transaction, 39 const IndexedDBDatabaseError& error); 40 virtual void OnComplete(const IndexedDBTransaction& transaction); 41 virtual void OnDatabaseChange(blink::mojom::IDBObserverChangesPtr changes); 42 43 void OnConnectionError(); 44 45 protected: 46 virtual ~IndexedDBDatabaseCallbacks(); 47 48 private: 49 friend class base::RefCounted<IndexedDBDatabaseCallbacks>; 50 51 bool complete_ = false; 52 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; 53 mojo::AssociatedRemote<blink::mojom::IDBDatabaseCallbacks> callbacks_; 54 SEQUENCE_CHECKER(sequence_checker_); 55 56 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabaseCallbacks); 57 }; 58 59 } // namespace content 60 61 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_CALLBACKS_H_ 62