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

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

Issue 2340433003: [Presentation API] 1-UA: notify receiver page when receiver connection becomes available (blink sid… (Closed)
Patch Set: resolve code review comments from mlamouri Created 4 years, 3 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
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <queue> 13 #include <queue>
14 14
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/id_map.h" 16 #include "base/id_map.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "content/public/renderer/render_frame_observer.h" 19 #include "content/public/renderer/render_frame_observer.h"
20 #include "mojo/public/cpp/bindings/binding.h" 20 #include "mojo/public/cpp/bindings/binding.h"
21 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nClient.h" 21 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nClient.h"
22 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h" 22 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h"
23 23
24 namespace blink { 24 namespace blink {
25 class WebPresentationAvailabilityObserver; 25 class WebPresentationAvailabilityObserver;
26 class WebPresentationReceiver;
26 class WebString; 27 class WebString;
27 template <typename T> 28 template <typename T>
28 class WebVector; 29 class WebVector;
29 } // namespace blink 30 } // namespace blink
30 31
31 namespace content { 32 namespace content {
32 33
33 // PresentationDispatcher is a delegate for Presentation API messages used by 34 // PresentationDispatcher is a delegate for Presentation API messages used by
34 // Blink. It forwards the calls to the Mojo PresentationService. 35 // Blink. It forwards the calls to the Mojo PresentationService.
35 class CONTENT_EXPORT PresentationDispatcher 36 class CONTENT_EXPORT PresentationDispatcher
(...skipping 20 matching lines...) Expand all
56 const blink::WebString& message); 57 const blink::WebString& message);
57 static SendMessageRequest* CreateSendBinaryMessageRequest( 58 static SendMessageRequest* CreateSendBinaryMessageRequest(
58 const blink::WebString& presentationUrl, 59 const blink::WebString& presentationUrl,
59 const blink::WebString& presentationId, 60 const blink::WebString& presentationId,
60 blink::mojom::PresentationMessageType type, 61 blink::mojom::PresentationMessageType type,
61 const uint8_t* data, 62 const uint8_t* data,
62 size_t length); 63 size_t length);
63 64
64 // WebPresentationClient implementation. 65 // WebPresentationClient implementation.
65 void setController(blink::WebPresentationController* controller) override; 66 void setController(blink::WebPresentationController* controller) override;
67 void setReceiver(blink::WebPresentationReceiver*) override;
68
66 void startSession( 69 void startSession(
67 const blink::WebVector<blink::WebString>& presentationUrls, 70 const blink::WebVector<blink::WebString>& presentationUrls,
68 blink::WebPresentationConnectionClientCallbacks* callback) override; 71 blink::WebPresentationConnectionClientCallbacks* callback) override;
69 void joinSession( 72 void joinSession(
70 const blink::WebVector<blink::WebString>& presentationUrls, 73 const blink::WebVector<blink::WebString>& presentationUrls,
71 const blink::WebString& presentationId, 74 const blink::WebString& presentationId,
72 blink::WebPresentationConnectionClientCallbacks* callback) override; 75 blink::WebPresentationConnectionClientCallbacks* callback) override;
73 void sendString(const blink::WebString& presentationUrl, 76 void sendString(const blink::WebString& presentationUrl,
74 const blink::WebString& presentationId, 77 const blink::WebString& presentationId,
75 const blink::WebString& message) override; 78 const blink::WebString& message) override;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 void OnSessionMessagesReceived( 115 void OnSessionMessagesReceived(
113 blink::mojom::PresentationSessionInfoPtr session_info, 116 blink::mojom::PresentationSessionInfoPtr session_info,
114 std::vector<blink::mojom::SessionMessagePtr> messages) override; 117 std::vector<blink::mojom::SessionMessagePtr> messages) override;
115 void OnDefaultSessionStarted( 118 void OnDefaultSessionStarted(
116 blink::mojom::PresentationSessionInfoPtr session_info) override; 119 blink::mojom::PresentationSessionInfoPtr session_info) override;
117 120
118 void OnSessionCreated( 121 void OnSessionCreated(
119 blink::WebPresentationConnectionClientCallbacks* callback, 122 blink::WebPresentationConnectionClientCallbacks* callback,
120 blink::mojom::PresentationSessionInfoPtr session_info, 123 blink::mojom::PresentationSessionInfoPtr session_info,
121 blink::mojom::PresentationErrorPtr error); 124 blink::mojom::PresentationErrorPtr error);
125 void OnReceiverConnectionAvailable(
126 blink::mojom::PresentationSessionInfoPtr) override;
122 127
123 // Call to PresentationService to send the message in |request|. 128 // Call to PresentationService to send the message in |request|.
124 // |session_info| and |message| of |reuqest| will be consumed. 129 // |session_info| and |message| of |reuqest| will be consumed.
125 // |HandleSendMessageRequests| will be invoked after the send is attempted. 130 // |HandleSendMessageRequests| will be invoked after the send is attempted.
126 void DoSendMessage(SendMessageRequest* request); 131 void DoSendMessage(SendMessageRequest* request);
127 void HandleSendMessageRequests(bool success); 132 void HandleSendMessageRequests(bool success);
128 133
129 void ConnectToPresentationServiceIfNeeded(); 134 void ConnectToPresentationServiceIfNeeded();
130 135
131 void UpdateListeningState(); 136 void UpdateListeningState();
132 137
133 // Used as a weak reference. Can be null since lifetime is bound to the frame. 138 // Used as a weak reference. Can be null since lifetime is bound to the frame.
134 blink::WebPresentationController* controller_; 139 blink::WebPresentationController* controller_;
140 blink::WebPresentationReceiver* m_receiver;
mlamouri (slow - plz ping) 2016/09/15 10:49:39 style: `receiver_`
zhaobin 2016/09/15 18:56:03 Done.
135 blink::mojom::PresentationServicePtr presentation_service_; 141 blink::mojom::PresentationServicePtr presentation_service_;
136 mojo::Binding<blink::mojom::PresentationServiceClient> binding_; 142 mojo::Binding<blink::mojom::PresentationServiceClient> binding_;
137 143
138 // Message requests are queued here and only one message at a time is sent 144 // Message requests are queued here and only one message at a time is sent
139 // over mojo channel. 145 // over mojo channel.
140 using MessageRequestQueue = std::queue<std::unique_ptr<SendMessageRequest>>; 146 using MessageRequestQueue = std::queue<std::unique_ptr<SendMessageRequest>>;
141 MessageRequestQueue message_request_queue_; 147 MessageRequestQueue message_request_queue_;
142 148
143 enum class ListeningState { 149 enum class ListeningState {
144 INACTIVE, 150 INACTIVE,
(...skipping 24 matching lines...) Expand all
169 // Updates the listening state of availability for |status| and notifies the 175 // Updates the listening state of availability for |status| and notifies the
170 // client. 176 // client.
171 void UpdateListeningState(AvailabilityStatus* status); 177 void UpdateListeningState(AvailabilityStatus* status);
172 178
173 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); 179 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher);
174 }; 180 };
175 181
176 } // namespace content 182 } // namespace content
177 183
178 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 184 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698