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 <ostream> | |
9 #include <string> | 8 #include <string> |
10 | 9 |
11 #include "base/hash.h" | |
12 | |
13 namespace media_router { | 10 namespace media_router { |
14 | 11 |
15 using MediaSourceId = std::string; | |
16 | |
17 class MediaSource { | 12 class MediaSource { |
18 public: | 13 public: |
19 explicit MediaSource(const MediaSourceId& id); | 14 explicit MediaSource(const std::string& id); |
20 MediaSource(); | |
21 ~MediaSource(); | 15 ~MediaSource(); |
22 | 16 |
23 // Gets the ID of the media source. | 17 // Gets the ID of the media source. |
24 MediaSourceId id() const; | 18 std::string id() const; |
25 | |
26 // Returns true if two MediaSource objects use the same media ID. | |
27 bool Equals(const MediaSource& other) const; | |
28 | |
29 // Returns true if a MediaSource is empty or uninitialized. | |
30 bool Empty() const; | |
31 | |
32 // Used for logging. | |
33 std::string ToString() const; | |
34 | |
35 // Hash operator for hash containers. | |
36 struct Hash { | |
37 size_t operator()(const MediaSource& source) const { | |
38 return base::Hash(source.id()); | |
39 } | |
40 }; | |
41 | 19 |
42 private: | 20 private: |
43 MediaSourceId id_; | 21 std::string id_; |
44 }; | 22 }; |
45 | 23 |
46 } // namespace media_router | 24 } // namespace media_router |
47 | 25 |
48 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ | 26 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ |
OLD | NEW |