OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 PresentationConnectionCallbacks_h | 5 #ifndef PresentationConnectionCallbacks_h |
6 #define PresentationConnectionCallbacks_h | 6 #define PresentationConnectionCallbacks_h |
7 | 7 |
8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
9 #include "public/platform/WebCallbacks.h" | 9 #include "public/platform/WebCallbacks.h" |
| 10 #include "public/platform/modules/presentation/WebPresentationConnectionCallback
s.h" |
10 #include "wtf/Noncopyable.h" | 11 #include "wtf/Noncopyable.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
| 15 class PresentationConnection; |
14 class PresentationRequest; | 16 class PresentationRequest; |
15 class ScriptPromiseResolver; | 17 class ScriptPromiseResolver; |
16 struct WebPresentationSessionInfo; | 18 struct WebPresentationSessionInfo; |
17 struct WebPresentationError; | 19 struct WebPresentationError; |
18 | 20 |
19 // PresentationConnectionCallbacks extends WebCallbacks to resolve the | 21 // PresentationConnectionCallbacks extends WebCallbacks to resolve the |
20 // underlying promise depending on the result passed to the callback. It takes | 22 // underlying promise depending on the result passed to the callback. It takes |
21 // the PresentationRequest object that originated the call in its constructor | 23 // the PresentationRequest object that originated the call in its constructor |
22 // and will pass it to the created PresentationConnection. | 24 // and will pass it to the created PresentationConnection. |
23 class PresentationConnectionCallbacks final | 25 class PresentationConnectionCallbacks final |
24 : public WebCallbacks<const WebPresentationSessionInfo&, | 26 : public WebPresentationConnectionCallbacks { |
25 const WebPresentationError&> { | |
26 public: | 27 public: |
27 PresentationConnectionCallbacks(ScriptPromiseResolver*, PresentationRequest*); | 28 PresentationConnectionCallbacks(ScriptPromiseResolver*, PresentationRequest*); |
28 ~PresentationConnectionCallbacks() override = default; | 29 ~PresentationConnectionCallbacks() override = default; |
29 | 30 |
| 31 // WebCallbacks implementation |
30 void onSuccess(const WebPresentationSessionInfo&) override; | 32 void onSuccess(const WebPresentationSessionInfo&) override; |
31 void onError(const WebPresentationError&) override; | 33 void onError(const WebPresentationError&) override; |
32 | 34 |
| 35 // WebPresentationConnectionCallbacks implementation |
| 36 WebPresentationConnection* getConnection() override; |
| 37 |
33 private: | 38 private: |
34 Persistent<ScriptPromiseResolver> m_resolver; | 39 Persistent<ScriptPromiseResolver> m_resolver; |
35 Persistent<PresentationRequest> m_request; | 40 Persistent<PresentationRequest> m_request; |
| 41 WeakPersistent<PresentationConnection> m_connection; |
36 | 42 |
37 WTF_MAKE_NONCOPYABLE(PresentationConnectionCallbacks); | 43 WTF_MAKE_NONCOPYABLE(PresentationConnectionCallbacks); |
38 }; | 44 }; |
39 | 45 |
40 } // namespace blink | 46 } // namespace blink |
41 | 47 |
42 #endif // PresentationConnectionCallbacks_h | 48 #endif // PresentationConnectionCallbacks_h |
OLD | NEW |