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

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

Issue 1957143002: [OnionSoup] Move persentation_service.mojom from //content to //third_party/WebKit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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/common/presentation/presentation_service.mojom.h"
20 #include "content/public/renderer/render_frame_observer.h" 19 #include "content/public/renderer/render_frame_observer.h"
21 #include "mojo/public/cpp/bindings/binding.h" 20 #include "mojo/public/cpp/bindings/binding.h"
22 #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"
23 23
24 namespace blink { 24 namespace blink {
25 class WebPresentationAvailabilityObserver; 25 class WebPresentationAvailabilityObserver;
26 class WebString; 26 class WebString;
27 } // namespace blink 27 } // namespace blink
28 28
29 namespace content { 29 namespace content {
30 30
31 // PresentationDispatcher is a delegate for Presentation API messages used by 31 // PresentationDispatcher is a delegate for Presentation API messages used by
32 // Blink. It forwards the calls to the Mojo PresentationService. 32 // Blink. It forwards the calls to the Mojo PresentationService.
33 class CONTENT_EXPORT PresentationDispatcher 33 class CONTENT_EXPORT PresentationDispatcher
34 : public RenderFrameObserver, 34 : public RenderFrameObserver,
35 public NON_EXPORTED_BASE(blink::WebPresentationClient), 35 public NON_EXPORTED_BASE(blink::WebPresentationClient),
36 public NON_EXPORTED_BASE(mojom::PresentationServiceClient) { 36 public NON_EXPORTED_BASE(blink::mojom::PresentationServiceClient) {
37 public: 37 public:
38 explicit PresentationDispatcher(RenderFrame* render_frame); 38 explicit PresentationDispatcher(RenderFrame* render_frame);
39 ~PresentationDispatcher() override; 39 ~PresentationDispatcher() override;
40 40
41 private: 41 private:
42 struct SendMessageRequest { 42 struct SendMessageRequest {
43 SendMessageRequest(mojom::PresentationSessionInfoPtr session_info, 43 SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info,
44 mojom::SessionMessagePtr message); 44 blink::mojom::SessionMessagePtr message);
45 ~SendMessageRequest(); 45 ~SendMessageRequest();
46 46
47 mojom::PresentationSessionInfoPtr session_info; 47 blink::mojom::PresentationSessionInfoPtr session_info;
48 mojom::SessionMessagePtr message; 48 blink::mojom::SessionMessagePtr message;
49 }; 49 };
50 50
51 static SendMessageRequest* CreateSendTextMessageRequest( 51 static SendMessageRequest* CreateSendTextMessageRequest(
52 const blink::WebString& presentationUrl, 52 const blink::WebString& presentationUrl,
53 const blink::WebString& presentationId, 53 const blink::WebString& presentationId,
54 const blink::WebString& message); 54 const blink::WebString& message);
55 static SendMessageRequest* CreateSendBinaryMessageRequest( 55 static SendMessageRequest* CreateSendBinaryMessageRequest(
56 const blink::WebString& presentationUrl, 56 const blink::WebString& presentationUrl,
57 const blink::WebString& presentationId, 57 const blink::WebString& presentationId,
58 mojom::PresentationMessageType type, 58 blink::mojom::PresentationMessageType type,
59 const uint8_t* data, 59 const uint8_t* data,
60 size_t length); 60 size_t length);
61 61
62 // WebPresentationClient implementation. 62 // WebPresentationClient implementation.
63 void setController(blink::WebPresentationController* controller) override; 63 void setController(blink::WebPresentationController* controller) override;
64 void startSession( 64 void startSession(
65 const blink::WebString& presentationUrl, 65 const blink::WebString& presentationUrl,
66 blink::WebPresentationConnectionClientCallbacks* callback) override; 66 blink::WebPresentationConnectionClientCallbacks* callback) override;
67 void joinSession( 67 void joinSession(
68 const blink::WebString& presentationUrl, 68 const blink::WebString& presentationUrl,
(...skipping 19 matching lines...) Expand all
88 blink::WebPresentationAvailabilityCallbacks* callbacks) override; 88 blink::WebPresentationAvailabilityCallbacks* callbacks) override;
89 void startListening(blink::WebPresentationAvailabilityObserver*) override; 89 void startListening(blink::WebPresentationAvailabilityObserver*) override;
90 void stopListening(blink::WebPresentationAvailabilityObserver*) override; 90 void stopListening(blink::WebPresentationAvailabilityObserver*) override;
91 void setDefaultPresentationUrl(const blink::WebString& url) override; 91 void setDefaultPresentationUrl(const blink::WebString& url) override;
92 92
93 // RenderFrameObserver implementation. 93 // RenderFrameObserver implementation.
94 void DidCommitProvisionalLoad( 94 void DidCommitProvisionalLoad(
95 bool is_new_navigation, 95 bool is_new_navigation,
96 bool is_same_page_navigation) override; 96 bool is_same_page_navigation) override;
97 97
98 // mojom::PresentationServiceClient 98 // blink::mojom::PresentationServiceClient
99 void OnScreenAvailabilityNotSupported(const mojo::String& url) override; 99 void OnScreenAvailabilityNotSupported(const mojo::String& url) override;
100 void OnScreenAvailabilityUpdated(const mojo::String& url, 100 void OnScreenAvailabilityUpdated(const mojo::String& url,
101 bool available) override; 101 bool available) override;
102 void OnConnectionStateChanged( 102 void OnConnectionStateChanged(
103 mojom::PresentationSessionInfoPtr connection, 103 blink::mojom::PresentationSessionInfoPtr connection,
104 mojom::PresentationConnectionState state) override; 104 blink::mojom::PresentationConnectionState state) override;
105 void OnConnectionClosed(mojom::PresentationSessionInfoPtr connection, 105 void OnConnectionClosed(
106 mojom::PresentationConnectionCloseReason reason, 106 blink::mojom::PresentationSessionInfoPtr connection,
107 const mojo::String& message) override; 107 blink::mojom::PresentationConnectionCloseReason reason,
108 const mojo::String& message) override;
108 void OnSessionMessagesReceived( 109 void OnSessionMessagesReceived(
109 mojom::PresentationSessionInfoPtr session_info, 110 blink::mojom::PresentationSessionInfoPtr session_info,
110 mojo::Array<mojom::SessionMessagePtr> messages) override; 111 mojo::Array<blink::mojom::SessionMessagePtr> messages) override;
111 void OnDefaultSessionStarted( 112 void OnDefaultSessionStarted(
112 mojom::PresentationSessionInfoPtr session_info) override; 113 blink::mojom::PresentationSessionInfoPtr session_info) override;
113 114
114 void OnSessionCreated( 115 void OnSessionCreated(
115 blink::WebPresentationConnectionClientCallbacks* callback, 116 blink::WebPresentationConnectionClientCallbacks* callback,
116 mojom::PresentationSessionInfoPtr session_info, 117 blink::mojom::PresentationSessionInfoPtr session_info,
117 mojom::PresentationErrorPtr error); 118 blink::mojom::PresentationErrorPtr error);
118 119
119 // Call to PresentationService to send the message in |request|. 120 // Call to PresentationService to send the message in |request|.
120 // |session_info| and |message| of |reuqest| will be consumed. 121 // |session_info| and |message| of |reuqest| will be consumed.
121 // |HandleSendMessageRequests| will be invoked after the send is attempted. 122 // |HandleSendMessageRequests| will be invoked after the send is attempted.
122 void DoSendMessage(SendMessageRequest* request); 123 void DoSendMessage(SendMessageRequest* request);
123 void HandleSendMessageRequests(bool success); 124 void HandleSendMessageRequests(bool success);
124 125
125 void ConnectToPresentationServiceIfNeeded(); 126 void ConnectToPresentationServiceIfNeeded();
126 127
127 void UpdateListeningState(); 128 void UpdateListeningState();
128 129
129 // Used as a weak reference. Can be null since lifetime is bound to the frame. 130 // Used as a weak reference. Can be null since lifetime is bound to the frame.
130 blink::WebPresentationController* controller_; 131 blink::WebPresentationController* controller_;
131 mojom::PresentationServicePtr presentation_service_; 132 blink::mojom::PresentationServicePtr presentation_service_;
132 mojo::Binding<mojom::PresentationServiceClient> binding_; 133 mojo::Binding<blink::mojom::PresentationServiceClient> binding_;
133 134
134 // Message requests are queued here and only one message at a time is sent 135 // Message requests are queued here and only one message at a time is sent
135 // over mojo channel. 136 // over mojo channel.
136 using MessageRequestQueue = std::queue<std::unique_ptr<SendMessageRequest>>; 137 using MessageRequestQueue = std::queue<std::unique_ptr<SendMessageRequest>>;
137 MessageRequestQueue message_request_queue_; 138 MessageRequestQueue message_request_queue_;
138 139
139 enum class ListeningState { 140 enum class ListeningState {
140 INACTIVE, 141 INACTIVE,
141 WAITING, 142 WAITING,
142 ACTIVE, 143 ACTIVE,
(...skipping 22 matching lines...) Expand all
165 // Updates the listening state of availability for |status| and notifies the 166 // Updates the listening state of availability for |status| and notifies the
166 // client. 167 // client.
167 void UpdateListeningState(AvailabilityStatus* status); 168 void UpdateListeningState(AvailabilityStatus* status);
168 169
169 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); 170 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher);
170 }; 171 };
171 172
172 } // namespace content 173 } // namespace content
173 174
174 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 175 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698