| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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_ROUTE_REQUEST_RESULT_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_ROUTE_REQUEST_RESULT_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "url/gurl.h" | |
| 13 | |
| 14 namespace media_router { | |
| 15 | |
| 16 class MediaRoute; | |
| 17 | |
| 18 // Holds the result of a successful or failed route request. | |
| 19 // On success: | |
| 20 // |route|: The route created or joined. | |
| 21 // |presentation_id|: | |
| 22 // The presentation ID of the route created or joined. In the case of | |
| 23 // |CreateRoute()|, the ID is generated by MediaRouter and is guaranteed to | |
| 24 // be unique. | |
| 25 // |error|: Empty string. | |
| 26 // |result_code|: RouteRequestResult::OK | |
| 27 // On failure: | |
| 28 // |route|: nullptr | |
| 29 // |presentation_id|: Empty string. | |
| 30 // |error|: Non-empty string describing the error. | |
| 31 // |result_code|: A value from RouteRequestResult describing the error. | |
| 32 class RouteRequestResult { | |
| 33 public: | |
| 34 // Keep in sync with: | |
| 35 // - RouteRequestResultCode in media_router.mojom | |
| 36 // - MediaRouteProviderResult enum in tools/metrics/histograms.xml | |
| 37 // - mr.RouteRequestResultCode in route_request_error.js | |
| 38 // - RouteRequestResultCodeFromMojo in media_router_type_converters.cc | |
| 39 enum ResultCode { | |
| 40 UNKNOWN_ERROR = 0, | |
| 41 OK = 1, | |
| 42 TIMED_OUT = 2, | |
| 43 ROUTE_NOT_FOUND = 3, | |
| 44 SINK_NOT_FOUND = 4, | |
| 45 INVALID_ORIGIN = 5, | |
| 46 INCOGNITO_MISMATCH = 6, | |
| 47 NO_SUPPORTED_PROVIDER = 7, | |
| 48 CANCELLED = 8, | |
| 49 // New values must be added here. | |
| 50 | |
| 51 TOTAL_COUNT = 9 // The total number of values. | |
| 52 }; | |
| 53 | |
| 54 static std::unique_ptr<RouteRequestResult> FromSuccess( | |
| 55 const MediaRoute& route, | |
| 56 const std::string& presentation_id); | |
| 57 static std::unique_ptr<RouteRequestResult> FromError(const std::string& error, | |
| 58 ResultCode result_code); | |
| 59 RouteRequestResult(std::unique_ptr<MediaRoute> route, | |
| 60 const std::string& presentation_id, | |
| 61 const std::string& error, | |
| 62 ResultCode result_code); | |
| 63 | |
| 64 ~RouteRequestResult(); | |
| 65 | |
| 66 // Note the caller does not own the returned MediaRoute. The caller must | |
| 67 // create a copy if they wish to use it after this object is destroyed. | |
| 68 const MediaRoute* route() const { return route_.get(); } | |
| 69 std::string presentation_id() const { return presentation_id_; } | |
| 70 GURL presentation_url() const { return presentation_url_; } | |
| 71 std::string error() const { return error_; } | |
| 72 ResultCode result_code() const { return result_code_; } | |
| 73 | |
| 74 private: | |
| 75 std::unique_ptr<MediaRoute> route_; | |
| 76 std::string presentation_id_; | |
| 77 GURL presentation_url_; | |
| 78 std::string error_; | |
| 79 ResultCode result_code_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(RouteRequestResult); | |
| 82 }; | |
| 83 | |
| 84 } // namespace media_router | |
| 85 | |
| 86 #endif // CHROME_BROWSER_MEDIA_ROUTER_ROUTE_REQUEST_RESULT_H_ | |
| OLD | NEW |