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 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_RESPONSE_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_RESPONSE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "chrome/browser/media/router/media_route.h" | |
| 12 | |
| 13 namespace media_router { | |
| 14 | |
| 15 // Response from the media route provider to a media route request. | |
| 16 class MediaRouteResponse { | |
| 17 public: | |
| 18 // Creates a MediaRouteResponse object that indicates success. | |
| 19 // |request_id|: ID of original request. | |
| 20 // |route|: Route created. | |
| 21 static scoped_ptr<MediaRouteResponse> CreateFromSuccess( | |
| 22 const RouteRequestId& request_id, | |
| 23 const MediaRoute& route); | |
| 24 | |
| 25 // Creates a MediaRouteResponse object that indicates failure. | |
| 26 // |request_id|: ID of original request. | |
| 27 // |error|: Failure reason. | |
| 28 static scoped_ptr<MediaRouteResponse> CreateFromError( | |
| 29 const RouteRequestId& request_id, | |
| 30 const std::string& error); | |
| 31 | |
| 32 ~MediaRouteResponse(); | |
| 33 | |
| 34 const RouteRequestId& request_id() const { return request_id_; } | |
| 35 | |
| 36 // Returns the route created, or nullptr if there was an error. | |
| 37 const MediaRoute* route() const { return route_.get(); } | |
| 38 | |
| 39 // Returns the error, or an empty string if the route was created | |
| 40 // successfully. | |
| 41 const std::string& error() const { return error_; } | |
| 42 | |
| 43 private: | |
| 44 MediaRouteResponse(const RouteRequestId& request_id, const MediaRoute& route); | |
| 45 MediaRouteResponse(const RouteRequestId& request_id, | |
| 46 const std::string& error); | |
| 47 | |
| 48 // ID of original request. Set in all MediaRouteResponse objects, regardless | |
| 49 // of success/failure. | |
| 50 const RouteRequestId request_id_; | |
| 51 const scoped_ptr<MediaRoute> route_; | |
| 52 const std::string error_; | |
|
xhwang
2015/04/06 20:51:31
DISALLOW_COPY_AND_ASSIGN?
imcheng
2015/04/06 21:54:20
Done.
| |
| 53 }; | |
| 54 | |
| 55 } // namespace media_router | |
| 56 | |
| 57 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_RESPONSE_H_ | |
| OLD | NEW |