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

Side by Side Diff: content/browser/presentation/presentation_service_impl.h

Issue 2938023002: [PresentationService] Improve PresentationServiceImplTest. (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 CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_
6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ 6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 const base::Optional<PresentationError>&)>; 58 const base::Optional<PresentationError>&)>;
59 59
60 // Static factory method to create an instance of PresentationServiceImpl. 60 // Static factory method to create an instance of PresentationServiceImpl.
61 // |render_frame_host|: The RFH the instance is associated with. 61 // |render_frame_host|: The RFH the instance is associated with.
62 // |request|: The instance will be bound to this request. Used for Mojo setup. 62 // |request|: The instance will be bound to this request. Used for Mojo setup.
63 static void CreateMojoService( 63 static void CreateMojoService(
64 RenderFrameHost* render_frame_host, 64 RenderFrameHost* render_frame_host,
65 const service_manager::BindSourceInfo& source_info, 65 const service_manager::BindSourceInfo& source_info,
66 mojo::InterfaceRequest<blink::mojom::PresentationService> request); 66 mojo::InterfaceRequest<blink::mojom::PresentationService> request);
67 67
68 // PresentationService implementation.
69 void SetDefaultPresentationUrls(
70 const std::vector<GURL>& presentation_urls) override;
71 void SetClient(blink::mojom::PresentationServiceClientPtr client) override;
72 void ListenForScreenAvailability(const GURL& url) override;
73 void StopListeningForScreenAvailability(const GURL& url) override;
74 void StartPresentation(const std::vector<GURL>& presentation_urls,
75 const NewPresentationCallback& callback) override;
76 void ReconnectPresentation(const std::vector<GURL>& presentation_urls,
77 const base::Optional<std::string>& presentation_id,
78 const NewPresentationCallback& callback) override;
79 void CloseConnection(const GURL& presentation_url,
80 const std::string& presentation_id) override;
81 void Terminate(const GURL& presentation_url,
82 const std::string& presentation_id) override;
83 void ListenForConnectionMessages(
84 const PresentationInfo& presentation_info) override;
85 void SetPresentationConnection(
86 const PresentationInfo& presentation_info,
87 blink::mojom::PresentationConnectionPtr controller_connection_ptr,
88 blink::mojom::PresentationConnectionRequest receiver_connection_request)
89 override;
90
68 private: 91 private:
69 friend class PresentationServiceImplTest; 92 friend class PresentationServiceImplTest;
70 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, Reset); 93 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, Reset);
71 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, DidNavigateThisFrame);
72 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
73 DidNavigateOtherFrame);
74 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, ThisRenderFrameDeleted); 94 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, ThisRenderFrameDeleted);
75 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 95 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
76 OtherRenderFrameDeleted); 96 OtherRenderFrameDeleted);
77 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, DelegateFails); 97 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, DelegateFails);
78 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 98 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
79 SetDefaultPresentationUrls); 99 ListenForConnectionStateChange);
80 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 100 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
81 SetSameDefaultPresentationUrls); 101 ListenForConnectionClose);
82 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
83 ClearDefaultPresentationUrls);
84 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
85 ListenForDefaultPresentationStart);
86 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
87 ListenForDefaultPresentationStartAfterSet);
88 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
89 DefaultPresentationStartReset);
90 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
91 ReceiveConnectionMessagesAfterReset);
92 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 102 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
93 MaxPendingStartPresentationRequests); 103 MaxPendingStartPresentationRequests);
94 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 104 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
95 MaxPendingReconnectPresentationRequests); 105 MaxPendingReconnectPresentationRequests);
96 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, 106 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
97 ListenForConnectionStateChange);
98 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
99 ListenForConnectionClose);
100 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
101 SetPresentationConnection);
102 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
103 ReceiverPresentationServiceDelegate); 107 ReceiverPresentationServiceDelegate);
104 108
105 // Maximum number of pending ReconnectPresentation requests at any given time. 109 // Maximum number of pending ReconnectPresentation requests at any given time.
106 static const int kMaxQueuedRequests = 10; 110 static const int kMaxQueuedRequests = 10;
107 111
108 using ConnectionMessagesCallback = 112 using ConnectionMessagesCallback =
109 base::Callback<void(std::vector<PresentationConnectionMessage>)>; 113 base::Callback<void(std::vector<PresentationConnectionMessage>)>;
110 114
111 // Listener implementation owned by PresentationServiceImpl. An instance of 115 // Listener implementation owned by PresentationServiceImpl. An instance of
112 // this is created when PresentationRequest.getAvailability() is resolved. 116 // this is created when PresentationRequest.getAvailability() is resolved.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // owned by this class. 157 // owned by this class.
154 // |receiver_delegate|: Where Presentation API requests are delegated to in 158 // |receiver_delegate|: Where Presentation API requests are delegated to in
155 // receiver frame. Set to nullptr if current frame is controller frame. Not 159 // receiver frame. Set to nullptr if current frame is controller frame. Not
156 // owned by this class. 160 // owned by this class.
157 PresentationServiceImpl( 161 PresentationServiceImpl(
158 RenderFrameHost* render_frame_host, 162 RenderFrameHost* render_frame_host,
159 WebContents* web_contents, 163 WebContents* web_contents,
160 ControllerPresentationServiceDelegate* controller_delegate, 164 ControllerPresentationServiceDelegate* controller_delegate,
161 ReceiverPresentationServiceDelegate* receiver_delegate); 165 ReceiverPresentationServiceDelegate* receiver_delegate);
162 166
163 // PresentationService implementation.
164 void SetDefaultPresentationUrls(
165 const std::vector<GURL>& presentation_urls) override;
166 void SetClient(blink::mojom::PresentationServiceClientPtr client) override;
167 void ListenForScreenAvailability(const GURL& url) override;
168 void StopListeningForScreenAvailability(const GURL& url) override;
169 void StartPresentation(const std::vector<GURL>& presentation_urls,
170 const NewPresentationCallback& callback) override;
171 void ReconnectPresentation(const std::vector<GURL>& presentation_urls,
172 const base::Optional<std::string>& presentation_id,
173 const NewPresentationCallback& callback) override;
174 void CloseConnection(const GURL& presentation_url,
175 const std::string& presentation_id) override;
176 void Terminate(const GURL& presentation_url,
177 const std::string& presentation_id) override;
178 void ListenForConnectionMessages(
179 const PresentationInfo& presentation_info) override;
180 void SetPresentationConnection(
181 const PresentationInfo& presentation_info,
182 blink::mojom::PresentationConnectionPtr controller_connection_ptr,
183 blink::mojom::PresentationConnectionRequest receiver_connection_request)
184 override;
185
186 // Creates a binding between this object and |request|. 167 // Creates a binding between this object and |request|.
187 void Bind(blink::mojom::PresentationServiceRequest request); 168 void Bind(blink::mojom::PresentationServiceRequest request);
188 169
189 // WebContentsObserver override. 170 // WebContentsObserver override.
190 void DidFinishNavigation(NavigationHandle* navigation_handle) override; 171 void DidFinishNavigation(NavigationHandle* navigation_handle) override;
191 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; 172 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
192 void WebContentsDestroyed() override; 173 void WebContentsDestroyed() override;
193 174
194 // PresentationServiceDelegate::Observer 175 // PresentationServiceDelegate::Observer
195 void OnDelegateDestroyed() override; 176 void OnDelegateDestroyed() override;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 283
303 // NOTE: Weak pointers must be invalidated before all other member variables. 284 // NOTE: Weak pointers must be invalidated before all other member variables.
304 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; 285 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_;
305 286
306 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); 287 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl);
307 }; 288 };
308 289
309 } // namespace content 290 } // namespace content
310 291
311 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ 292 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698