Chromium Code Reviews| Index: chrome/browser/media/router/dial_media_sink_service.h |
| diff --git a/chrome/browser/media/router/dial_media_sink_service.h b/chrome/browser/media/router/dial_media_sink_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6bb4956b87218917c0ea2c79845006fd9c2571f2 |
| --- /dev/null |
| +++ b/chrome/browser/media/router/dial_media_sink_service.h |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2017 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_DIAL_MEDIA_SINK_SERVICE_H_ |
| +#define CHROME_BROWSER_MEDIA_ROUTER_DIAL_MEDIA_SINK_SERVICE_H_ |
| + |
| +#include <memory> |
| + |
| +#include "chrome/browser/extensions/api/dial/dial_registry.h" |
| +#include "chrome/browser/media/router/device_description_service.h" |
| +#include "chrome/browser/media/router/media_sink.h" |
| +#include "chrome/browser/media/router/media_sink_service.h" |
| + |
| +namespace content { |
| +class BrowserContext; |
| +} |
| + |
| +namespace extensions { |
| +class DialAPI; |
| +} |
| + |
| +namespace net { |
| +class URLRequestContextGetter; |
| +} |
| + |
| +namespace media_router { |
| + |
| +class DialMediaSinkService |
| + : public MediaSinkService, |
| + public extensions::api::dial::DialRegistry::Observer, |
| + public DeviceDescriptionService::Observer { |
| + public: |
| + DialMediaSinkService(const OnSinksDiscoveredCallback& callback, |
| + content::BrowserContext* browser_context); |
|
mark a. foltz
2017/03/11 00:08:15
Is this a profile-keyed service?
Note that we hav
zhaobin
2017/04/10 18:44:41
We use profile to get request context for URL fetc
|
| + ~DialMediaSinkService() override; |
| + |
| + // MediaSinkService implementation |
| + void Start() override; |
| + void AddSinkQuery(MediaSinksObserver* observer) override; |
| + void RemoveSinkQuery(MediaSinksObserver* observer) override; |
| + |
| + private: |
| + using DialRegistry = extensions::api::dial::DialRegistry; |
| + |
| + DialRegistry* dial_registry(); |
| + DeviceDescriptionService* description_service(); |
| + |
| + // api::dial::DialRegistry::Observer implementation |
| + void OnDialDeviceEvent(const DialRegistry::DeviceList& devices) override; |
| + void OnDialError(DialRegistry::DialErrorCode type) override; |
| + |
| + // DeviceDescriptionService::Observer implementation. |
| + void OnDeviceDescriptionAvailable( |
| + const std::string& device_label, |
| + const DialDeviceDescription& description) override; |
| + void OnDeviceDescriptionFetchError(const std::string& device_label, |
| + const std::string& error_message) override; |
| + |
| + void OnDeviceDescription(const std::string& device_id); |
| + void FetchCompleted(); |
| + |
| + // Device ids pending resolution |
| + std::set<std::string> pending_device_labels_; |
| + |
| + // Map of <sink id, mediaSink> |
| + std::map<std::string, std::unique_ptr<MediaSink>> dial_sinks_; |
| + |
| + // |dial_api_| lives in IO thread. It owns |dial_registry_|. |
| + scoped_refptr<extensions::DialAPI> dial_api_; |
| + DialRegistry* dial_registry_; |
|
mark a. foltz
2017/03/11 00:08:15
The DialRegistry should become refcounted, since I
zhaobin
2017/03/28 13:36:59
DialRegistry is a leaky singleton now. Raw pointer
|
| + |
| + std::unique_ptr<DeviceDescriptionService> description_service_; |
| + content::BrowserContext* browser_context_; |
| + net::URLRequestContextGetter* request_context_; |
|
mark a. foltz
2017/03/11 00:08:15
This is usually passed directly to the URLFetcher
zhaobin
2017/04/10 18:44:42
profile->GetRequestContext() should be called on U
|
| +}; |
| + |
| +} // namespace media_router |
| + |
| +#endif // CHROME_BROWSER_MEDIA_ROUTER_DIAL_MEDIA_SINK_SERVICE_H_ |