Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/media/router/media_source.h

Issue 1693963003: Pass origin to StartObservingMediaSinks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Marks Review Fixes with URL changes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 origin() const;
31
32 // Sets the origin of the media source.
33 void set_origin(std::string origin);
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. 44 bool operator==(const MediaSource& other) const;
39 struct Hash { 45 bool operator<(const MediaSource& other) const;
40 size_t operator()(const MediaSource& source) const {
41 return base::Hash(source.id());
42 }
43 };
44 46
45 private: 47 private:
46 MediaSource::Id id_; 48 MediaSource::Id id_;
49 std::string origin_;
47 }; 50 };
48 51
49 } // namespace media_router 52 } // namespace media_router
50 53
54 namespace std {
55 template <> struct hash<media_router::MediaSource> {
56 size_t operator () (const media_router::MediaSource &m) const {
57 return base::HashInts32(base::Hash(m.id()),
58 base::Hash(m.origin()));
59 }
60 };
61 }
62
51 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ 63 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_sinks_observer.h ('k') | chrome/browser/media/router/media_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698