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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <ostream> | 10 #include <ostream> |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 explicit MediaSource(const MediaSource::Id& id); | 22 explicit MediaSource(const MediaSource::Id& id); |
| 23 MediaSource(); | 23 MediaSource(); |
| 24 ~MediaSource(); | 24 ~MediaSource(); |
| 25 | 25 |
| 26 // Gets the ID of the media source. | 26 // Gets the ID of the media source. |
| 27 MediaSource::Id id() const; | 27 MediaSource::Id id() const; |
| 28 | 28 |
| 29 // Returns true if two MediaSource objects use the same media ID. | 29 // Returns true if two MediaSource objects use the same media ID. |
| 30 bool Equals(const MediaSource& other) const; | 30 bool Equals(const MediaSource& other) const; |
| 31 | 31 |
| 32 bool operator==(const MediaSource& other) const; | |
|
mark a. foltz
2016/08/31 05:18:54
Why do we need both == and Equals?
takumif
2016/09/01 21:09:25
Got rid of Equals().
| |
| 33 | |
| 32 // Returns true if a MediaSource is empty or uninitialized. | 34 // Returns true if a MediaSource is empty or uninitialized. |
| 33 bool Empty() const; | 35 bool Empty() const; |
| 34 | 36 |
| 35 // Used for logging. | 37 // Used for logging. |
| 36 std::string ToString() const; | 38 std::string ToString() const; |
| 37 | 39 |
| 38 // Hash operator for hash containers. | 40 // Hash operator for hash containers. |
| 39 struct Hash { | 41 struct Hash { |
| 40 size_t operator()(const MediaSource& source) const { | 42 size_t operator()(const MediaSource& source) const { |
| 41 return base::Hash(source.id()); | 43 return base::Hash(source.id()); |
| 42 } | 44 } |
| 43 }; | 45 }; |
| 44 | 46 |
| 47 // For storing in sets and in maps as keys. | |
| 48 struct Compare { | |
| 49 bool operator()(const MediaSource& source1, | |
| 50 const MediaSource& source2) const { | |
| 51 return source1.id() < source2.id(); | |
| 52 } | |
| 53 }; | |
| 54 | |
| 45 private: | 55 private: |
| 46 MediaSource::Id id_; | 56 MediaSource::Id id_; |
| 47 }; | 57 }; |
| 48 | 58 |
| 49 } // namespace media_router | 59 } // namespace media_router |
| 50 | 60 |
| 51 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ | 61 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ |
| OLD | NEW |