Chromium Code Reviews| 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> | |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 namespace media_router { | 11 namespace media_router { |
| 11 | 12 |
| 13 using MediaSourceId = std::string; | |
| 14 | |
| 12 class MediaSource { | 15 class MediaSource { |
| 13 public: | 16 public: |
| 14 explicit MediaSource(const std::string& id); | 17 explicit MediaSource(const MediaSourceId& id); |
| 18 MediaSource(); | |
| 15 ~MediaSource(); | 19 ~MediaSource(); |
| 16 | 20 |
| 17 // Gets the ID of the media source. | 21 // Gets the ID of the media source. |
| 18 std::string id() const; | 22 MediaSourceId id() const; |
| 23 | |
| 24 // Returns true if two MediaSource objects use the same media ID. | |
| 25 bool Equals(const MediaSource& other) const; | |
| 26 | |
| 27 // Returns true if a MediaSource is empty or uninitialized. | |
| 28 bool Empty() const; | |
| 29 | |
| 30 // Stream output, used for logging. | |
| 31 friend std::ostream& operator<<(std::ostream& output, | |
| 32 const MediaSource& source); | |
|
xhwang
2015/04/02 17:13:03
Operator overloading is not recommended:
https://g
imcheng
2015/04/02 23:05:24
Done.
| |
| 19 | 33 |
| 20 private: | 34 private: |
| 21 std::string id_; | 35 MediaSourceId id_; |
|
xhwang
2015/04/02 17:13:03
Do we plan to add more members to MeidaSource? Can
imcheng
2015/04/02 23:05:24
It is possible that we will add more fields to Med
| |
| 36 }; | |
| 37 | |
| 38 // Inequality comparison functor to provide map lookup capabilities for | |
| 39 // MediaSource. | |
| 40 class MediaSourceLess { | |
| 41 public: | |
| 42 bool operator()(const MediaSource& lhs, const MediaSource& rhs) const { | |
| 43 return lhs.id() < rhs.id(); | |
| 44 } | |
|
xhwang
2015/04/02 17:13:03
How will this be used?
imcheng
2015/04/02 23:05:24
It will be used in maps where MediaSource is used
xhwang
2015/04/06 20:51:30
Can you simply use MediaSource::id() as the key to
imcheng
2015/04/06 21:54:20
Perhaps we can do that, but we might add more comp
| |
| 22 }; | 45 }; |
| 23 | 46 |
| 24 } // namespace media_router | 47 } // namespace media_router |
| 25 | 48 |
| 26 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ | 49 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ |
| OLD | NEW |