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> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/hash.h" | 13 #include "base/hash.h" |
| 14 | 14 |
| 15 namespace media_router { | 15 namespace media_router { |
| 16 | 16 |
| 17 | 17 |
| 18 class MediaSource { | 18 class MediaSource { |
| 19 public: | 19 public: |
| 20 using Id = std::string; | 20 using Id = std::string; |
| 21 | 21 |
| 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 // Gets the origin of the media source. | |
| 30 std::string GetOrigin() const; | |
|
mark a. foltz
2016/03/03 22:58:36
origin() for simple getters
matt.boetger
2016/03/04 00:22:10
Done.
| |
| 31 | |
| 32 // Sets the origin of the media source. | |
| 33 void SetOrigin(std::string origin); | |
|
mark a. foltz
2016/03/03 22:58:36
set_origin() for simple setters
matt.boetger
2016/03/04 00:22:10
Done.
| |
| 34 | |
| 29 // Returns true if two MediaSource objects use the same media ID. | 35 // Returns true if two MediaSource objects use the same media ID. |
| 30 bool Equals(const MediaSource& other) const; | 36 bool Equals(const MediaSource& other) const; |
| 31 | 37 |
| 32 // Returns true if a MediaSource is empty or uninitialized. | 38 // Returns true if a MediaSource is empty or uninitialized. |
| 33 bool Empty() const; | 39 bool Empty() const; |
| 34 | 40 |
| 35 // Used for logging. | 41 // Used for logging. |
| 36 std::string ToString() const; | 42 std::string ToString() const; |
| 37 | 43 |
| 38 // Hash operator for hash containers. | |
| 39 struct Hash { | 44 struct Hash { |
| 40 size_t operator()(const MediaSource& source) const { | 45 size_t operator () (const media_router::MediaSource &m) const { |
| 41 return base::Hash(source.id()); | 46 return base::HashInts32(base::Hash(m.id()), |
| 47 base::Hash(m.GetOrigin())); | |
| 42 } | 48 } |
| 43 }; | 49 }; |
| 44 | 50 |
| 51 bool operator==(const MediaSource& other) const; | |
| 52 bool operator<(const MediaSource& other) const; | |
| 53 | |
| 45 private: | 54 private: |
| 46 MediaSource::Id id_; | 55 MediaSource::Id id_; |
| 56 std::string origin_; | |
| 47 }; | 57 }; |
| 48 | 58 |
| 49 } // namespace media_router | 59 } // namespace media_router |
| 50 | 60 |
| 61 namespace std { | |
| 62 template <> struct hash<media_router::MediaSource> { | |
| 63 size_t operator () (const media_router::MediaSource &m) const { | |
| 64 return base::HashInts32(base::Hash(m.id()), | |
| 65 base::Hash(m.GetOrigin())); | |
| 66 } | |
| 67 }; | |
| 68 } | |
| 69 | |
| 51 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ | 70 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ |
| OLD | NEW |