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

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

Issue 2701633002: [Media Router] Add DialMediaSinkService and DeviceDescriptionService (Closed)
Patch Set: Add DialMediaSinkCacheService and unit test Created 3 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/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..07394d20e627cda0417eaf42ad8f4ae3ae797c98
--- /dev/null
+++ b/chrome/browser/media/router/dial_media_sink_service.h
@@ -0,0 +1,102 @@
+// 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/dial_media_sink_cache_service.h"
+#include "chrome/browser/media/router/discovery/media_sink_internal.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);
+ ~DialMediaSinkService() override;
+
+ // MediaSinkService implementation
+ void Start() override;
+ void AddSinkQuery(MediaSinksObserver* observer) override;
+ void RemoveSinkQuery(MediaSinksObserver* observer) override;
+
+ protected:
+ using DialRegistry = extensions::api::dial::DialRegistry;
+
+ virtual DialRegistry* dial_registry();
+ virtual DeviceDescriptionService* description_service();
+ virtual DialMediaSinkCacheService* cache_service();
+
+ private:
+ friend class DialMediaSinkServiceTest;
+ FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestStart);
+ FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestFetchCompleted);
+ FRIEND_TEST_ALL_PREFIXES(DialMediaSinkServiceTest, TestIsDifferent);
+
+ // 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 FetchCompleted();
+
+ bool IsDifferent(const std::vector<MediaSinkInternal> new_sinks,
+ const std::vector<MediaSinkInternal> old_sinks);
+
+ // Device ids pending resolution
+ std::set<std::string> pending_device_labels_;
+
+ // Map of <sink id, DialMediaSink> for current round discovery.
+ // std::map<std::string, DialMediaSink> dial_sinks_;
+
+ // Timer for finishing fetching.
+ base::OneShotTimer finish_timer_;
+
+ // |dial_api_| lives in IO thread. It owns |dial_registry_|.
+ scoped_refptr<extensions::DialAPI> dial_api_;
+
+ // This class does not take ownership of |dial_registry_|. |dial_api_| owns
+ // this.
+ DialRegistry* dial_registry_;
+
+ std::unique_ptr<DeviceDescriptionService> description_service_;
+ std::unique_ptr<DialMediaSinkCacheService> cache_service_;
+
+ content::BrowserContext* browser_context_;
+ net::URLRequestContextGetter* request_context_;
+
+ std::vector<MediaSinkInternal> mrp_sinks_;
+
+ bool network_disconnected_;
+};
+
+} // namespace media_router
+
+#endif // CHROME_BROWSER_MEDIA_ROUTER_DIAL_MEDIA_SINK_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698