1 /* 2 * Copyright 2022 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "modules/desktop_capture/linux/wayland/restore_token_manager.h" 12 13 namespace webrtc { 14 15 // static GetInstance()16RestoreTokenManager& RestoreTokenManager::GetInstance() { 17 static webrtc::RestoreTokenManager* manager = new RestoreTokenManager(); 18 return *manager; 19 } 20 AddToken(DesktopCapturer::SourceId id,const std::string & token)21void RestoreTokenManager::AddToken(DesktopCapturer::SourceId id, 22 const std::string& token) { 23 restore_tokens_.insert({id, token}); 24 } 25 TakeToken(DesktopCapturer::SourceId id)26std::string RestoreTokenManager::TakeToken(DesktopCapturer::SourceId id) { 27 std::string token = restore_tokens_[id]; 28 // Remove the token as it cannot be used anymore 29 restore_tokens_.erase(id); 30 return token; 31 } 32 GetUnusedId()33DesktopCapturer::SourceId RestoreTokenManager::GetUnusedId() { 34 return ++last_source_id_; 35 } 36 37 } // namespace webrtc 38