tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ClearKeyPersistence.h (1780B)


      1 /*
      2 * Copyright 2015, Mozilla Foundation and contributors
      3 *
      4 * Licensed under the Apache License, Version 2.0 (the "License");
      5 * you may not use this file except in compliance with the License.
      6 * You may obtain a copy of the License at
      7 *
      8 * http://www.apache.org/licenses/LICENSE-2.0
      9 *
     10 * Unless required by applicable law or agreed to in writing, software
     11 * distributed under the License is distributed on an "AS IS" BASIS,
     12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 * See the License for the specific language governing permissions and
     14 * limitations under the License.
     15 */
     16 
     17 #ifndef __ClearKeyPersistence_h__
     18 #define __ClearKeyPersistence_h__
     19 
     20 // This include is required in order for content_decryption_module to work
     21 // on Unix systems.
     22 
     23 #include <functional>
     24 #include <set>
     25 #include <string>
     26 
     27 #include "RefCounted.h"
     28 #include "content_decryption_module.h"
     29 
     30 class ClearKeySessionManager;
     31 
     32 // Whether we've loaded the persistent session ids yet.
     33 enum PersistentKeyState { UNINITIALIZED, LOADING, LOADED };
     34 
     35 class ClearKeyPersistence : public RefCounted {
     36 public:
     37  explicit ClearKeyPersistence(cdm::Host_11* aHost);
     38 
     39  void EnsureInitialized(bool aPersistentStateAllowed,
     40                         std::function<void()>&& aOnInitialized);
     41 
     42  bool IsLoaded() const;
     43 
     44  std::string GetNewSessionId(cdm::SessionType aSessionType);
     45 
     46  bool IsPersistentSessionId(const std::string& aSid);
     47 
     48  void PersistentSessionRemoved(std::string& aSid);
     49 
     50 private:
     51  cdm::Host_11* mHost = nullptr;
     52 
     53  PersistentKeyState mPersistentKeyState = PersistentKeyState::UNINITIALIZED;
     54 
     55  std::set<uint32_t> mPersistentSessionIds;
     56 
     57  void ReadAllRecordsFromIndex(std::function<void()>&& aOnComplete);
     58  void WriteIndex();
     59 };
     60 
     61 #endif  // __ClearKeyPersistence_h__