OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_CHILD_INDEXED_DB_INDEXED_DB_CALLBACKS_IMPL_H_ | |
6 #define CONTENT_CHILD_INDEXED_DB_INDEXED_DB_CALLBACKS_IMPL_H_ | |
7 | |
8 #include "content/common/indexed_db/indexed_db.mojom.h" | |
9 #include "mojo/public/cpp/bindings/associated_binding.h" | |
10 | |
11 namespace blink { | |
12 class WebIDBCallbacks; | |
13 } | |
14 | |
15 namespace content { | |
16 | |
17 class ThreadSafeSender; | |
18 | |
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 | |
21 // the thread which owns the blink::WebIDBCallbacks. | |
22 class IndexedDBCallbacksImpl : public indexed_db::mojom::Callbacks { | |
23 public: | |
24 class InternalState { | |
25 public: | |
26 InternalState(blink::WebIDBCallbacks* callbacks, | |
dcheng
2016/10/19 23:44:02
Nit: make this a std::unique_ptr if it's not too v
Reilly Grant (use Gerrit)
2016/10/20 01:46:18
Done.
| |
27 scoped_refptr<ThreadSafeSender> thread_safe_sender); | |
28 ~InternalState(); | |
29 | |
30 void Error(int32_t code, const base::string16& message); | |
31 void SuccessStringList(const std::vector<base::string16>& value); | |
32 void Blocked(int64_t existing_version); | |
33 void UpgradeNeeded(int32_t database_id, | |
34 int64_t old_version, | |
35 blink::WebIDBDataLoss data_loss, | |
36 const std::string& data_loss_message, | |
37 const content::IndexedDBDatabaseMetadata& metadata); | |
38 void SuccessDatabase(int32_t database_id, | |
39 const content::IndexedDBDatabaseMetadata& metadata); | |
40 void SuccessInteger(int64_t value); | |
41 | |
42 private: | |
43 std::unique_ptr<blink::WebIDBCallbacks> callbacks_; | |
44 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | |
45 | |
46 DISALLOW_COPY_AND_ASSIGN(InternalState); | |
47 }; | |
48 | |
49 IndexedDBCallbacksImpl(blink::WebIDBCallbacks* callbacks, | |
50 scoped_refptr<ThreadSafeSender> thread_safe_sender); | |
51 ~IndexedDBCallbacksImpl() override; | |
52 | |
53 // indexed_db::mojom::Callbacks implementation: | |
54 void Error(int32_t code, const base::string16& message) override; | |
55 void SuccessStringList(const std::vector<base::string16>& value) override; | |
56 void Blocked(int64_t existing_version) override; | |
57 void UpgradeNeeded( | |
58 int32_t database_id, | |
59 int64_t old_version, | |
60 blink::WebIDBDataLoss data_loss, | |
61 const std::string& data_loss_message, | |
62 const content::IndexedDBDatabaseMetadata& metadata) override; | |
63 void SuccessDatabase( | |
64 int32_t database_id, | |
65 const content::IndexedDBDatabaseMetadata& metadata) override; | |
66 void SuccessInteger(int64_t value) override; | |
67 | |
68 private: | |
69 // |internal_state_| is owned by the thread on which |callback_runner_| | |
70 // executes tasks and must be destroyed there. | |
71 InternalState* internal_state_; | |
72 scoped_refptr<base::SingleThreadTaskRunner> callback_runner_; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacksImpl); | |
75 }; | |
76 | |
77 } // namespace content | |
78 | |
79 #endif // CONTENT_CHILD_INDEXED_DB_INDEXED_DB_CALLBACKS_IMPL_H_ | |
OLD | NEW |