Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 PresentationConnection_h | 5 #ifndef PresentationConnection_h |
| 6 #define PresentationConnection_h | 6 #define PresentationConnection_h |
| 7 | 7 |
| 8 #include "core/dom/ContextLifecycleObserver.h" | 8 #include "core/dom/ContextLifecycleObserver.h" |
| 9 #include "core/events/EventTarget.h" | 9 #include "core/events/EventTarget.h" |
| 10 #include "core/fileapi/Blob.h" | 10 #include "core/fileapi/Blob.h" |
| 11 #include "core/fileapi/FileError.h" | 11 #include "core/fileapi/FileError.h" |
| 12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 13 #include "platform/weborigin/KURL.h" | 13 #include "platform/weborigin/KURL.h" |
| 14 #include "public/platform/modules/presentation/WebPresentationConnection.h" | |
| 15 #include "public/platform/modules/presentation/WebPresentationConnectionProxy.h" | |
| 14 #include "public/platform/modules/presentation/WebPresentationController.h" | 16 #include "public/platform/modules/presentation/WebPresentationController.h" |
| 15 #include "public/platform/modules/presentation/WebPresentationSessionInfo.h" | 17 #include "public/platform/modules/presentation/WebPresentationSessionInfo.h" |
| 16 #include "wtf/text/WTFString.h" | 18 #include "wtf/text/WTFString.h" |
| 17 #include <memory> | 19 #include <memory> |
| 18 | 20 |
| 19 namespace WTF { | 21 namespace WTF { |
| 20 class AtomicString; | 22 class AtomicString; |
| 21 } // namespace WTF | 23 } // namespace WTF |
| 22 | 24 |
| 23 namespace blink { | 25 namespace blink { |
| 24 | 26 |
| 25 class DOMArrayBuffer; | 27 class DOMArrayBuffer; |
| 26 class DOMArrayBufferView; | 28 class DOMArrayBufferView; |
| 27 class PresentationController; | 29 class PresentationController; |
| 28 class PresentationReceiver; | 30 class PresentationReceiver; |
| 29 class PresentationRequest; | 31 class PresentationRequest; |
| 30 | 32 |
| 31 class PresentationConnection final : public EventTargetWithInlineData, | 33 class PresentationConnection final : public EventTargetWithInlineData, |
| 32 public ContextClient { | 34 public ContextClient, |
| 35 public WebPresentationConnection { | |
| 33 USING_GARBAGE_COLLECTED_MIXIN(PresentationConnection); | 36 USING_GARBAGE_COLLECTED_MIXIN(PresentationConnection); |
| 34 DEFINE_WRAPPERTYPEINFO(); | 37 DEFINE_WRAPPERTYPEINFO(); |
| 35 | 38 |
| 36 public: | 39 public: |
| 37 // For CallbackPromiseAdapter. | 40 // For CallbackPromiseAdapter. |
| 38 static PresentationConnection* take(ScriptPromiseResolver*, | 41 static PresentationConnection* take(ScriptPromiseResolver*, |
| 39 const WebPresentationSessionInfo&, | 42 const WebPresentationSessionInfo&, |
| 40 PresentationRequest*); | 43 PresentationRequest*); |
| 41 static PresentationConnection* take(PresentationController*, | 44 static PresentationConnection* take(PresentationController*, |
| 42 const WebPresentationSessionInfo&, | 45 const WebPresentationSessionInfo&, |
| 43 PresentationRequest*); | 46 PresentationRequest*); |
| 44 static PresentationConnection* take(PresentationReceiver*, | 47 static PresentationConnection* take(PresentationReceiver*, |
| 45 const WebPresentationSessionInfo&); | 48 const WebPresentationSessionInfo&); |
| 46 ~PresentationConnection() override; | 49 ~PresentationConnection() override; |
| 47 | 50 |
| 51 void bindProxy(std::unique_ptr<WebPresentationConnectionProxy>) override; | |
|
imcheng
2017/01/20 20:15:43
nit: group the override methods together and comme
zhaobin
2017/01/23 19:38:49
Done.
| |
| 52 | |
| 48 // EventTarget implementation. | 53 // EventTarget implementation. |
| 49 const AtomicString& interfaceName() const override; | 54 const AtomicString& interfaceName() const override; |
| 50 ExecutionContext* getExecutionContext() const override; | 55 ExecutionContext* getExecutionContext() const override; |
| 51 | 56 |
| 52 DECLARE_VIRTUAL_TRACE(); | 57 DECLARE_VIRTUAL_TRACE(); |
| 53 | 58 |
| 54 const String& id() const { return m_id; } | 59 const String& id() const { return m_id; } |
| 55 const String& url() const { return m_url; } | 60 const String& url() const { return m_url; } |
| 56 const WTF::AtomicString& state() const; | 61 const WTF::AtomicString& state() const; |
| 57 | 62 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 72 | 77 |
| 73 // Returns true if and only if the the session info represents this | 78 // Returns true if and only if the the session info represents this |
| 74 // connection. | 79 // connection. |
| 75 bool matches(const WebPresentationSessionInfo&) const; | 80 bool matches(const WebPresentationSessionInfo&) const; |
| 76 | 81 |
| 77 // Returns true if this connection's id equals to |id| and its url equals to | 82 // Returns true if this connection's id equals to |id| and its url equals to |
| 78 // |url|. | 83 // |url|. |
| 79 bool matches(const String& id, const KURL&) const; | 84 bool matches(const String& id, const KURL&) const; |
| 80 | 85 |
| 81 // Notifies the connection about its state change. | 86 // Notifies the connection about its state change. |
| 82 void didChangeState(WebPresentationConnectionState); | 87 void didChangeState(WebPresentationConnectionState) override; |
| 83 | 88 |
| 84 // Notifies the connection about its state change to 'closed'. | 89 // Notifies the connection about its state change to 'closed'. |
| 85 void didClose(WebPresentationConnectionCloseReason, const String& message); | 90 void didClose(WebPresentationConnectionCloseReason, const String& message); |
| 86 | 91 |
| 87 // Notifies the presentation about new message. | 92 // Notifies the presentation about new message. |
| 88 void didReceiveTextMessage(const String& message); | 93 void didReceiveTextMessage(const WebString& message) override; |
| 89 void didReceiveBinaryMessage(const uint8_t* data, size_t length); | 94 void didReceiveBinaryMessage(const uint8_t* data, size_t length) override; |
| 90 | 95 |
| 91 WebPresentationConnectionState getState(); | 96 WebPresentationConnectionState getState(); |
| 92 | 97 |
| 93 protected: | 98 protected: |
| 94 // EventTarget implementation. | 99 // EventTarget implementation. |
| 95 void addedEventListener(const AtomicString& eventType, | 100 void addedEventListener(const AtomicString& eventType, |
| 96 RegisteredEventListener&) override; | 101 RegisteredEventListener&) override; |
| 97 | 102 |
| 98 private: | 103 private: |
| 99 class BlobLoader; | 104 class BlobLoader; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 126 | 131 |
| 127 String m_id; | 132 String m_id; |
| 128 KURL m_url; | 133 KURL m_url; |
| 129 WebPresentationConnectionState m_state; | 134 WebPresentationConnectionState m_state; |
| 130 | 135 |
| 131 // For Blob data handling. | 136 // For Blob data handling. |
| 132 Member<BlobLoader> m_blobLoader; | 137 Member<BlobLoader> m_blobLoader; |
| 133 HeapDeque<Member<Message>> m_messages; | 138 HeapDeque<Member<Message>> m_messages; |
| 134 | 139 |
| 135 BinaryType m_binaryType; | 140 BinaryType m_binaryType; |
| 141 | |
| 142 std::unique_ptr<WebPresentationConnectionProxy> m_proxy; | |
| 136 }; | 143 }; |
| 137 | 144 |
| 138 } // namespace blink | 145 } // namespace blink |
| 139 | 146 |
| 140 #endif // PresentationConnection_h | 147 #endif // PresentationConnection_h |
| OLD | NEW |