| OLD | NEW |
| 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_MOJO_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/containers/scoped_ptr_hash_map.h" | 13 #include "base/containers/scoped_ptr_hash_map.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 19 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
| 20 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
| 21 #include "chrome/browser/media/router/issue.h" | 21 #include "chrome/browser/media/router/issue.h" |
| 22 #include "chrome/browser/media/router/media_router.h" | 22 #include "chrome/browser/media/router/media_router.h" |
| 23 #include "chrome/browser/media/router/media_router.mojom.h" | 23 #include "chrome/browser/media/router/media_router.mojom.h" |
| 24 #include "components/keyed_service/core/keyed_service.h" | |
| 25 | 24 |
| 26 namespace content { | 25 namespace content { |
| 27 class BrowserContext; | 26 class BrowserContext; |
| 28 } | 27 } |
| 29 | 28 |
| 30 namespace extensions { | 29 namespace extensions { |
| 31 class EventPageTracker; | 30 class EventPageTracker; |
| 32 } | 31 } |
| 33 | 32 |
| 34 namespace media_router { | 33 namespace media_router { |
| 35 | 34 |
| 36 // MediaRouter implementation that delegates calls to the component extension. | 35 // MediaRouter implementation that delegates calls to the component extension. |
| 37 // Also handles the suspension and wakeup of the component extension. | 36 // Also handles the suspension and wakeup of the component extension. |
| 38 class MediaRouterMojoImpl : public MediaRouter, | 37 class MediaRouterMojoImpl : public MediaRouter, |
| 39 public interfaces::MediaRouter, | 38 public interfaces::MediaRouter { |
| 40 public KeyedService { | |
| 41 public: | 39 public: |
| 42 ~MediaRouterMojoImpl() override; | 40 ~MediaRouterMojoImpl() override; |
| 43 | 41 |
| 44 // Sets up the MediaRouterMojoImpl instance owned by |context| to handle | 42 // Sets up the MediaRouterMojoImpl instance owned by |context| to handle |
| 45 // MediaRouterObserver requests from the component extension given by | 43 // MediaRouterObserver requests from the component extension given by |
| 46 // |extension_id|. Creates the MediaRouterMojoImpl instance if it does not | 44 // |extension_id|. Creates the MediaRouterMojoImpl instance if it does not |
| 47 // exist. | 45 // exist. |
| 48 // Called by the Mojo module registry. | 46 // Called by the Mojo module registry. |
| 49 // |extension_id|: The ID of the component extension, used for querying | 47 // |extension_id|: The ID of the component extension, used for querying |
| 50 // suspension state. | 48 // suspension state. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 81 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | 79 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; |
| 82 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | 80 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; |
| 83 void RegisterIssuesObserver(IssuesObserver* observer) override; | 81 void RegisterIssuesObserver(IssuesObserver* observer) override; |
| 84 void UnregisterIssuesObserver(IssuesObserver* observer) override; | 82 void UnregisterIssuesObserver(IssuesObserver* observer) override; |
| 85 | 83 |
| 86 void set_instance_id_for_test(const std::string& instance_id) { | 84 void set_instance_id_for_test(const std::string& instance_id) { |
| 87 instance_id_ = instance_id; | 85 instance_id_ = instance_id; |
| 88 } | 86 } |
| 89 | 87 |
| 90 private: | 88 private: |
| 91 friend class MediaRouterMojoImplFactory; | 89 friend class MediaRouterFactory; |
| 92 friend class MediaRouterMojoTest; | 90 friend class MediaRouterMojoTest; |
| 93 | 91 |
| 94 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, | 92 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, |
| 95 DeferredBindingAndSuspension); | 93 DeferredBindingAndSuspension); |
| 96 | 94 |
| 97 // Standard constructor, used by | 95 // Standard constructor, used by |
| 98 // MediaRouterMojoImplFactory::GetApiForBrowserContext. | 96 // MediaRouterMojoImplFactory::GetApiForBrowserContext. |
| 99 explicit MediaRouterMojoImpl( | 97 explicit MediaRouterMojoImpl( |
| 100 extensions::EventPageTracker* event_page_tracker); | 98 extensions::EventPageTracker* event_page_tracker); |
| 101 | 99 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 std::string instance_id_; | 195 std::string instance_id_; |
| 198 | 196 |
| 199 base::ThreadChecker thread_checker_; | 197 base::ThreadChecker thread_checker_; |
| 200 | 198 |
| 201 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 199 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 202 }; | 200 }; |
| 203 | 201 |
| 204 } // namespace media_router | 202 } // namespace media_router |
| 205 | 203 |
| 206 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 204 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |