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

Side by Side Diff: content/child/indexed_db/indexed_db_callbacks_impl.h

Issue 2449953008: Port messages sent by WebIDBDatabaseImpl to Mojo. (Closed)
Patch Set: Address cmumford@ and jsbell@'s comments. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_CHILD_INDEXED_DB_INDEXED_DB_CALLBACKS_IMPL_H_ 5 #ifndef CONTENT_CHILD_INDEXED_DB_INDEXED_DB_CALLBACKS_IMPL_H_
6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_CALLBACKS_IMPL_H_ 6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_CALLBACKS_IMPL_H_
7 7
8 #include "content/common/indexed_db/indexed_db.mojom.h" 8 #include "content/common/indexed_db/indexed_db.mojom.h"
9 #include "mojo/public/cpp/bindings/associated_binding.h" 9 #include "mojo/public/cpp/bindings/associated_binding.h"
10 10
11 namespace blink { 11 namespace blink {
12 class WebIDBCallbacks; 12 class WebIDBCallbacks;
13 } 13 }
14 14
15 namespace content { 15 namespace content {
16 16
17 class ThreadSafeSender; 17 class ThreadSafeSender;
18 18
19 // Implements the child-process end of the pipe used to deliver callbacks. It 19 // Implements the child-process end of the pipe used to deliver callbacks. It
20 // is owned by the IO thread. |callback_runner_| is used to post tasks back to 20 // is owned by the IO thread. |callback_runner_| is used to post tasks back to
21 // the thread which owns the blink::WebIDBCallbacks. 21 // the thread which owns the blink::WebIDBCallbacks.
22 class IndexedDBCallbacksImpl : public indexed_db::mojom::Callbacks { 22 class IndexedDBCallbacksImpl : public indexed_db::mojom::Callbacks {
23 public: 23 public:
24 enum : int64_t { kNoTransaction = -1 };
25
26 // This class holds the parts of the internal state of IndexedDBCallbacksImpl
27 // that must live on whatever renderer or worker thread the API is used from.
24 class InternalState { 28 class InternalState {
25 public: 29 public:
26 InternalState(std::unique_ptr<blink::WebIDBCallbacks> callbacks, 30 InternalState(std::unique_ptr<blink::WebIDBCallbacks> callbacks,
31 int64_t transaction_id,
32 scoped_refptr<base::SingleThreadTaskRunner> io_runner,
27 scoped_refptr<ThreadSafeSender> thread_safe_sender); 33 scoped_refptr<ThreadSafeSender> thread_safe_sender);
28 ~InternalState(); 34 ~InternalState();
29 35
30 void Error(int32_t code, const base::string16& message); 36 void Error(int32_t code, const base::string16& message);
31 void SuccessStringList(const std::vector<base::string16>& value); 37 void SuccessStringList(const std::vector<base::string16>& value);
32 void Blocked(int64_t existing_version); 38 void Blocked(int64_t existing_version);
33 void UpgradeNeeded(int32_t database_id, 39 void UpgradeNeeded(indexed_db::mojom::DatabaseAssociatedPtrInfo database,
34 int64_t old_version, 40 int64_t old_version,
35 blink::WebIDBDataLoss data_loss, 41 blink::WebIDBDataLoss data_loss,
36 const std::string& data_loss_message, 42 const std::string& data_loss_message,
37 const content::IndexedDBDatabaseMetadata& metadata); 43 const content::IndexedDBDatabaseMetadata& metadata);
38 void SuccessDatabase(int32_t database_id, 44 void SuccessDatabase(indexed_db::mojom::DatabaseAssociatedPtrInfo database,
39 const content::IndexedDBDatabaseMetadata& metadata); 45 const content::IndexedDBDatabaseMetadata& metadata);
46 void SuccessCursor(int32_t cursor_id,
47 const IndexedDBKey& key,
48 const IndexedDBKey& primary_key,
49 indexed_db::mojom::ValuePtr value);
50 void SuccessValue(indexed_db::mojom::ReturnValuePtr value);
51 void SuccessArray(std::vector<indexed_db::mojom::ReturnValuePtr> values);
52 void SuccessKey(const IndexedDBKey& key);
40 void SuccessInteger(int64_t value); 53 void SuccessInteger(int64_t value);
54 void Success();
41 55
42 private: 56 private:
43 std::unique_ptr<blink::WebIDBCallbacks> callbacks_; 57 std::unique_ptr<blink::WebIDBCallbacks> callbacks_;
58 int64_t transaction_id_;
59 scoped_refptr<base::SingleThreadTaskRunner> io_runner_;
44 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 60 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
45 61
46 DISALLOW_COPY_AND_ASSIGN(InternalState); 62 DISALLOW_COPY_AND_ASSIGN(InternalState);
47 }; 63 };
48 64
49 IndexedDBCallbacksImpl(std::unique_ptr<blink::WebIDBCallbacks> callbacks, 65 IndexedDBCallbacksImpl(std::unique_ptr<blink::WebIDBCallbacks> callbacks,
66 int64_t transaction_id,
67 scoped_refptr<base::SingleThreadTaskRunner> io_runner,
50 scoped_refptr<ThreadSafeSender> thread_safe_sender); 68 scoped_refptr<ThreadSafeSender> thread_safe_sender);
51 ~IndexedDBCallbacksImpl() override; 69 ~IndexedDBCallbacksImpl() override;
52 70
53 // indexed_db::mojom::Callbacks implementation: 71 // indexed_db::mojom::Callbacks implementation:
54 void Error(int32_t code, const base::string16& message) override; 72 void Error(int32_t code, const base::string16& message) override;
55 void SuccessStringList(const std::vector<base::string16>& value) override; 73 void SuccessStringList(const std::vector<base::string16>& value) override;
56 void Blocked(int64_t existing_version) override; 74 void Blocked(int64_t existing_version) override;
57 void UpgradeNeeded( 75 void UpgradeNeeded(
58 int32_t database_id, 76 indexed_db::mojom::DatabaseAssociatedPtrInfo database_info,
59 int64_t old_version, 77 int64_t old_version,
60 blink::WebIDBDataLoss data_loss, 78 blink::WebIDBDataLoss data_loss,
61 const std::string& data_loss_message, 79 const std::string& data_loss_message,
62 const content::IndexedDBDatabaseMetadata& metadata) override; 80 const content::IndexedDBDatabaseMetadata& metadata) override;
63 void SuccessDatabase( 81 void SuccessDatabase(
64 int32_t database_id, 82 indexed_db::mojom::DatabaseAssociatedPtrInfo database_info,
65 const content::IndexedDBDatabaseMetadata& metadata) override; 83 const content::IndexedDBDatabaseMetadata& metadata) override;
84 void SuccessCursor(int32_t cursor_id,
85 const IndexedDBKey& key,
86 const IndexedDBKey& primary_key,
87 indexed_db::mojom::ValuePtr value) override;
88 void SuccessValue(indexed_db::mojom::ReturnValuePtr value) override;
89 void SuccessArray(
90 std::vector<indexed_db::mojom::ReturnValuePtr> values) override;
91 void SuccessKey(const IndexedDBKey& key) override;
66 void SuccessInteger(int64_t value) override; 92 void SuccessInteger(int64_t value) override;
93 void Success() override;
67 94
68 private: 95 private:
69 // |internal_state_| is owned by the thread on which |callback_runner_| 96 // |internal_state_| is owned by the thread on which |callback_runner_|
70 // executes tasks and must be destroyed there. 97 // executes tasks and must be destroyed there.
71 InternalState* internal_state_; 98 InternalState* internal_state_;
72 scoped_refptr<base::SingleThreadTaskRunner> callback_runner_; 99 scoped_refptr<base::SingleThreadTaskRunner> callback_runner_;
73 100
74 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacksImpl); 101 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacksImpl);
75 }; 102 };
76 103
77 } // namespace content 104 } // namespace content
78 105
79 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_CALLBACKS_IMPL_H_ 106 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_CALLBACKS_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698