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

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

Issue 1020743003: [Media Router] Design MediaRouter interface with stub implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile Created 5 years, 8 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 <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 // Used for logging.
31 std::string ToString() const;
19 32
20 private: 33 private:
21 std::string id_; 34 MediaSourceId id_;
35 };
36
37 // Inequality comparison functor to provide map lookup capabilities for
38 // MediaSource.
39 class MediaSourceLess {
40 public:
41 bool operator()(const MediaSource& lhs, const MediaSource& rhs) const {
42 return lhs.id() < rhs.id();
xhwang 2015/04/06 20:51:31 Comparing strings isn't efficient. Consider using
imcheng 2015/04/06 21:54:20 Replaced this class with a struct Hash.
43 }
22 }; 44 };
23 45
24 } // namespace media_router 46 } // namespace media_router
25 47
26 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_ 48 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698