OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <ostream> | 10 #include <ostream> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/hash.h" | 13 #include "base/hash.h" |
14 | 14 |
| 15 class GURL; |
| 16 |
| 17 // TODO(mfoltz): Right now this is a wrapper for std::string. Factor methods |
| 18 // from media_source_helper here so this object becomes useful; and don't just |
| 19 // pass it around by Id. |
15 namespace media_router { | 20 namespace media_router { |
16 | 21 |
17 | |
18 class MediaSource { | 22 class MediaSource { |
19 public: | 23 public: |
20 using Id = std::string; | 24 using Id = std::string; |
21 | 25 |
22 explicit MediaSource(const MediaSource::Id& id); | 26 explicit MediaSource(const MediaSource::Id& id); |
| 27 explicit MediaSource(const GURL& presentation_url); |
23 ~MediaSource(); | 28 ~MediaSource(); |
24 | 29 |
25 // Gets the ID of the media source. | 30 // Gets the ID of the media source. |
26 MediaSource::Id id() const; | 31 MediaSource::Id id() const; |
27 | 32 |
28 // Returns true if two MediaSource objects use the same media ID. | 33 // Returns true if two MediaSource objects use the same media ID. |
29 bool operator==(const MediaSource& other) const; | 34 bool operator==(const MediaSource& other) const; |
30 | 35 |
31 // Used for logging. | 36 // Used for logging. |
32 std::string ToString() const; | 37 std::string ToString() const; |
33 | 38 |
34 // Hash operator for hash containers. | 39 // Hash operator for hash containers. |
35 struct Hash { | 40 struct Hash { |
36 size_t operator()(const MediaSource& source) const { | 41 size_t operator()(const MediaSource& source) const { |
37 return base::Hash(source.id()); | 42 return base::Hash(source.id()); |
38 } | 43 } |
39 }; | 44 }; |
40 | 45 |
41 private: | 46 private: |
42 MediaSource::Id id_; | 47 MediaSource::Id id_; |
43 }; | 48 }; |
44 | 49 |
45 } // namespace media_router | 50 } // namespace media_router |
46 | 51 |
47 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ | 52 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ |
OLD | NEW |