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

Side by Side Diff: content/renderer/presentation/presentation_dispatcher.h

Issue 2471263003: [Presentation API] (4th)(1-UA blink side) Add WebPresentationConnection and WebPresentationConnecti… (Closed)
Patch Set: resolve code review comments from Derek and Mark Created 3 years, 11 months 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 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 CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 5 #ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Blink. It forwards the calls to the Mojo PresentationService. 42 // Blink. It forwards the calls to the Mojo PresentationService.
43 class CONTENT_EXPORT PresentationDispatcher 43 class CONTENT_EXPORT PresentationDispatcher
44 : public RenderFrameObserver, 44 : public RenderFrameObserver,
45 public NON_EXPORTED_BASE(blink::WebPresentationClient), 45 public NON_EXPORTED_BASE(blink::WebPresentationClient),
46 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) { 46 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) {
47 public: 47 public:
48 explicit PresentationDispatcher(RenderFrame* render_frame); 48 explicit PresentationDispatcher(RenderFrame* render_frame);
49 ~PresentationDispatcher() override; 49 ~PresentationDispatcher() override;
50 50
51 private: 51 private:
52 // TODO(crbug.com/684116): remove friend class after moving message queue
53 // logic from PresentationDispatcher to PresentationConnectionProxy.
54 friend class PresentationConnectionProxy;
52 friend class TestPresentationDispatcher; 55 friend class TestPresentationDispatcher;
53 friend class PresentationDispatcherTest; 56 friend class PresentationDispatcherTest;
54 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSession); 57 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSession);
55 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSessionError); 58 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSessionError);
56 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSession); 59 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSession);
57 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSessionError); 60 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSessionError);
58 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendString); 61 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendString);
59 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendArrayBuffer); 62 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendArrayBuffer);
60 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendBlobData); 63 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendBlobData);
61 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestCloseSession); 64 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestCloseSession);
62 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestTerminateSession); 65 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestTerminateSession);
63 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, 66 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest,
64 TestListenForScreenAvailability); 67 TestListenForScreenAvailability);
65 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, 68 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest,
66 TestSetDefaultPresentationUrls); 69 TestSetDefaultPresentationUrls);
67 70
68 struct SendMessageRequest { 71 struct SendMessageRequest {
69 SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info, 72 SendMessageRequest(
70 blink::mojom::ConnectionMessagePtr message); 73 blink::mojom::PresentationSessionInfoPtr session_info,
74 blink::mojom::ConnectionMessagePtr message,
75 const blink::WebPresentationConnectionProxy* connection_proxy);
71 ~SendMessageRequest(); 76 ~SendMessageRequest();
72 77
73 blink::mojom::PresentationSessionInfoPtr session_info; 78 blink::mojom::PresentationSessionInfoPtr session_info;
74 blink::mojom::ConnectionMessagePtr message; 79 blink::mojom::ConnectionMessagePtr message;
80 // Proxy of Blink connection object |connection| calling connection.send().
81 // It does not take ownership of proxy object. Proxy object is owned by
82 // Blink connection. Blink connection is destroyed after
83 // PresentationDispatcher so |connection_proxy| should always be valid.
84 const blink::WebPresentationConnectionProxy* connection_proxy;
75 }; 85 };
76 86
77 static SendMessageRequest* CreateSendTextMessageRequest( 87 static SendMessageRequest* CreateSendTextMessageRequest(
78 const blink::WebURL& presentationUrl, 88 const blink::WebURL& presentationUrl,
79 const blink::WebString& presentationId, 89 const blink::WebString& presentationId,
80 const blink::WebString& message); 90 const blink::WebString& message,
91 const blink::WebPresentationConnectionProxy* connection_proxy);
81 static SendMessageRequest* CreateSendBinaryMessageRequest( 92 static SendMessageRequest* CreateSendBinaryMessageRequest(
82 const blink::WebURL& presentationUrl, 93 const blink::WebURL& presentationUrl,
83 const blink::WebString& presentationId, 94 const blink::WebString& presentationId,
84 blink::mojom::PresentationMessageType type, 95 blink::mojom::PresentationMessageType type,
85 const uint8_t* data, 96 const uint8_t* data,
86 size_t length); 97 size_t length,
98 const blink::WebPresentationConnectionProxy* connection_proxy);
87 99
88 // WebPresentationClient implementation. 100 // WebPresentationClient implementation.
89 void setController(blink::WebPresentationController* controller) override; 101 void setController(blink::WebPresentationController* controller) override;
90 void setReceiver(blink::WebPresentationReceiver*) override; 102 void setReceiver(blink::WebPresentationReceiver*) override;
91
92 void startSession(const blink::WebVector<blink::WebURL>& presentationUrls, 103 void startSession(const blink::WebVector<blink::WebURL>& presentationUrls,
93 std::unique_ptr<blink::WebPresentationConnectionCallback> 104 std::unique_ptr<blink::WebPresentationConnectionCallbacks>
94 callback) override; 105 callback) override;
95 void joinSession(const blink::WebVector<blink::WebURL>& presentationUrls, 106 void joinSession(const blink::WebVector<blink::WebURL>& presentationUrls,
96 const blink::WebString& presentationId, 107 const blink::WebString& presentationId,
97 std::unique_ptr<blink::WebPresentationConnectionCallback> 108 std::unique_ptr<blink::WebPresentationConnectionCallbacks>
98 callback) override; 109 callback) override;
99 void sendString(const blink::WebURL& presentationUrl, 110 void sendString(
100 const blink::WebString& presentationId, 111 const blink::WebURL& presentationUrl,
101 const blink::WebString& message) override; 112 const blink::WebString& presentationId,
102 void sendArrayBuffer(const blink::WebURL& presentationUrl, 113 const blink::WebString& message,
103 const blink::WebString& presentationId, 114 const blink::WebPresentationConnectionProxy* connection_proxy) override;
104 const uint8_t* data, 115 void sendArrayBuffer(
105 size_t length) override; 116 const blink::WebURL& presentationUrl,
106 void sendBlobData(const blink::WebURL& presentationUrl, 117 const blink::WebString& presentationId,
107 const blink::WebString& presentationId, 118 const uint8_t* data,
108 const uint8_t* data, 119 size_t length,
109 size_t length) override; 120 const blink::WebPresentationConnectionProxy* connection_proxy) override;
121 void sendBlobData(
122 const blink::WebURL& presentationUrl,
123 const blink::WebString& presentationId,
124 const uint8_t* data,
125 size_t length,
126 const blink::WebPresentationConnectionProxy* connection_proxy) override;
110 void closeSession(const blink::WebURL& presentationUrl, 127 void closeSession(const blink::WebURL& presentationUrl,
111 const blink::WebString& presentationId) override; 128 const blink::WebString& presentationId) override;
112 void terminateSession(const blink::WebURL& presentationUrl, 129 void terminateSession(const blink::WebURL& presentationUrl,
113 const blink::WebString& presentationId) override; 130 const blink::WebString& presentationId) override;
114 void getAvailability( 131 void getAvailability(
115 const blink::WebVector<blink::WebURL>& availabilityUrls, 132 const blink::WebVector<blink::WebURL>& availabilityUrls,
116 std::unique_ptr<blink::WebPresentationAvailabilityCallbacks> callbacks) 133 std::unique_ptr<blink::WebPresentationAvailabilityCallbacks> callbacks)
117 override; 134 override;
118 void startListening(blink::WebPresentationAvailabilityObserver*) override; 135 void startListening(blink::WebPresentationAvailabilityObserver*) override;
119 void stopListening(blink::WebPresentationAvailabilityObserver*) override; 136 void stopListening(blink::WebPresentationAvailabilityObserver*) override;
(...skipping 16 matching lines...) Expand all
136 blink::mojom::PresentationSessionInfoPtr session_info, 153 blink::mojom::PresentationSessionInfoPtr session_info,
137 blink::mojom::PresentationConnectionCloseReason reason, 154 blink::mojom::PresentationConnectionCloseReason reason,
138 const std::string& message) override; 155 const std::string& message) override;
139 void OnConnectionMessagesReceived( 156 void OnConnectionMessagesReceived(
140 blink::mojom::PresentationSessionInfoPtr session_info, 157 blink::mojom::PresentationSessionInfoPtr session_info,
141 std::vector<blink::mojom::ConnectionMessagePtr> messages) override; 158 std::vector<blink::mojom::ConnectionMessagePtr> messages) override;
142 void OnDefaultSessionStarted( 159 void OnDefaultSessionStarted(
143 blink::mojom::PresentationSessionInfoPtr session_info) override; 160 blink::mojom::PresentationSessionInfoPtr session_info) override;
144 161
145 void OnSessionCreated( 162 void OnSessionCreated(
146 std::unique_ptr<blink::WebPresentationConnectionCallback> callback, 163 std::unique_ptr<blink::WebPresentationConnectionCallbacks> callback,
147 blink::mojom::PresentationSessionInfoPtr session_info, 164 blink::mojom::PresentationSessionInfoPtr session_info,
148 blink::mojom::PresentationErrorPtr error); 165 blink::mojom::PresentationErrorPtr error);
149 void OnReceiverConnectionAvailable( 166 void OnReceiverConnectionAvailable(
150 blink::mojom::PresentationSessionInfoPtr, 167 blink::mojom::PresentationSessionInfoPtr,
151 blink::mojom::PresentationConnectionPtr, 168 blink::mojom::PresentationConnectionPtr,
152 blink::mojom::PresentationConnectionRequest) override; 169 blink::mojom::PresentationConnectionRequest) override;
153 170
154 // Call to PresentationService to send the message in |request|. 171 // Call to PresentationService to send the message in |request|.
155 // |session_info| and |message| of |reuqest| will be consumed. 172 // |session_info| and |message| of |reuqest| will be consumed.
156 // |HandleSendMessageRequests| will be invoked after the send is attempted. 173 // |HandleSendMessageRequests| will be invoked after the send is attempted.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // Returns UNKNOWN if all urls in |urls| have screen availability 262 // Returns UNKNOWN if all urls in |urls| have screen availability
246 // UNKNOWN. 263 // UNKNOWN.
247 ScreenAvailability GetScreenAvailability(const std::vector<GURL>& urls) const; 264 ScreenAvailability GetScreenAvailability(const std::vector<GURL>& urls) const;
248 265
249 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); 266 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher);
250 }; 267 };
251 268
252 } // namespace content 269 } // namespace content
253 270
254 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 271 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698