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

Unified Diff: chrome/browser/media/router/media_router_impl.h

Issue 1020743003: [Media Router] Design MediaRouter interface with stub implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Kevin's comments Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
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..647962f830093198a7b2ca4559aac1cb74748b4e
--- /dev/null
+++ b/chrome/browser/media/router/media_router_impl.h
@@ -0,0 +1,102 @@
+// 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 addition, responses from MediaRouteProviderManagerHost are delegated to
+// this class which then invokes the observers / callbacks.
+// Instances of this class are created by MediaRouterImplFactory.
+// MediaRouterImpl is a profile-keyed service.
+// MediaRouterImpl runs on the browser UI thread. All observers/callbacks
+// registered to this class must also run in the UI thread.
+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 Initialize(MediaRouteProviderManagerHost* mrpm_host);
+
+ // 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 RegisterMediaSinksObserver(MediaSinksObserver* observer) override;
+ void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override;
+ void PostMessage(const MediaRouteId& route_id,
+ const std::string& message) override;
+ bool RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override;
+ void UnregisterMediaRoutesObserver(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.
+ // Not owned by this object.
+ MediaRouteProviderManagerHost* mrpm_host_;
xhwang 2015/04/02 17:13:02 Most people have no idea what "mrpm" is, use full
imcheng 2015/04/02 23:05:24 renamed to provider_manager_host_. Yes, the class
+
+ DISALLOW_COPY_AND_ASSIGN(MediaRouterImpl);
+};
+
+} // namespace media_router
+
+#endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698