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 = socket_observer_map_.find(id); |
| 57 return it == socket_observer_map_.end() ? nullptr : it->second.get(); |
| 58 } |
| 59 |
| 60 CastSocket::Observer* CastSocketService::AddObserver( |
| 61 const std::string& id, |
| 62 std::unique_ptr<CastSocket::Observer> observer) { |
| 63 CastSocket::Observer* observer_ptr = observer.get(); |
| 64 socket_observer_map_.insert(std::make_pair(id, std::move(observer))); |
| 65 return observer_ptr; |
| 66 } |
| 67 |
55 void CastSocketService::ShutdownOnUIThread() {} | 68 void CastSocketService::ShutdownOnUIThread() {} |
56 | 69 |
57 } // namespace cast_channel | 70 } // namespace cast_channel |
OLD | NEW |