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

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

Issue 1259073004: [Presentation API] Change ListenForSessionMessages API to client-style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fix Created 5 years, 4 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 "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/id_map.h" 9 #include "base/id_map.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 13 matching lines...) Expand all
24 // Blink. It forwards the calls to the Mojo PresentationService. 24 // Blink. It forwards the calls to the Mojo PresentationService.
25 class CONTENT_EXPORT PresentationDispatcher 25 class CONTENT_EXPORT PresentationDispatcher
26 : public RenderFrameObserver, 26 : public RenderFrameObserver,
27 public NON_EXPORTED_BASE(blink::WebPresentationClient), 27 public NON_EXPORTED_BASE(blink::WebPresentationClient),
28 public NON_EXPORTED_BASE(presentation::PresentationServiceClient) { 28 public NON_EXPORTED_BASE(presentation::PresentationServiceClient) {
29 public: 29 public:
30 explicit PresentationDispatcher(RenderFrame* render_frame); 30 explicit PresentationDispatcher(RenderFrame* render_frame);
31 ~PresentationDispatcher() override; 31 ~PresentationDispatcher() override;
32 32
33 private: 33 private:
34 struct SendMessageRequest {
35 SendMessageRequest(presentation::PresentationSessionInfoPtr session_info,
36 presentation::SessionMessagePtr message);
37 ~SendMessageRequest();
38
39 presentation::PresentationSessionInfoPtr session_info;
40 presentation::SessionMessagePtr message;
41 };
42
43 static SendMessageRequest* GetSendStringMessageRequest(
haibinlu 2015/07/30 23:16:30 TextMessage?
imcheng 2015/08/03 18:56:33 Done.
44 const blink::WebString& presentationUrl,
45 const blink::WebString& presentationId,
46 const blink::WebString& message);
47 static SendMessageRequest* GetSendDataMessageRequest(
haibinlu 2015/07/30 23:16:30 BinaryMessage
imcheng 2015/08/03 18:56:33 Done.
48 const blink::WebString& presentationUrl,
49 const blink::WebString& presentationId,
50 presentation::PresentationMessageType type,
51 const uint8* data,
52 size_t length);
53
34 // WebPresentationClient implementation. 54 // WebPresentationClient implementation.
35 virtual void setController( 55 virtual void setController(
36 blink::WebPresentationController* controller); 56 blink::WebPresentationController* controller);
37 virtual void updateAvailableChangeWatched(bool watched); 57 virtual void updateAvailableChangeWatched(bool watched);
38 virtual void startSession( 58 virtual void startSession(
39 const blink::WebString& presentationUrl, 59 const blink::WebString& presentationUrl,
40 blink::WebPresentationSessionClientCallbacks* callback); 60 blink::WebPresentationSessionClientCallbacks* callback);
41 virtual void joinSession( 61 virtual void joinSession(
42 const blink::WebString& presentationUrl, 62 const blink::WebString& presentationUrl,
43 const blink::WebString& presentationId, 63 const blink::WebString& presentationId,
(...skipping 26 matching lines...) Expand all
70 void DidCommitProvisionalLoad( 90 void DidCommitProvisionalLoad(
71 bool is_new_navigation, 91 bool is_new_navigation,
72 bool is_same_page_navigation) override; 92 bool is_same_page_navigation) override;
73 93
74 // presentation::PresentationServiceClient 94 // presentation::PresentationServiceClient
75 void OnScreenAvailabilityUpdated(bool available) override; 95 void OnScreenAvailabilityUpdated(bool available) override;
76 void OnSessionStateChanged( 96 void OnSessionStateChanged(
77 presentation::PresentationSessionInfoPtr session_info, 97 presentation::PresentationSessionInfoPtr session_info,
78 presentation::PresentationSessionState new_state) override; 98 presentation::PresentationSessionState new_state) override;
79 void OnScreenAvailabilityNotSupported() override; 99 void OnScreenAvailabilityNotSupported() override;
100 void OnSessionMessagesReceived(
101 presentation::PresentationSessionInfoPtr session_info,
102 mojo::Array<presentation::SessionMessagePtr> messages) override;
80 103
81 void OnSessionCreated( 104 void OnSessionCreated(
82 blink::WebPresentationSessionClientCallbacks* callback, 105 blink::WebPresentationSessionClientCallbacks* callback,
83 presentation::PresentationSessionInfoPtr session_info, 106 presentation::PresentationSessionInfoPtr session_info,
84 presentation::PresentationErrorPtr error); 107 presentation::PresentationErrorPtr error);
85 void OnDefaultSessionStarted( 108 void OnDefaultSessionStarted(
86 presentation::PresentationSessionInfoPtr session_info); 109 presentation::PresentationSessionInfoPtr session_info);
87 void OnSessionMessagesReceived( 110 void DoSendMessage(const SendMessageRequest& request);
88 mojo::Array<presentation::SessionMessagePtr> messages);
89 void DoSendMessage(const presentation::SessionMessage& session_message);
90 void HandleSendMessageRequests(bool success); 111 void HandleSendMessageRequests(bool success);
91 112
92 void ConnectToPresentationServiceIfNeeded(); 113 void ConnectToPresentationServiceIfNeeded();
93 114
94 void UpdateListeningState(); 115 void UpdateListeningState();
95 116
96 void StartListenForMessages();
97
98 // Used as a weak reference. Can be null since lifetime is bound to the frame. 117 // Used as a weak reference. Can be null since lifetime is bound to the frame.
99 blink::WebPresentationController* controller_; 118 blink::WebPresentationController* controller_;
100 presentation::PresentationServicePtr presentation_service_; 119 presentation::PresentationServicePtr presentation_service_;
101 mojo::Binding<presentation::PresentationServiceClient> binding_; 120 mojo::Binding<presentation::PresentationServiceClient> binding_;
102 121
103 // Message requests are queued here and only one message at a time is sent 122 // Message requests are queued here and only one message at a time is sent
104 // over mojo channel. 123 // over mojo channel.
105 using MessageRequestQueue = 124 using MessageRequestQueue = std::queue<linked_ptr<SendMessageRequest>>;
106 std::queue<linked_ptr<presentation::SessionMessage>>;
107 MessageRequestQueue message_request_queue_; 125 MessageRequestQueue message_request_queue_;
108 126
109 enum class ListeningState { 127 enum class ListeningState {
110 Inactive, 128 Inactive,
111 Waiting, 129 Waiting,
112 Active, 130 Active,
113 }; 131 };
114 132
115 ListeningState listening_state_; 133 ListeningState listening_state_;
116 bool last_known_availability_; 134 bool last_known_availability_;
117 135
118 using AvailabilityCallbacksMap = 136 using AvailabilityCallbacksMap =
119 IDMap<blink::WebPresentationAvailabilityCallbacks, IDMapOwnPointer>; 137 IDMap<blink::WebPresentationAvailabilityCallbacks, IDMapOwnPointer>;
120 AvailabilityCallbacksMap availability_callbacks_; 138 AvailabilityCallbacksMap availability_callbacks_;
121 139
122 using AvailabilityObserversSet = 140 using AvailabilityObserversSet =
123 std::set<blink::WebPresentationAvailabilityObserver*>; 141 std::set<blink::WebPresentationAvailabilityObserver*>;
124 AvailabilityObserversSet availability_observers_; 142 AvailabilityObserversSet availability_observers_;
125 143
126 bool listening_for_messages_;
127
128 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); 144 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher);
129 }; 145 };
130 146
131 } // namespace content 147 } // namespace content
132 148
133 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ 149 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698