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

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

Issue 2958663002: [MediaRouter] PresentationServiceDelegateImpl cleanup. (Closed)
Patch Set: Addressed Bin's comments Created 3 years, 5 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 content::PresentationConnectionCallback success_cb, 197 content::PresentationConnectionCallback success_cb,
200 content::PresentationConnectionErrorCallback error_cb, 198 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 content::PresentationConnectionCallback success_cb, 204 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 std::string& presentation_id);
220
221 // Sets the default presentation request for the owning WebContents and
222 // notifies observers of changes.
223 void SetDefaultPresentationRequest(
224 const PresentationRequest& default_presentation_request);
225
226 // Clears the default presentation request for the owning WebContents and
227 // notifies observers of changes. Also resets
228 // |default_presentation_started_callback_|.
229 void ClearDefaultPresentationRequest();
230
231 bool IsMainFrame(const RenderFrameHostId& render_frame_host_id) const;
Kevin M 2017/07/10 19:01:36 Add a comment for all new methods?
imcheng 2017/07/10 19:18:50 Done.
232
233 MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id,
234 const std::string& presentation_id) const;
235
210 #if !defined(OS_ANDROID) 236 #if !defined(OS_ANDROID)
211 // Returns true if auto-join requests should be cancelled for |origin|. 237 // Returns true if auto-join requests should be cancelled for |origin|.
212 bool ShouldCancelAutoJoinForOrigin(const url::Origin& origin) const; 238 bool ShouldCancelAutoJoinForOrigin(const url::Origin& origin) const;
213 #endif 239 #endif
214 240
215 // References to the WebContents that owns this instance, and associated 241 // References to the WebContents that owns this instance, and associated
216 // browser profile's MediaRouter instance. 242 // browser profile's MediaRouter instance.
217 content::WebContents* const web_contents_; 243 content::WebContents* const web_contents_;
218 MediaRouter* router_; 244 MediaRouter* router_;
219 245
220 std::unique_ptr<PresentationFrameManager> frame_manager_; 246 // References to the observers listening for changes to this tab WebContent's
Kevin M 2017/07/10 19:01:37 The pluralized WebContents name makes a mess of th
imcheng 2017/07/10 19:18:50 Done.
247 // default presentation.
248 base::ObserverList<DefaultPresentationRequestObserver>
249 default_presentation_request_observers_;
250
251 // Default presentation request for the owning tab WebContents.
Kevin M 2017/07/10 19:01:36 tab's
imcheng 2017/07/10 19:18:50 Done. Got rid of tab, since it means the same thin
252 std::unique_ptr<PresentationRequest> default_presentation_request_;
253
254 // Callback to invoke when default presentation has started.
Kevin M 2017/07/10 19:01:36 the default presentation
imcheng 2017/07/10 19:18:50 Done.
255 content::DefaultPresentationConnectionCallback
256 default_presentation_started_callback_;
257
258 // Maps a frame identifier to a PresentationFrame object for frames
259 // that are using Presentation API.
260 std::unordered_map<RenderFrameHostId,
261 std::unique_ptr<PresentationFrame>,
262 RenderFrameHostIdHasher>
263 presentation_frames_;
264
221 PresentationServiceDelegateObservers observers_; 265 PresentationServiceDelegateObservers observers_;
222 266
223 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_; 267 base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_;
224 268
225 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl); 269 DISALLOW_COPY_AND_ASSIGN(PresentationServiceDelegateImpl);
226 }; 270 };
227 271
228 } // namespace media_router 272 } // namespace media_router
229 273
230 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_ 274 #endif // CHROME_BROWSER_MEDIA_ROUTER_PRESENTATION_SERVICE_DELEGATE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698