OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_ | |
7 | |
8 #include <map> | |
9 #include <queue> | |
10 #include <string> | |
11 #include <vector> | |
12 | |
13 #include "base/callback.h" | |
14 #include "base/containers/hash_tables.h" | |
15 #include "base/gtest_prod_util.h" | |
16 #include "base/macros.h" | |
17 #include "base/memory/scoped_vector.h" | |
18 #include "base/threading/thread_checker.h" | |
19 #include "chrome/browser/media/router/media_router.h" | |
20 #include "chrome/browser/media/router/media_sinks_observer.h" | |
21 #include "components/keyed_service/core/keyed_service.h" | |
22 | |
23 namespace base { | |
24 template <typename T> | |
25 struct DefaultLazyInstanceTraits; | |
26 } // namespace base | |
27 | |
28 namespace media_router { | |
29 | |
30 class MediaRoute; | |
31 class MediaRouterApiImpl; | |
32 class MediaRoutesObserver; | |
33 struct RoutesQueryResult; | |
34 | |
35 // Delegates calls to another implementation of MediaRouter, which in turn | |
36 // handles communication with the Media Route Provider Manager (MRPM). | |
37 // Instances of this class are created by MediaRouterImplFactory. | |
38 // MediaRouterImpl is a profile-keyed service. | |
39 // MediaRouterImpl runs on the browser UI thread. All observers/callbacks | |
40 // registered to this class must also run in the UI thread. | |
41 class MediaRouterImpl : public MediaRouter, public KeyedService { | |
42 public: | |
43 ~MediaRouterImpl() override; | |
44 | |
45 // |provider_manager_host_| must be null at the time this is called. | |
46 // |provider_manager_host| must not be null. | |
47 // Does not take ownership of |provider_manager_host_|. | |
48 // This function can only be called once. | |
49 void Initialize(MediaRouter* provider_manager_host); | |
50 | |
51 // MediaRouter implementation. | |
52 void RequestRoute(const MediaSourceId& source, | |
53 const MediaSinkId& sink_id, | |
54 const MediaRouteResponseCallback& callback) override; | |
55 void CloseRoute(const MediaRouteId& route_id) override; | |
56 void PostMessage(const MediaRouteId& route_id, | |
57 const std::string& message) override; | |
58 | |
59 private: | |
60 friend class MediaRouterImplFactory; | |
61 | |
62 // Use MediaRouterImplFactory::GetForBrowserContext(). | |
63 MediaRouterImpl(); | |
64 | |
65 // MediaRouter implementation. | |
66 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override; | |
67 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override; | |
68 bool RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | |
69 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | |
70 | |
71 // MRPM host to forward calls to MRPM to. | |
72 // This class does not own provider_manager_host_. | |
73 MediaRouter* provider_manager_host_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(MediaRouterImpl); | |
76 }; | |
77 | |
78 } // namespace media_router | |
79 | |
80 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_ | |
OLD | NEW |