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

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: Removed OnSinksReceived/OnRoutesReceived from Delegate 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
« no previous file with comments | « chrome/browser/media/router/media_route.h ('k') | chrome/browser/media/router/media_router.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(scoped_ptr<MediaRoute>, const std::string&)>;
xhwang 2015/04/09 17:33:34 Since this is part of the interface. Please add a
imcheng 2015/04/09 17:49:10 Done.
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 virtual void RequestRoute(const MediaSource& source,
37 const MediaSinkId& sink_id,
xhwang 2015/04/09 17:33:34 OOC, is there any reason not to use a MediaSink he
imcheng 2015/04/09 17:49:10 That's because RequestRoute only needs to know the
38 const MediaRouteResponseCallback& callback) = 0;
39
40 // Closes the media route specified by |route_id|.
41 virtual void CloseRoute(const MediaRouteId& route_id) = 0;
42
43 // Posts |message| to a MediaSink connected via MediaRoute with |route_id|.
44 // TODO(imcheng): Support additional data types: Blob, ArrayBuffer,
45 // ArrayBufferView.
46 virtual void PostMessage(const MediaRouteId& route_id,
47 const std::string& message) = 0;
48
49 // Receives updates from a MediaRouter instance.
50 class Delegate {
51 // Called when there is a message from a route.
Kevin Marshall 2015/04/09 18:16:59 Missing public:
imcheng 2015/04/09 18:44:27 Done.
52 // |route_id|: The route ID.
53 // |message|: The message.
54 virtual void OnMessage(const MediaRouteId& route_id,
55 const std::string& message) = 0;
56 };
57
58 private:
59 friend class MediaSinksObserver;
60 friend class MediaRoutesObserver;
61
62 // The following APIs are called by MediaSinksObserver/MediaRoutesObserver
63 // only.
64
65 // Registers |observer| with this MediaRouter. |observer| specifies a media
66 // source and will receive updates with media sinks that are compatible with
67 // that source. The initial update may happen synchronously.
68 // NOTE: This class does not assume ownership of |observer|. Callers must
69 // manage |observer| and make sure |UnregisterObserver()| is called
70 // before the observer is destroyed.
71 // Returns true if registration succeeded.
72 // It is invalid to request the same observer more than once and will result
73 // in undefined behavior.
74 // If the MRPM Host is not available, the registration request will fail
75 // immediately.
76 virtual bool RegisterMediaSinksObserver(MediaSinksObserver* observer) = 0;
77
78 // Removes a previously added MediaSinksObserver. |observer| will stop
79 // receiving further updates.
80 virtual void UnregisterMediaSinksObserver(MediaSinksObserver* observer) = 0;
xhwang 2015/04/09 17:33:33 Do you expect all customers of MeidaRouter to impl
imcheng 2015/04/09 17:49:10 Yes, customers will have to provide their own impl
81
82 // Adds a MediaRoutesObserver to listen for updates on MediaRoutes.
83 // The initial update may happen synchronously.
84 // MediaRouter does not own |observer|. |RemoveMediaRoutesObserver| should
85 // be called before |observer| is destroyed.
86 virtual bool RegisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0;
87
88 // Removes a previously added MediaRoutesObserver. |observer| will stop
89 // receiving further updates.
90 virtual void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) = 0;
91 };
92
93 } // namespace media_router
94
95 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_route.h ('k') | chrome/browser/media/router/media_router.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698