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

Side by Side Diff: chrome/browser/media/router/presentation_service_delegate_impl.h

Issue 2958663002: [MediaRouter] PresentationServiceDelegateImpl cleanup. (Closed)
Patch Set: Created 3 years, 6 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 CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 20 matching lines...) Expand all
31 struct PresentationInfo; 31 struct PresentationInfo;
32 } // namespace content 32 } // namespace content
33 33
34 namespace url { 34 namespace url {
35 class Origin; 35 class Origin;
36 } // namespace url 36 } // namespace url
37 37
38 namespace media_router { 38 namespace media_router {
39 39
40 class MediaRoute; 40 class MediaRoute;
41 class PresentationFrameManager; 41 class PresentationFrame;
42 class RouteRequestResult; 42 class RouteRequestResult;
43 43
44 // Implementation of PresentationServiceDelegate that interfaces an instance of 44 // Implementation of PresentationServiceDelegate that interfaces an instance of
45 // WebContents with the Chrome Media Router. It uses the Media Router to handle 45 // WebContents with the Chrome Media Router. It uses the Media Router to handle
46 // presentation API calls forwarded from PresentationServiceImpl. In addition, 46 // presentation API calls forwarded from PresentationServiceImpl. In addition,
47 // it also provides default presentation URL that is required for creating 47 // it also provides default presentation URL that is required for creating
48 // browser-initiated presentations. It is scoped to the lifetime of a 48 // browser-initiated presentations. It is scoped to the lifetime of a
49 // WebContents, and is managed by the associated WebContents. 49 // WebContents, and is managed by the associated WebContents.
50 class PresentationServiceDelegateImpl 50 class PresentationServiceDelegateImpl
51 : public content::WebContentsUserData<PresentationServiceDelegateImpl>, 51 : public content::WebContentsUserData<PresentationServiceDelegateImpl>,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 DefaultPresentationUrlCallback); 179 DefaultPresentationUrlCallback);
180 FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest, 180 FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
181 TestCloseConnectionForOffscreenPresentation); 181 TestCloseConnectionForOffscreenPresentation);
182 FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest, 182 FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
183 ConnectToOffscreenPresentation); 183 ConnectToOffscreenPresentation);
184 FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest, 184 FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
185 ConnectToPresentation); 185 ConnectToPresentation);
186 186
187 explicit PresentationServiceDelegateImpl(content::WebContents* web_contents); 187 explicit PresentationServiceDelegateImpl(content::WebContents* web_contents);
188 188
189 // Returns |listener|'s presentation URL as a MediaSource. If |listener| does 189 PresentationFrame* GetOrAddPresentationFrame(
190 // not have a persentation URL, returns the tab mirroring MediaSource. 190 const RenderFrameHostId& render_frame_host_id);
191 MediaSource GetMediaSourceFromListener(
192 content::PresentationScreenAvailabilityListener* listener);
193 191
194 void OnJoinRouteResponse( 192 void OnJoinRouteResponse(
195 int render_process_id, 193 int render_process_id,
196 int render_frame_id, 194 int render_frame_id,
197 const GURL& presentation_url, 195 const GURL& presentation_url,
198 const std::string& presentation_id, 196 const std::string& presentation_id,
199 const content::PresentationConnectionCallback& success_cb, 197 const content::PresentationConnectionCallback& success_cb,
200 const content::PresentationConnectionErrorCallback& error_cb, 198 const content::PresentationConnectionErrorCallback& error_cb,
201 const RouteRequestResult& result); 199 const RouteRequestResult& result);
202 200
203 void OnStartPresentationSucceeded( 201 void OnStartPresentationSucceeded(
204 int render_process_id, 202 int render_process_id,
205 int render_frame_id, 203 int render_frame_id,
206 const content::PresentationConnectionCallback& success_cb, 204 const content::PresentationConnectionCallback& success_cb,
207 const content::PresentationInfo& new_presentation_info, 205 const content::PresentationInfo& new_presentation_info,
208 const MediaRoute& route); 206 const MediaRoute& route);
209 207
208 // Notifies the PresentationFrame of |render_frame_host_id| that a
209 // presentation and its corresponding MediaRoute has been created.
210 // The PresentationFrame will be created if it does not already exist.
211 // This must be called before |ConnectToPresentation()|.
212 void AddPresentation(const RenderFrameHostId& render_frame_host_id,
213 const content::PresentationInfo& presentation_info,
214 const MediaRoute& route);
215
216 // Notifies the PresentationFrame of |render_frame_host_id| that a
217 // presentation and its corresponding MediaRoute has been removed.
218 void RemovePresentation(const RenderFrameHostId& render_frame_host_id,
219 const MediaRoute::Id& route_id,
220 const std::string& presentation_id);
221
222 // Sets the default presentation request for the owning WebContents and
223 // notifies observers of changes.
224 void SetDefaultPresentationRequest(
225 const PresentationRequest& default_presentation_request);
226
227 // Clears the default presentation request for the owning WebContents and
228 // notifies observers of changes. Also resets
229 // |default_presentation_started_callback_|.
230 void ClearDefaultPresentationRequest();
231
232 bool IsMainFrame(const RenderFrameHostId& render_frame_host_id) const;
233
234 MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id,
235 const std::string& presentation_id) const;
236
210 #if !defined(OS_ANDROID) 237 #if !defined(OS_ANDROID)
211 // Returns true if auto-join requests should be cancelled for |origin|. 238 // Returns true if auto-join requests should be cancelled for |origin|.
212 bool ShouldCancelAutoJoinForOrigin(const url::Origin& origin) const; 239 bool ShouldCancelAutoJoinForOrigin(const url::Origin& origin) const;
213 #endif 240 #endif
214 241
215 // References to the WebContents that owns this instance, and associated 242 // References to the WebContents that owns this instance, and associated
216 // browser profile's MediaRouter instance. 243 // browser profile's MediaRouter instance.
217 content::WebContents* const web_contents_; 244 content::WebContents* const web_contents_;
218 MediaRouter* router_; 245 MediaRouter* router_;
219 246
220 std::unique_ptr<PresentationFrameManager> frame_manager_; 247 // References to the observers listening for changes to this tab WebContent's
248 // default presentation.
249 base::ObserverList<DefaultPresentationRequestObserver>
250 default_presentation_request_observers_;
251
252 // Default presentation request for the owning tab WebContents.
253 std::unique_ptr<PresentationRequest> default_presentation_request_;
254
255 // Callback to invoke when default presentation has started.
256 content::PresentationConnectionCallback
257 default_presentation_started_callback_;
258
259 // Maps a frame identifier to a PresentationFrame object for frames
260 // that are using Presentation API.
261 std::unordered_map<RenderFrameHostId,
262 std::unique_ptr<PresentationFrame>,
263 RenderFrameHostIdHasher>
264 presentation_frames_;
265
221 PresentationServiceDelegateObservers observers_; 266 PresentationServiceDelegateObservers observers_;
222 267
223 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; 268 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_;
224 269
225 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); 270 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl);
226 }; 271 };
227 272
228 } // namespace media_router 273 } // namespace media_router
229 274
230 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ 275 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698