OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_CALLBACKS_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_CALLBACKS_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_CALLBACKS_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_CALLBACKS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "content/common/indexed_db/indexed_db.mojom.h" | 14 #include "content/common/indexed_db/indexed_db.mojom.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
| 18 class IndexedDBContextImpl; |
18 class IndexedDBDatabaseError; | 19 class IndexedDBDatabaseError; |
19 class IndexedDBDispatcherHost; | |
20 class IndexedDBTransaction; | 20 class IndexedDBTransaction; |
21 | 21 |
| 22 // Expected to be constructed on IO thread and called/deleted from IDB thread. |
22 class CONTENT_EXPORT IndexedDBDatabaseCallbacks | 23 class CONTENT_EXPORT IndexedDBDatabaseCallbacks |
23 : public base::RefCounted<IndexedDBDatabaseCallbacks> { | 24 : public base::RefCounted<IndexedDBDatabaseCallbacks> { |
24 public: | 25 public: |
25 IndexedDBDatabaseCallbacks( | 26 IndexedDBDatabaseCallbacks( |
26 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host, | 27 scoped_refptr<IndexedDBContextImpl> context, |
27 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo callbacks_info); | 28 ::indexed_db::mojom::DatabaseCallbacksAssociatedPtrInfo callbacks_info); |
28 | 29 |
29 virtual void OnForcedClose(); | 30 virtual void OnForcedClose(); |
30 virtual void OnVersionChange(int64_t old_version, int64_t new_version); | 31 virtual void OnVersionChange(int64_t old_version, int64_t new_version); |
31 | 32 |
32 virtual void OnAbort(const IndexedDBTransaction& transaction, | 33 virtual void OnAbort(const IndexedDBTransaction& transaction, |
33 const IndexedDBDatabaseError& error); | 34 const IndexedDBDatabaseError& error); |
34 virtual void OnComplete(const IndexedDBTransaction& transaction); | 35 virtual void OnComplete(const IndexedDBTransaction& transaction); |
35 virtual void OnDatabaseChange( | 36 virtual void OnDatabaseChange( |
36 ::indexed_db::mojom::ObserverChangesPtr changes); | 37 ::indexed_db::mojom::ObserverChangesPtr changes); |
37 | 38 |
38 protected: | 39 protected: |
39 virtual ~IndexedDBDatabaseCallbacks(); | 40 virtual ~IndexedDBDatabaseCallbacks(); |
40 | 41 |
41 private: | 42 private: |
42 friend class base::RefCounted<IndexedDBDatabaseCallbacks>; | 43 friend class base::RefCounted<IndexedDBDatabaseCallbacks>; |
43 | 44 |
44 class IOThreadHelper; | 45 class IOThreadHelper; |
45 | 46 |
46 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; | 47 bool complete_ = false; |
| 48 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; |
47 std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_; | 49 std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_; |
48 base::ThreadChecker thread_checker_; | 50 base::ThreadChecker thread_checker_; |
49 | 51 |
50 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabaseCallbacks); | 52 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabaseCallbacks); |
51 }; | 53 }; |
52 | 54 |
53 } // namespace content | 55 } // namespace content |
54 | 56 |
55 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_CALLBACKS_H_ | 57 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_CALLBACKS_H_ |
OLD | NEW |