Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 // Defines communication between the Media Router and the | |
| 6 // Media Router Provider Component Extension. | |
|
xhwang
2015/04/27 17:52:02
This interface should be generic, it's not limited
Kevin Marshall
2015/04/27 19:23:51
Done.
| |
| 7 | |
| 8 module media_router.mojom; | |
|
xhwang
2015/04/27 17:52:02
Typically we don't put mojom in the module name. B
Kevin Marshall
2015/04/27 19:23:51
I'd prefer to use a nested type for naming conflic
xhwang
2015/04/28 06:08:18
Agreed. I might do the same for media mojom interf
| |
| 9 | |
| 10 struct Provider { | |
|
xhwang
2015/04/27 17:52:02
This struct is not used anywhere in this mojom fil
Kevin Marshall
2015/04/27 19:23:51
Done.
| |
| 11 // State transitions: | |
| 12 // UNINITIALIZED => LOADING => INITIALIZING | |
| 13 // ^ \/ | | |
| 14 // +=========(error handling)===| | |
| 15 // | | |
| 16 // \/ | |
| 17 // LOADING ====> READY | |
| 18 // ^ | (when idle) | |
| 19 // UNLOADED <======+ | |
|
xhwang
2015/04/27 17:52:01
nit: Will it cause confusing that LOADING appears
Kevin Marshall
2015/04/27 19:23:51
Removed.
| |
| 20 enum Status { | |
| 21 UNINITIALIZED, | |
| 22 LOADING, | |
| 23 INITIALIZING, | |
| 24 UNLOADED, | |
| 25 READY, | |
| 26 }; | |
| 27 string name; | |
| 28 Status load_status; | |
| 29 }; | |
| 30 | |
| 31 // Represents an output sink to which media can be routed. | |
| 32 struct MediaSink { | |
| 33 // The sink identifier, e.g. "rs71w7mFzYLFlabir_qO4NHl6SUc." | |
| 34 // Required. | |
|
xhwang
2015/04/27 17:52:02
Not needed? Optional/nullable members are marked w
Kevin Marshall
2015/04/27 19:23:50
Done.
| |
| 35 string sink_id; | |
| 36 // The human-readable name, e.g. "Janet's Chromecast". | |
| 37 // Required. | |
| 38 string name; | |
| 39 }; | |
| 40 | |
| 41 // Should be kept in sync with media_route.h. | |
| 42 struct MediaRoute { | |
| 43 // The ID of this media route, e.g. "r_PR1O_blkC9dsKp-tb1ti8qurOo". | |
| 44 // Required. | |
| 45 string media_route_id; | |
| 46 // The media source being sent through this media route. | |
| 47 // May be missing if route is not local. | |
| 48 // Optional. | |
| 49 string? media_source; | |
|
xhwang
2015/04/27 17:52:02
Is this an id or a name?
Kevin Marshall
2015/04/27 19:23:51
Done.
| |
| 50 // The ID of the sink receiving the media. | |
| 51 // e.g. "rs71w7mFzYLFlabir_qO4NHl6SUc." | |
| 52 // Required. | |
| 53 string sink_id; | |
| 54 // Human readable name of the sink. | |
| 55 string? sink_name; | |
|
xhwang
2015/04/27 17:52:02
In MediaSink, both id and name are required. But h
Kevin Marshall
2015/04/27 19:23:51
Good catch. In the past there was a call that retu
| |
| 56 // Human readable description of this route, e.g. | |
| 57 // "Tab casting". | |
| 58 // Required. | |
| 59 string description; | |
| 60 // An icon that is associated with this media source. | |
| 61 // Optional. | |
| 62 string? icon_url; | |
| 63 // Specifies that the route is requested locally. | |
| 64 // Required. | |
| 65 bool is_local; | |
| 66 }; | |
| 67 | |
| 68 // Issue created by a media route provider and shown to the user. | |
|
xhwang
2015/04/27 17:52:02
nit: Could you please define "issue"?
Kevin Marshall
2015/04/27 19:23:51
Done.
| |
| 69 // When is_blocking is true, media router UI shows issue only: | |
| 70 // | |
| 71 // Title | |
| 72 // Message | |
| 73 // default_action_button secondary_action_button | |
| 74 // | |
| 75 // When is_blocking is false, media router UI uses banner: | |
| 76 // | |
| 77 // Title default_action_link secondary_action_link | |
| 78 // | |
| 79 // above receiver list if route_id is not provided; otherwise it is | |
| 80 // above route detail and controls. | |
|
xhwang
2015/04/27 17:52:02
hmm, seems like these are just UI implementation d
Kevin Marshall
2015/04/27 19:23:51
Done.
| |
| 81 struct Issue { | |
| 82 enum Severity { | |
| 83 FATAL, | |
| 84 WARNING, | |
| 85 NOTIFICATION | |
| 86 }; | |
| 87 | |
| 88 enum ActionType { | |
| 89 OK, | |
| 90 CANCEL, | |
| 91 DISMISS, | |
| 92 LEARN_MORE | |
| 93 }; | |
| 94 | |
| 95 // If set, the ID of the route to which this issue pertains. | |
| 96 // If not set (default), then this is a global issue. | |
| 97 // Optional | |
| 98 string? route_id; | |
| 99 | |
| 100 // Required | |
| 101 Severity severity; | |
| 102 | |
| 103 // When true, this issue takes the whole dialog. | |
| 104 // Required | |
| 105 bool is_blocking; | |
| 106 | |
| 107 // Short description about the issue. | |
| 108 // Required. | |
| 109 string title; | |
| 110 | |
| 111 // Message about issue detail or how to handle issue. | |
| 112 // Messages should be suitable for end users to decide which actions to take. | |
| 113 // Optional | |
| 114 string? message; | |
| 115 | |
| 116 // Required | |
| 117 ActionType default_action; | |
| 118 | |
| 119 // Optional | |
| 120 array<ActionType>? secondary_actions; | |
| 121 | |
| 122 // A help page to be opened if users select learn_more. | |
| 123 // Optional | |
| 124 string? help_url; | |
| 125 }; | |
| 126 | |
| 127 // Interface for sending messages from the MediaRouter (MR) | |
| 128 // to the Media Router client. For the component extension, this is the Media | |
|
xhwang
2015/04/27 17:52:01
ditto about "extension" is implementation detail.
Kevin Marshall
2015/04/27 19:23:51
Done.
| |
| 129 // Route Provider Manager (MRPM). | |
| 130 interface ProviderManagerService { | |
| 131 // Signals the client to route the media located | |
| 132 // at |source_urn| to |sink_id|. | |
|
xhwang
2015/04/27 17:52:02
What's the relationship between this |source_run|
Kevin Marshall
2015/04/27 19:23:51
The same thing.
Fixed everywhere: s/source_urn/me
| |
| 133 // If the operation was successful, |route| will be defined and | |
| 134 // |error_text| will be null. | |
| 135 // If the operation failed, |route| will be null and |error_text| | |
| 136 // will be set. | |
| 137 CreateRoute(string source, string sink_id) => | |
| 138 (MediaRoute? route, string? error_text); | |
| 139 | |
| 140 // Signals the client to join an established route given by |presentation_id| | |
| 141 // with media located at |source_urn|. |origin| and |tab_id| are used for | |
| 142 // enforcing same origin/tab scopes. | |
| 143 // Returns the route on success. Otherwise an error message is returned. | |
| 144 JoinRoute(string source_urn, | |
| 145 string presentation_id, | |
| 146 string origin, | |
| 147 int64 tab_id) => (MediaRoute? route, string? error_text); | |
| 148 | |
| 149 // Signals the client to close the route specified by |route_id|. | |
| 150 CloseRoute(string route_id); | |
|
xhwang
2015/04/27 17:52:01
hmm... With CreateRoute/JoinRoute/CloseRoute/PostM
Kevin Marshall
2015/04/27 19:23:51
I agree that the methods are the same as the Media
xhwang
2015/04/28 06:08:18
Client is still pretty popular in the mojo world.
Kevin M
2015/04/28 17:20:29
Done.
| |
| 151 | |
| 152 // Sends |message| with optional |extra_info_json| via the media route | |
| 153 // |media_route_id|. | |
| 154 PostMessage(string media_route_id, string message); | |
| 155 | |
| 156 // Signals the client to start querying for sinks | |
| 157 // capable of displaying |source_urn|. | |
| 158 StartObservingMediaSinks(string source_urn); | |
| 159 | |
| 160 // Signals the client to stop querying for sinks | |
| 161 // capable of displaying |source_urn|. | |
| 162 StopObservingMediaSinks(string source_urn); | |
| 163 | |
| 164 // Signals the to start a query on all routes. Updates are received from | |
| 165 // |OnRoutesUpdated()|. | |
| 166 StartObservingMediaRoutes(); | |
| 167 | |
| 168 // Signals the to stop query on all routes. | |
| 169 StopObservingMediaRoutes(); | |
| 170 | |
| 171 // "Clears" an issue after it has been processed. | |
| 172 ClearIssue(string issue_id); | |
| 173 }; | |
| 174 | |
| 175 // Interface for sending messages from the client to the MR. | |
| 176 interface MediaRouterApi { | |
|
xhwang
2015/04/27 17:52:02
Just MediaRouter? You have nested namespace so the
Kevin Marshall
2015/04/27 19:23:51
Done.
| |
| 177 // Sets a service object for issuing calls back to the MRPM. | |
| 178 // Returns a string that uniquely identifies the Media Router browser | |
| 179 // process. | |
| 180 SetProviderManagerService(ProviderManagerService observer) => | |
| 181 (string instance_id); | |
|
xhwang
2015/04/27 17:52:02
See naming comment above. In mojo, usually we have
Kevin Marshall
2015/04/27 19:23:51
I'm unsure if "Client" is useful in this case, bec
xhwang
2015/04/28 06:08:18
Ack. But from API's perspective, this is confusing
Kevin M
2015/04/28 17:20:29
Done.
| |
| 182 | |
| 183 // Called when the Media Route Manager receives a new list of sinks. | |
| 184 OnSinksReceived(string source_urn, array<MediaSink> sinks); | |
| 185 | |
| 186 // Called when the Media Route Manager receives a route message. | |
| 187 OnMessage(string source_urn, string message); | |
| 188 | |
| 189 // Called when providers send an issue. | |
| 190 OnIssue(Issue issue); | |
| 191 | |
| 192 // Called when list of routes has been updated. | |
| 193 OnRoutesUpdated(array<MediaRoute> routes); | |
| 194 }; | |
| OLD | NEW |