Chromium Code Reviews| Index: chrome/browser/media/router/media_router_impl.h |
| diff --git a/chrome/browser/media/router/media_router_impl.h b/chrome/browser/media/router/media_router_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..de12badbfeafc23c80f56f7315bc56dd62c4fd4d |
| --- /dev/null |
| +++ b/chrome/browser/media/router/media_router_impl.h |
| @@ -0,0 +1,100 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_ |
| +#define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_ |
| + |
| +#include <map> |
| +#include <queue> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| +#include "base/containers/hash_tables.h" |
| +#include "base/gtest_prod_util.h" |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_vector.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "chrome/browser/media/router/media_route_provider_manager_host.h" |
| +#include "chrome/browser/media/router/media_router.h" |
| +#include "chrome/browser/media/router/media_sinks_observer.h" |
| +#include "components/keyed_service/core/keyed_service.h" |
| + |
| +namespace base { |
| +template <typename T> |
| +struct DefaultLazyInstanceTraits; |
| +} // namespace base |
| + |
| +namespace media_router { |
| + |
| +class MediaRoute; |
| +class MediaRouterApiImpl; |
| +class MediaRoutesObserver; |
| +struct RoutesQueryResult; |
| + |
| +// Implementation of MediaRouter that delegates calls to |
| +// MediaRouteProviderManagerHost, which in turn handles communication |
| +// with the Media Route Provider Manager (MRPM) in the component extension. |
|
mark a. foltz
2015/03/27 21:21:59
I wouldn't mention the component extension here, s
imcheng
2015/03/30 22:49:10
Done.
|
| +// In addition, responses from MRPM are delegated to this class which then |
|
mark a. foltz
2015/03/27 21:21:58
s/MRPM/MediaRouteProviderManagerHost/
imcheng
2015/03/30 22:49:10
Done.
|
| +// invokes the observers / callbacks. |
| +// Instances of this class are created through MediaRouterImplFactory. |
|
mark a. foltz
2015/03/27 21:21:58
s/through/by/
Mention this is a profile-keyed ser
imcheng
2015/03/30 22:49:10
Done.
|
| +class MediaRouterImpl : public MediaRouter, |
| + public KeyedService, |
| + public MediaRouteProviderManagerHost::Delegate { |
| + public: |
| + ~MediaRouterImpl() override; |
| + |
| + // |mrpm_host_| must be null at the time this is called. |
| + // |mrpm_host| must not be null. |
| + // Does not take ownership of |mrpm_host_|. |
| + // This function can only be called once. |
| + void SetMRPMHost(MediaRouteProviderManagerHost* mrpm_host); |
|
mark a. foltz
2015/03/27 21:21:58
Maybe this should just be Initialize()?
imcheng
2015/03/30 22:49:10
Done.
|
| + |
| + // MediaRouter implementation. |
| + RouteRequestId StartRouteRequest( |
| + const MediaSource& source, |
| + const MediaSinkId& sink_id, |
| + const MediaRouteResponseCallback& callback) override; |
| + void UnregisterMediaRouteResponseCallback( |
| + const RouteRequestId& request_id) override; |
| + void CloseRoute(const MediaRouteId& route_id) override; |
| + bool RegisterObserver(MediaSinksObserver* observer) override; |
| + void UnregisterObserver(MediaSinksObserver* observer) override; |
| + void PostMessage(const MediaRouteId& route_id, |
| + const std::string& message, |
| + const std::string& extra_info_json) override; |
| + void AddMediaRoutesObserver(MediaRoutesObserver* observer) override; |
| + void RemoveMediaRoutesObserver(MediaRoutesObserver* observer) override; |
| + |
| + // MediaRouteProviderManagerHost::Delegate implementation. |
| + void OnMessage(const MediaRouteId& route_id, |
| + const std::string& message) override; |
| + void OnSinksReceived(const MediaSource& source, |
| + const std::vector<MediaSink>& sinks) override; |
| + void OnRouteResponseReceived(const RouteRequestId& request_id, |
| + const MediaRoute& route) override; |
| + void OnRouteResponseError(const RouteRequestId& request_id, |
| + const std::string& error_text) override; |
| + void OnRoutesUpdated( |
| + const std::vector<MediaRoute>& routes, |
| + const std::vector<MediaSink>& sinks) override; |
| + void OnHostDestroyed(MediaRouteProviderManagerHost* host) override; |
| + |
| + private: |
| + friend class MediaRouterImplFactory; |
| + |
| + // Use MediaRouterImplFactory::GetForBrowserContext(). |
| + MediaRouterImpl(); |
| + |
| + // MRPM host to forward calls to MRPM to. |
| + // Responses from MRPM are also received from this host. |
| + // Does not own this object. |
|
mark a. foltz
2015/03/27 21:21:59
I think you meant to say "Not owned by this object
imcheng
2015/03/30 22:49:10
Done.
|
| + MediaRouteProviderManagerHost* mrpm_host_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MediaRouterImpl); |
| +}; |
| + |
| +} // namespace media_router |
| + |
| +#endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_ |