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

Side by Side Diff: chrome/browser/media/router/media_router.h

Issue 1020743003: [Media Router] Design MediaRouter interface with stub implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gcl format Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "chrome/browser/media/router/media_route.h"
13 #include "chrome/browser/media/router/media_route_id.h"
14 #include "chrome/browser/media/router/media_sink.h"
15
16 namespace media_router {
17
18 class MediaRouteResponse;
19 class MediaRoutesObserver;
20 class MediaSource;
21 class MediaSinksObserver;
22
23 using MediaRouteResponseCallback =
24 base::Callback<void(const MediaRouteResponse&)>;
25
26 // An interface for handling resources related to media routing.
27 // Responsible for registering observers for receiving sink availability
28 // updates, handling route requests/responses, and operating on routes (e.g.
29 // posting messages or closing).
30 class MediaRouter {
31 public:
32 virtual ~MediaRouter() {}
33
34 // Requests a media route from |source| to |sink_id|.
35 // |callback| is invoked with a response indicating success or failure.
36 // If it is not possible to request a route, returns kInvalidRouteRequestId.
37 // Otherwise a valid RouteRequestId (id > kInvalidRouteRequestId) will be
38 // returned, which can be used with |UnregisterMediaRouteResponseCallback()|
39 // if the caller no longer wants the callback invoked when a response
40 // comes back.
41 virtual RouteRequestId StartRouteRequest(
xhwang 2015/04/08 17:46:25 (See comment above.) Does this correspond to Req
imcheng 2015/04/08 19:21:31 Renamed to RequestRoute(). For delegate vs. cb, pl
42 const MediaSource& source,
43 const MediaSinkId& sink_id,
44 const MediaRouteResponseCallback& callback) = 0;
45
46 // Unregisters a callback registered with a pending media route request,
47 // e.g., when the user has canceled presentation by closing the media router
48 // dialog.
49 // It does NOT cancel the route request, only the callback previously
50 // registered via |StartRouteRequest|.
51 // |request_id|: A valid request ID returned by |StartRouteRequest()|.
52 virtual void UnregisterMediaRouteResponseCallback(
53 const RouteRequestId& request_id) = 0;
xhwang 2015/04/08 17:46:25 Since we don't actually cancel the request, what's
imcheng 2015/04/08 19:21:31 What you described is correct. However removing th
xhwang 2015/04/08 20:32:51 We use WeakPtrs in many many places in Chromium an
imcheng 2015/04/08 23:28:09 Removed API.
54
55 // Closes the media route specified by |route_id|.
56 virtual void CloseRoute(const MediaRouteId& route_id) = 0;
57
58 // Posts |message| to a MediaSink connected via MediaRoute with |route_id|.
59 // TODO(imcheng): Support additional data types: Blob, ArrayBuffer,
60 // ArrayBufferView.
61 virtual void PostMessage(const MediaRouteId& route_id,
62 const std::string& message) = 0;
63
64 private:
65 friend class MediaSinksObserver;
66 friend class MediaRoutesObserver;
xhwang 2015/04/08 17:46:25 Does MediaSinkObserver and MediaRoutesObserver cor
imcheng 2015/04/08 19:21:31 Yes.
67
68 // The following APIs are called by MediaSinksObserver/MediaRoutesObserver
69 // only.
70
71 // Registers |observer| with this MediaRouter. |observer| specifies a media
72 // source and will receive updates with media sinks that are compatible with
73 // that source. The initial update may happen synchronously.
74 // NOTE: This class does not assume ownership of |observer|. Callers must
75 // manage |observer| and make sure |UnregisterObserver()| is called
76 // before the observer is destroyed.
77 // Returns true if registration succeeded.
78 // It is invalid to request the same observer more than once and will result
79 // in undefined behavior.
80 // If the MRPM Host is not available, the registration request will fail
81 // immediately.
82 virtual bool RegisterMediaSinksObserver(MediaSinksObserver* observer) = 0;
83
84 // Removes a previously added MediaSinksObserver. |observer| will stop
85 // receiving further updates.
86 virtual void UnregisterMediaSinksObserver(MediaSinksObserver* observer) = 0;
87
88 // Adds a MediaRoutesObserver to listen for updates on MediaRoutes.
89 // The initial update may happen synchronously.
90 // MediaRouter does not own |observer|. |RemoveMediaRoutesObserver| should
91 // be called before |observer| is destroyed.
92 virtual bool RegisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0;
93
94 // Removes a previously added MediaRoutesObserver. |observer| will stop
95 // receiving further updates.
96 virtual void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0;
97 };
98
99 } // namespace media_router
100
101 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698