Chromium Code Reviews| Index: chrome/browser/media/router/offscreen_presentation_manager.h |
| diff --git a/chrome/browser/media/router/offscreen_presentation_manager.h b/chrome/browser/media/router/offscreen_presentation_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cc1b21245fce8171b0ef686b05f3383b55200e0b |
| --- /dev/null |
| +++ b/chrome/browser/media/router/offscreen_presentation_manager.h |
| @@ -0,0 +1,106 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
|
imcheng
2016/09/19 23:01:17
2016
zhaobin
2016/09/23 17:18:18
Done.
|
| +// 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_OFFSCREEN_PRESENTATION_MANAGER_H_ |
| +#define CHROME_BROWSER_MEDIA_ROUTER_OFFSCREEN_PRESENTATION_MANAGER_H_ |
| + |
| +#include <map> |
| +#include <set> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "chrome/browser/media/router/render_frame_host_id.h" |
| +#include "components/keyed_service/core/keyed_service.h" |
| +#include "content/public/browser/presentation_service_delegate.h" |
| + |
| +namespace media_router { |
| + |
| +class OffscreenPresentation; |
| + |
| +// This class lives in browser context and manages all presentations |
|
imcheng
2016/09/19 23:01:17
Please clarify the comments:
- Instances of this
zhaobin
2016/09/23 17:18:18
Done.
|
| +// in current browser process. All PSDImpl share the same instance of |
| +// OffscreenPresentationManager. |
| +class OffscreenPresentationManager : public KeyedService { |
| + public: |
| + ~OffscreenPresentationManager() override; |
| + |
| + // Register controller PSImpl to presentation with |presentation_id|. |
| + // Create a new presentation if no presentation with |presentation_id| exists. |
| + void RegisterOffscreenPresentationController( |
| + const std::string& presentation_id, |
| + content::OffscreenPresentationClient* controller); |
| + |
| + // Unregister controller PSImpl to presentation with |presentation_id|. |
| + void UnregisterOffscreenPresentationController( |
| + const std::string& presentation_id, |
| + content::OffscreenPresentationClient* controller); |
| + |
| + // Register receiver PSImpl to presentation with |presentation_id|. |
| + void RegisterOffscreenPresentationReceiver( |
| + const std::string& presentation_id, |
| + content::OffscreenPresentationClient* receiver); |
|
imcheng
2016/09/19 23:01:17
The method signature here doesn't restrict it to R
zhaobin
2016/09/23 17:18:18
Done.
|
| + |
| + // Unregister receiver PSImpl to presentation with |presentation_id|, |
| + // and remove presentation from presentation map. |
| + void UnregisterOffscreenPresentationReceiver( |
| + const std::string& presentation_id); |
| + |
| + private: |
| + friend class OffscreenPresentationManagerFactory; |
| + friend class OffscreenPresentationManagerTest; |
| + |
| + // Used by OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext. |
| + OffscreenPresentationManager(); |
| + |
| + // Maps from presentation ID to OffscreenPresentation. |
| + std::map<std::string, std::unique_ptr<OffscreenPresentation>> |
| + offscreen_presentations_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OffscreenPresentationManager); |
| +}; |
| + |
| +class OffscreenPresentation { |
|
imcheng
2016/09/19 23:01:17
Please add documentation
zhaobin
2016/09/23 17:18:18
Done.
|
| + public: |
| + explicit OffscreenPresentation(const std::string& presentation_id); |
| + ~OffscreenPresentation(); |
| + |
| + void RegisterController(content::OffscreenPresentationClient* controller); |
| + |
| + void UnregisterController(content::OffscreenPresentationClient* controller); |
| + |
| + void RegisterReceiver(content::OffscreenPresentationClient* receiver); |
| + |
| + void UnregisterReceiver(); |
| + |
| + private: |
| + friend class OffscreenPresentationManagerTest; |
| + friend class OffscreenPresentationManager; |
| + |
| + void AddOffscreenPresentationObserver( |
| + content::OffscreenPresentationClient* controller, |
| + content::OffscreenPresentationClient* receiver); |
| + |
| + void RemoveOffscreenPresentationObserver( |
| + content::OffscreenPresentationClient* controller, |
| + content::OffscreenPresentationClient* receiver); |
| + |
| + // URL for current presentation |
| + const std::string presentation_url_; |
| + |
| + // presentation_id for current presentation |
| + const std::string presentation_id_; |
| + |
| + // proxy to receiver PSImpl |
| + content::OffscreenPresentationClient* receiver_; |
| + |
| + // proxy to controller PSImpl |
| + std::set<content::OffscreenPresentationClient*> controllers_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(OffscreenPresentation); |
| +}; |
| + |
| +} // namespace media_router |
| + |
| +#endif // CHROME_BROWSER_MEDIA_ROUTER_OFFSCREEN_PRESENTATION_MANAGER_H_ |