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

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

Issue 2837363002: [Media Router] Use DialMediaSinkService in MediaRouterMojoImpl (Closed)
Patch Set: resolve code review comments from Mark Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/discovery/dial/dial_media_sink_service_proxy.h
diff --git a/chrome/browser/media/router/discovery/dial/dial_media_sink_service_proxy.h b/chrome/browser/media/router/discovery/dial/dial_media_sink_service_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..10895b0fa2ad4701f1a3997076e700fb1086e501
--- /dev/null
+++ b/chrome/browser/media/router/discovery/dial/dial_media_sink_service_proxy.h
@@ -0,0 +1,72 @@
+// 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_PROXY_H_
+#define CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_PROXY_H_
+
+#include <memory>
+#include "chrome/common/media_router/discovery/media_sink_service.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+namespace media_router {
+
+class DialMediaSinkService;
+
+// A wrapper class of DialMediaSinkService handling thread hopping between UI
+// and IO threads. This class is thread safe. Public APIs should be invoked on
+// UI thread. It then post tasks to IO thread and invoke them on underlying
+// DialMediaSinkService instance.
+class DialMediaSinkServiceProxy
+ : public MediaSinkService,
Kevin M 2017/05/15 19:56:58 Can MediaSinkService be made into a 100% pure virt
mark a. foltz 2017/05/15 21:36:28 I think refactoring the inheritance is in progress
zhaobin 2017/05/16 21:26:49 Both DialMediaSinkServiceProxy and DialMediaSinkSe
+ public base::RefCountedThreadSafe<DialMediaSinkServiceProxy> {
+ public:
+ // |callback| is invoked on the UI thread when sinks are discovered.
+ // |request_context| is used for HTTP requests made for discovery.
+ DialMediaSinkServiceProxy(
+ const MediaSinkService::OnSinksDiscoveredCallback& callback,
+ net::URLRequestContextGetter* request_context);
Kevin M 2017/05/15 19:56:58 ~DialMediaSinkServiceProxy = default;
mark a. foltz 2017/05/15 21:36:28 That should go in the .cc, as it will invoke the D
zhaobin 2017/05/16 21:26:49 RefCountedThreadSafe class needs private dtor.
+
+ // Starts discovery of DIAL devices on IO thread.
+ void Start() override;
+
+ // Stops discovery of DIAL devices on IO thread. The callback passed to
+ // Start() is cleared.
+ void Stop();
+
+ void SetDialMediaSinkServiceForTest(
+ std::unique_ptr<DialMediaSinkService,
+ content::BrowserThread::DeleteOnIOThread>
+ dial_media_sink_service);
+
+ private:
+ friend class DialMediaSinkServiceProxyTest;
+ friend class base::RefCountedThreadSafe<DialMediaSinkServiceProxy>;
+ ~DialMediaSinkServiceProxy() override;
+
+ // Starts DIAL discovery.
+ void StartOnIOThread();
+
+ // Stops DIAL discovery.
+ void StopOnIOThread();
+
+ // Callback passed to |dial_media_sink_service_| ctor. When invoked, post task
+ // to UI thread and invoke |sink_discovery_callback_|;
+ void OnSinksDiscoveredOnIOThread(const std::vector<MediaSinkInternal>& sinks);
+
+ // Invokes |sink_discovery_callback_| on UI thread.
+ void OnSinksDiscoveredOnUIThread(const std::vector<MediaSinkInternal>& sinks);
+
+ private:
+ std::unique_ptr<DialMediaSinkService,
+ content::BrowserThread::DeleteOnIOThread>
+ dial_media_sink_service_;
+};
Kevin M 2017/05/15 19:56:58 nit: DISALLOW_COPY_AND_ASSIGN(DialMediaSinkService
zhaobin 2017/05/16 21:26:49 Done.
+
+} // namespace media_router
+
+#endif // CHROME_BROWSER_MEDIA_ROUTER_DISCOVERY_DIAL_DIAL_MEDIA_SINK_SERVICE_PROXY_H_

Powered by Google App Engine
This is Rietveld 408576698