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

Side by Side Diff: chrome/browser/media/router/media_router_base.h

Issue 1911183002: [Media Router] Implement an internal Media Routes observer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad merge & android build Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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_BASE_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector>
9 10
10 #include "base/callback_list.h" 11 #include "base/callback_list.h"
11 #include "base/containers/scoped_ptr_hash_map.h" 12 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "chrome/browser/media/router/media_route.h"
15 #include "chrome/browser/media/router/media_router.h" 17 #include "chrome/browser/media/router/media_router.h"
16 18 #include "chrome/browser/media/router/media_routes_observer.h"
17 class Profile;
18 19
19 namespace media_router { 20 namespace media_router {
20 21
21 class MediaRouterBase : public MediaRouter { 22 class MediaRouterBase : public MediaRouter {
22 public: 23 public:
23 MediaRouterBase();
24 ~MediaRouterBase() override; 24 ~MediaRouterBase() override;
25 25
26 std::unique_ptr<PresentationConnectionStateSubscription> 26 std::unique_ptr<PresentationConnectionStateSubscription>
27 AddPresentationConnectionStateChangedCallback( 27 AddPresentationConnectionStateChangedCallback(
28 const MediaRoute::Id& route_id, 28 const MediaRoute::Id& route_id,
29 const content::PresentationConnectionStateChangedCallback& callback) 29 const content::PresentationConnectionStateChangedCallback& callback)
30 override; 30 override;
31 31
32 // Called when the off the record (incognito) profile for this instance is 32 // Called when the off the record (incognito) profile for this instance is
33 // being shut down. This will terminate all off the record media routes. 33 // being shut down. This will terminate all off the record media routes.
34 void OnOffTheRecordProfileShutdown() override; 34 void OnOffTheRecordProfileShutdown() override;
35 35
36 protected: 36 protected:
37 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, 37 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
38 PresentationConnectionStateChangedCallback); 38 PresentationConnectionStateChangedCallback);
39 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, 39 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
40 PresentationConnectionStateChangedCallbackRemoved); 40 PresentationConnectionStateChangedCallbackRemoved);
41 41
42 MediaRouterBase();
43
42 // Generates a unique presentation id. Shared between Android and desktop. 44 // Generates a unique presentation id. Shared between Android and desktop.
43 static std::string CreatePresentationId(); 45 static std::string CreatePresentationId();
44 46
45 void NotifyPresentationConnectionStateChange( 47 void NotifyPresentationConnectionStateChange(
46 const MediaRoute::Id& route_id, 48 const MediaRoute::Id& route_id,
47 content::PresentationConnectionState state); 49 content::PresentationConnectionState state);
48 void NotifyPresentationConnectionClose( 50 void NotifyPresentationConnectionClose(
49 const MediaRoute::Id& route_id, 51 const MediaRoute::Id& route_id,
50 content::PresentationConnectionCloseReason reason, 52 content::PresentationConnectionCloseReason reason,
51 const std::string& message); 53 const std::string& message);
52 54
53 // Called when off the record route |route_id| has been created. 55 // Returns true when there is at least one MediaRoute with is_local = true.
54 void OnOffTheRecordRouteCreated(const MediaRoute::Id& route_id); 56 bool HasLocalRoute() const;
55 // Called when route |route_id| has been terminated.
56 void OnRouteTerminated(const MediaRoute::Id& route_id);
57 57
58 using PresentationConnectionStateChangedCallbacks = base::CallbackList<void( 58 using PresentationConnectionStateChangedCallbacks = base::CallbackList<void(
59 const content::PresentationConnectionStateChangeInfo&)>; 59 const content::PresentationConnectionStateChangeInfo&)>;
60
60 base::ScopedPtrHashMap< 61 base::ScopedPtrHashMap<
61 MediaRoute::Id, 62 MediaRoute::Id,
62 std::unique_ptr<PresentationConnectionStateChangedCallbacks>> 63 std::unique_ptr<PresentationConnectionStateChangedCallbacks>>
63 presentation_connection_state_callbacks_; 64 presentation_connection_state_callbacks_;
64 65
65 base::ThreadChecker thread_checker_; 66 base::ThreadChecker thread_checker_;
66 67
67 private: 68 private:
69 friend class MediaRouterFactory;
70 friend class MediaRouterMojoTest;
71
72 class InternalMediaRoutesObserver;
73
74 // Must be called before invoking any other method.
75 void Initialize();
76
68 // Called when a PresentationConnectionStateChangedCallback associated with 77 // Called when a PresentationConnectionStateChangedCallback associated with
69 // |route_id| is removed from |presentation_connection_state_callbacks_|. 78 // |route_id| is removed from |presentation_connection_state_callbacks_|.
70 void OnPresentationConnectionStateCallbackRemoved( 79 void OnPresentationConnectionStateCallbackRemoved(
71 const MediaRoute::Id& route_id); 80 const MediaRoute::Id& route_id);
72 81
73 // Ids of current off the record media routes. 82 // KeyedService
74 std::set<MediaRoute::Id> off_the_record_route_ids_; 83 void Shutdown() override;
84
85 std::unique_ptr<InternalMediaRoutesObserver> internal_routes_observer_;
86 bool initialized_;
75 87
76 DISALLOW_COPY_AND_ASSIGN(MediaRouterBase); 88 DISALLOW_COPY_AND_ASSIGN(MediaRouterBase);
77 }; 89 };
78 90
79 } // namespace media_router 91 } // namespace media_router
80 92
81 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_ 93 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/android/router/media_router_android.cc ('k') | chrome/browser/media/router/media_router_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698