OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "components/cast_channel/cast_socket_service.h" | 5 #include "components/cast_channel/cast_socket_service.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 | 9 |
10 using content::BrowserThread; | 10 using content::BrowserThread; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 return socket; | 45 return socket; |
46 } | 46 } |
47 | 47 |
48 CastSocket* CastSocketService::GetSocket(int channel_id) const { | 48 CastSocket* CastSocketService::GetSocket(int channel_id) const { |
49 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); | 49 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
50 DCHECK(channel_id > 0); | 50 DCHECK(channel_id > 0); |
51 const auto& socket_it = sockets_.find(channel_id); | 51 const auto& socket_it = sockets_.find(channel_id); |
52 return socket_it == sockets_.end() ? nullptr : socket_it->second.get(); | 52 return socket_it == sockets_.end() ? nullptr : socket_it->second.get(); |
53 } | 53 } |
54 | 54 |
55 CastSocket::Observer* CastSocketService::GetObserver(const std::string& id) { | |
56 auto it = std::find_if( | |
57 socket_observer_map_.begin(), socket_observer_map_.end(), | |
58 [id](const std::pair<const std::string, | |
mark a. foltz
2017/06/20 01:16:43
Can the parameter passed to the lambda be const au
zhaobin
2017/06/20 17:50:05
Seems not.. Got ''auto' not allowed in lambda para
| |
59 std::unique_ptr<CastSocket::Observer>>& entry) { | |
60 return entry.first == id; | |
61 }); | |
62 return it == socket_observer_map_.end() ? nullptr : it->second.get(); | |
63 } | |
64 | |
65 void CastSocketService::AddObserver( | |
66 const std::string& id, | |
67 std::unique_ptr<CastSocket::Observer> observer) { | |
68 socket_observer_map_.insert(std::make_pair(id, std::move(observer))); | |
69 } | |
70 | |
55 void CastSocketService::ShutdownOnUIThread() {} | 71 void CastSocketService::ShutdownOnUIThread() {} |
56 | 72 |
57 } // namespace cast_channel | 73 } // namespace cast_channel |
OLD | NEW |