OLD | NEW |
---|---|
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_MEDIA_ROUTER_MOJO_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
13 #include "base/containers/scoped_ptr_hash_map.h" | 14 #include "base/containers/scoped_ptr_hash_map.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
18 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 void UnregisterIssuesObserver(IssuesObserver* observer) override; | 90 void UnregisterIssuesObserver(IssuesObserver* observer) override; |
90 | 91 |
91 const std::string& media_route_provider_extension_id() const { | 92 const std::string& media_route_provider_extension_id() const { |
92 return media_route_provider_extension_id_; | 93 return media_route_provider_extension_id_; |
93 } | 94 } |
94 | 95 |
95 void set_instance_id_for_test(const std::string& instance_id) { | 96 void set_instance_id_for_test(const std::string& instance_id) { |
96 instance_id_ = instance_id; | 97 instance_id_ = instance_id; |
97 } | 98 } |
98 | 99 |
100 const std::set<MediaSink::Id>& sink_ids_in_launch() const { | |
Kevin M
2015/08/08 00:35:56
ISTM that this doesn't belong at this layer - ther
haibinlu
2015/08/08 01:25:38
It cannot. It has to survive UI close and reopen.
| |
101 return sink_ids_in_launch_; | |
102 } | |
103 | |
99 private: | 104 private: |
100 friend class MediaRouterFactory; | 105 friend class MediaRouterFactory; |
101 friend class MediaRouterMojoTest; | 106 friend class MediaRouterMojoTest; |
102 | 107 |
103 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 108 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
104 DeferredBindingAndSuspension); | 109 DeferredBindingAndSuspension); |
105 | 110 |
106 // Standard constructor, used by | 111 // Standard constructor, used by |
107 // MediaRouterMojoImplFactory::GetApiForBrowserContext. | 112 // MediaRouterMojoImplFactory::GetApiForBrowserContext. |
108 explicit MediaRouterMojoImpl( | 113 explicit MediaRouterMojoImpl( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 // interfaces::MediaRouter implementation. | 170 // interfaces::MediaRouter implementation. |
166 void RegisterMediaRouteProvider( | 171 void RegisterMediaRouteProvider( |
167 interfaces::MediaRouteProviderPtr media_route_provider_ptr, | 172 interfaces::MediaRouteProviderPtr media_route_provider_ptr, |
168 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& | 173 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& |
169 callback) override; | 174 callback) override; |
170 void OnIssue(interfaces::IssuePtr issue) override; | 175 void OnIssue(interfaces::IssuePtr issue) override; |
171 void OnSinksReceived(const mojo::String& media_source, | 176 void OnSinksReceived(const mojo::String& media_source, |
172 mojo::Array<interfaces::MediaSinkPtr> sinks) override; | 177 mojo::Array<interfaces::MediaSinkPtr> sinks) override; |
173 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes) override; | 178 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes) override; |
174 | 179 |
180 void RouteResponseReceived( | |
181 const std::vector<MediaRouteResponseCallback>& callbacks, | |
182 const MediaSink::Id& sink_id, | |
183 interfaces::MediaRoutePtr media_route, | |
184 const mojo::String& error_text); | |
185 | |
175 // Pending requests queued to be executed once component extension | 186 // Pending requests queued to be executed once component extension |
176 // becomes ready. | 187 // becomes ready. |
177 std::vector<base::Closure> pending_requests_; | 188 std::vector<base::Closure> pending_requests_; |
178 | 189 |
179 base::ScopedPtrHashMap<MediaSource::Id, | 190 base::ScopedPtrHashMap<MediaSource::Id, |
180 scoped_ptr<base::ObserverList<MediaSinksObserver>>> | 191 scoped_ptr<base::ObserverList<MediaSinksObserver>>> |
181 sinks_observers_; | 192 sinks_observers_; |
182 | 193 |
183 base::ObserverList<MediaRoutesObserver> routes_observers_; | 194 base::ObserverList<MediaRoutesObserver> routes_observers_; |
184 | 195 |
185 IssueManager issue_manager_; | 196 IssueManager issue_manager_; |
186 | 197 |
187 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter. | 198 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter. |
188 scoped_ptr<mojo::Binding<interfaces::MediaRouter>> binding_; | 199 scoped_ptr<mojo::Binding<interfaces::MediaRouter>> binding_; |
189 | 200 |
190 // Mojo proxy object for the Media Route Provider Manager. | 201 // Mojo proxy object for the Media Route Provider Manager. |
191 // Set to null initially, and later set to the Provider Manager proxy object | 202 // Set to null initially, and later set to the Provider Manager proxy object |
192 // passed in via |RegisterMediaRouteProvider()|. | 203 // passed in via |RegisterMediaRouteProvider()|. |
193 // This is set to null again when the component extension is suspended | 204 // This is set to null again when the component extension is suspended |
194 // if or a Mojo channel error occured. | 205 // if or a Mojo channel error occured. |
195 interfaces::MediaRouteProviderPtr media_route_provider_; | 206 interfaces::MediaRouteProviderPtr media_route_provider_; |
196 | 207 |
197 // Id of the component extension. Used for managing its suspend/wake state | 208 // Id of the component extension. Used for managing its suspend/wake state |
198 // via event_page_tracker_. | 209 // via event_page_tracker_. |
199 std::string media_route_provider_extension_id_; | 210 std::string media_route_provider_extension_id_; |
200 | 211 |
212 // The Ids of the sinks to which media router are creating routes. | |
213 std::set<MediaSink::Id> sink_ids_in_launch_; | |
214 | |
201 // Allows the extension to be monitored for suspend, and woken. | 215 // Allows the extension to be monitored for suspend, and woken. |
202 // This is a reference to a BrowserContext keyed service that outlives this | 216 // This is a reference to a BrowserContext keyed service that outlives this |
203 // instance. | 217 // instance. |
204 extensions::EventPageTracker* event_page_tracker_; | 218 extensions::EventPageTracker* event_page_tracker_; |
205 | 219 |
206 // GUID unique to each browser run. Component extension uses this to detect | 220 // GUID unique to each browser run. Component extension uses this to detect |
207 // when its persisted state was written by an older browser instance, and is | 221 // when its persisted state was written by an older browser instance, and is |
208 // therefore stale. | 222 // therefore stale. |
209 std::string instance_id_; | 223 std::string instance_id_; |
210 | 224 |
211 base::ThreadChecker thread_checker_; | 225 base::ThreadChecker thread_checker_; |
212 | 226 |
213 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 227 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
214 }; | 228 }; |
215 | 229 |
216 } // namespace media_router | 230 } // namespace media_router |
217 | 231 |
218 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 232 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
OLD | NEW |