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

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: resolving code review comments from Derek 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(zhaobin): remove friend class after moving message queue logic
53 // from PresentationDispatcher to PresentationConnectionProxy.
mark a. foltz 2017/01/23 20:18:42 That would be great. Eventually we want to get ri
zhaobin 2017/01/24 01:23:24 Done.
54 friend class PresentationConnectionProxy;
52 friend class TestPresentationDispatcher; 55 friend class TestPresentationDispatcher;
53 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSession); 56 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSession);
54 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSessionError); 57 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestStartSessionError);
55 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSession); 58 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSession);
56 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSessionError); 59 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestJoinSessionError);
57 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendString); 60 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendString);
58 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendArrayBuffer); 61 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendArrayBuffer);
59 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendBlobData); 62 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendBlobData);
60 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestCloseSession); 63 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestCloseSession);
61 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestTerminateSession); 64 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestTerminateSession);
62 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, 65 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest,
63 TestListenForScreenAvailability); 66 TestListenForScreenAvailability);
64 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, 67 FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest,
65 TestSetDefaultPresentationUrls); 68 TestSetDefaultPresentationUrls);
66 69
67 struct SendMessageRequest { 70 struct SendMessageRequest {
68 SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info, 71 SendMessageRequest(
69 blink::mojom::ConnectionMessagePtr message); 72 blink::mojom::PresentationSessionInfoPtr session_info,
73 blink::mojom::ConnectionMessagePtr message,
74 const blink::WebPresentationConnectionProxy* connection_proxy);
70 ~SendMessageRequest(); 75 ~SendMessageRequest();
71 76
72 blink::mojom::PresentationSessionInfoPtr session_info; 77 blink::mojom::PresentationSessionInfoPtr session_info;
73 blink::mojom::ConnectionMessagePtr message; 78 blink::mojom::ConnectionMessagePtr message;
79 // Proxy of blink connection object |connection| calling connection.send().
80 // It does not take ownership of proxy object. Proxy object is owned by
81 // blink connection. Blink connection is destroyed after
mark a. foltz 2017/01/23 20:18:42 s/blink/Blink/ throughout in comments
zhaobin 2017/01/24 01:23:24 Done.
82 // PresentationDispatcher so |connection_proxy| should always be valid.
83 const blink::WebPresentationConnectionProxy* connection_proxy;
74 }; 84 };
75 85
76 static SendMessageRequest* CreateSendTextMessageRequest( 86 static SendMessageRequest* CreateSendTextMessageRequest(
77 const blink::WebURL& presentationUrl, 87 const blink::WebURL& presentationUrl,
78 const blink::WebString& presentationId, 88 const blink::WebString& presentationId,
79 const blink::WebString& message); 89 const blink::WebString& message,
90 const blink::WebPresentationConnectionProxy* connection_proxy);
80 static SendMessageRequest* CreateSendBinaryMessageRequest( 91 static SendMessageRequest* CreateSendBinaryMessageRequest(
81 const blink::WebURL& presentationUrl, 92 const blink::WebURL& presentationUrl,
82 const blink::WebString& presentationId, 93 const blink::WebString& presentationId,
83 blink::mojom::PresentationMessageType type, 94 blink::mojom::PresentationMessageType type,
84 const uint8_t* data, 95 const uint8_t* data,
85 size_t length); 96 size_t length,
97 const blink::WebPresentationConnectionProxy* connection_proxy);
86 98
87 // WebPresentationClient implementation. 99 // WebPresentationClient implementation.
88 void setController(blink::WebPresentationController* controller) override; 100 void setController(blink::WebPresentationController* controller) override;
89 void setReceiver(blink::WebPresentationReceiver*) override; 101 void setReceiver(blink::WebPresentationReceiver*) override;
90
91 void startSession(const blink::WebVector<blink::WebURL>& presentationUrls, 102 void startSession(const blink::WebVector<blink::WebURL>& presentationUrls,
92 std::unique_ptr<blink::WebPresentationConnectionCallback> 103 std::unique_ptr<blink::WebPresentationConnectionCallbacks>
93 callback) override; 104 callback) override;
94 void joinSession(const blink::WebVector<blink::WebURL>& presentationUrls, 105 void joinSession(const blink::WebVector<blink::WebURL>& presentationUrls,
95 const blink::WebString& presentationId, 106 const blink::WebString& presentationId,
96 std::unique_ptr<blink::WebPresentationConnectionCallback> 107 std::unique_ptr<blink::WebPresentationConnectionCallbacks>
97 callback) override; 108 callback) override;
98 void sendString(const blink::WebURL& presentationUrl, 109 void sendString(
99 const blink::WebString& presentationId, 110 const blink::WebURL& presentationUrl,
100 const blink::WebString& message) override; 111 const blink::WebString& presentationId,
101 void sendArrayBuffer(const blink::WebURL& presentationUrl, 112 const blink::WebString& message,
102 const blink::WebString& presentationId, 113 const blink::WebPresentationConnectionProxy* connection_proxy) override;
103 const uint8_t* data, 114 void sendArrayBuffer(
104 size_t length) override; 115 const blink::WebURL& presentationUrl,
105 void sendBlobData(const blink::WebURL& presentationUrl, 116 const blink::WebString& presentationId,
106 const blink::WebString& presentationId, 117 const uint8_t* data,
107 const uint8_t* data, 118 size_t length,
108 size_t length) override; 119 const blink::WebPresentationConnectionProxy* connection_proxy) override;
120 void sendBlobData(
121 const blink::WebURL& presentationUrl,
122 const blink::WebString& presentationId,
123 const uint8_t* data,
124 size_t length,
125 const blink::WebPresentationConnectionProxy* connection_proxy) override;
109 void closeSession(const blink::WebURL& presentationUrl, 126 void closeSession(const blink::WebURL& presentationUrl,
110 const blink::WebString& presentationId) override; 127 const blink::WebString& presentationId) override;
111 void terminateSession(const blink::WebURL& presentationUrl, 128 void terminateSession(const blink::WebURL& presentationUrl,
112 const blink::WebString& presentationId) override; 129 const blink::WebString& presentationId) override;
113 void getAvailability( 130 void getAvailability(
114 const blink::WebVector<blink::WebURL>& availabilityUrl, 131 const blink::WebVector<blink::WebURL>& availabilityUrl,
115 std::unique_ptr<blink::WebPresentationAvailabilityCallbacks> callbacks) 132 std::unique_ptr<blink::WebPresentationAvailabilityCallbacks> callbacks)
116 override; 133 override;
117 void startListening(blink::WebPresentationAvailabilityObserver*) override; 134 void startListening(blink::WebPresentationAvailabilityObserver*) override;
118 void stopListening(blink::WebPresentationAvailabilityObserver*) override; 135 void stopListening(blink::WebPresentationAvailabilityObserver*) override;
(...skipping 16 matching lines...) Expand all
135 blink::mojom::PresentationSessionInfoPtr session_info, 152 blink::mojom::PresentationSessionInfoPtr session_info,
136 blink::mojom::PresentationConnectionCloseReason reason, 153 blink::mojom::PresentationConnectionCloseReason reason,
137 const std::string& message) override; 154 const std::string& message) override;
138 void OnConnectionMessagesReceived( 155 void OnConnectionMessagesReceived(
139 blink::mojom::PresentationSessionInfoPtr session_info, 156 blink::mojom::PresentationSessionInfoPtr session_info,
140 std::vector<blink::mojom::ConnectionMessagePtr> messages) override; 157 std::vector<blink::mojom::ConnectionMessagePtr> messages) override;
141 void OnDefaultSessionStarted( 158 void OnDefaultSessionStarted(
142 blink::mojom::PresentationSessionInfoPtr session_info) override; 159 blink::mojom::PresentationSessionInfoPtr session_info) override;
143 160
144 void OnSessionCreated( 161 void OnSessionCreated(
145 std::unique_ptr<blink::WebPresentationConnectionCallback> callback, 162 std::unique_ptr<blink::WebPresentationConnectionCallbacks> callback,
146 blink::mojom::PresentationSessionInfoPtr session_info, 163 blink::mojom::PresentationSessionInfoPtr session_info,
147 blink::mojom::PresentationErrorPtr error); 164 blink::mojom::PresentationErrorPtr error);
148 void OnReceiverConnectionAvailable( 165 void OnReceiverConnectionAvailable(
149 blink::mojom::PresentationSessionInfoPtr, 166 blink::mojom::PresentationSessionInfoPtr,
150 blink::mojom::PresentationConnectionPtr, 167 blink::mojom::PresentationConnectionPtr,
151 blink::mojom::PresentationConnectionRequest) override; 168 blink::mojom::PresentationConnectionRequest) override;
152 169
153 // Call to PresentationService to send the message in |request|. 170 // Call to PresentationService to send the message in |request|.
154 // |session_info| and |message| of |reuqest| will be consumed. 171 // |session_info| and |message| of |reuqest| will be consumed.
155 // |HandleSendMessageRequests| will be invoked after the send is attempted. 172 // |HandleSendMessageRequests| will be invoked after the send is attempted.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // Updates the listening state of availability for |status| and notifies the 218 // Updates the listening state of availability for |status| and notifies the
202 // client. 219 // client.
203 void UpdateListeningState(AvailabilityStatus* status); 220 void UpdateListeningState(AvailabilityStatus* status);
204 221
205 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); 222 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher);
206 }; 223 };
207 224
208 } // namespace content 225 } // namespace content
209 226
210 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 227 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698