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

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

Issue 2701633002: [Media Router] Add DialMediaSinkService and DeviceDescriptionService (Closed)
Patch Set: resolve code review comments from Mark cont Created 3 years, 8 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/discovery/dial/dial_media_sink_service.h
diff --git a/chrome/browser/media/router/discovery/dial/dial_media_sink_service.h b/chrome/browser/media/router/discovery/dial/dial_media_sink_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..7f364ec5fcbc0528b217206682189cf6a4d0987c
--- /dev/null
+++ b/chrome/browser/media/router/discovery/dial/dial_media_sink_service.h
@@ -0,0 +1,82 @@
+// 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_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_H_
+#define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_H_
+
+#include <memory>
+
+#include "chrome/browser/media/router/discovery/dial/device_description_service.h"
+#include "chrome/browser/media/router/discovery/dial/dial_registry.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 media_router {
+
+class DeviceDescriptionService;
+class DialMediaSinkCacheService;
+class DialRegistry;
+
+class DialMediaSinkService : public MediaSinkService,
+ public DialRegistry::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;
+
+ void Stop();
+
+ protected:
+ 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;
+
+ // Called when fails to fetch or parse device description xml.
+ void OnDeviceDescriptionError(const std::string& device_label,
+ const std::string& error_message);
+
+ // Called when |finish_timer_| expires.
+ void FetchCompleted();
+
+ // Returns true if |new_sink| is the same as |old_sinks|.
mark a. foltz 2017/04/12 00:17:18 s/new_sink/new_sinks/ The comment and the name of
zhaobin 2017/04/18 06:58:27 Done.
+ bool IsDifferent(const std::vector<MediaSinkInternal> new_sinks,
+ const std::vector<MediaSinkInternal> old_sinks);
+
+ // Timer for finishing fetching.
+ base::OneShotTimer finish_timer_;
+
+ std::unique_ptr<DeviceDescriptionService> description_service_;
+ std::unique_ptr<DialMediaSinkCacheService> cache_service_;
+
+ // Sinks sent to Media Router Provider in last FetchCompleted().
+ std::vector<MediaSinkInternal> mrp_sinks_;
+
+ bool network_disconnected_;
+
+ content::BrowserContext* browser_context_;
+ net::URLRequestContextGetter* request_context_;
+};
+
+} // namespace media_router
+
+#endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698