| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MEDIA_BASE_CDM_PROMISE_ADAPTER_H_ | 5 #ifndef MEDIA_BASE_CDM_PROMISE_ADAPTER_H_ |
| 6 #define MEDIA_BASE_CDM_PROMISE_ADAPTER_H_ | 6 #define MEDIA_BASE_CDM_PROMISE_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 uint32_t SavePromise(std::unique_ptr<media::CdmPromise> promise); | 29 uint32_t SavePromise(std::unique_ptr<media::CdmPromise> promise); |
| 30 | 30 |
| 31 // Takes the promise for |promise_id|, sanity checks its |type|, and resolves | 31 // Takes the promise for |promise_id|, sanity checks its |type|, and resolves |
| 32 // it with |result|. | 32 // it with |result|. |
| 33 template <typename... T> | 33 template <typename... T> |
| 34 void ResolvePromise(uint32_t promise_id, const T&... result); | 34 void ResolvePromise(uint32_t promise_id, const T&... result); |
| 35 | 35 |
| 36 // Takes the promise for |promise_id| and rejects it with |exception_code|, | 36 // Takes the promise for |promise_id| and rejects it with |exception_code|, |
| 37 // |system_code| and |error_message|. | 37 // |system_code| and |error_message|. |
| 38 void RejectPromise(uint32_t promise_id, | 38 void RejectPromise(uint32_t promise_id, |
| 39 MediaKeys::Exception exception_code, | 39 CdmPromise::Exception exception_code, |
| 40 uint32_t system_code, | 40 uint32_t system_code, |
| 41 const std::string& error_message); | 41 const std::string& error_message); |
| 42 | 42 |
| 43 // Rejects and clears all |promises_|. | 43 // Rejects and clears all |promises_|. |
| 44 void Clear(); | 44 void Clear(); |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 // A map between promise IDs and CdmPromises. It owns the CdmPromises. | 47 // A map between promise IDs and CdmPromises. It owns the CdmPromises. |
| 48 typedef base::ScopedPtrHashMap<uint32_t, std::unique_ptr<CdmPromise>> | 48 typedef base::ScopedPtrHashMap<uint32_t, std::unique_ptr<CdmPromise>> |
| 49 PromiseMap; | 49 PromiseMap; |
| 50 | 50 |
| 51 // Finds, takes the ownership of and returns the promise for |promise_id|. | 51 // Finds, takes the ownership of and returns the promise for |promise_id|. |
| 52 // Returns null if no promise can be found. | 52 // Returns null if no promise can be found. |
| 53 std::unique_ptr<CdmPromise> TakePromise(uint32_t promise_id); | 53 std::unique_ptr<CdmPromise> TakePromise(uint32_t promise_id); |
| 54 | 54 |
| 55 uint32_t next_promise_id_; | 55 uint32_t next_promise_id_; |
| 56 PromiseMap promises_; | 56 PromiseMap promises_; |
| 57 | 57 |
| 58 base::ThreadChecker thread_checker_; | 58 base::ThreadChecker thread_checker_; |
| 59 DISALLOW_COPY_AND_ASSIGN(CdmPromiseAdapter); | 59 DISALLOW_COPY_AND_ASSIGN(CdmPromiseAdapter); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 } // namespace media | 62 } // namespace media |
| 63 | 63 |
| 64 #endif // MEDIA_BASE_CDM_PROMISE_ADAPTER_H_ | 64 #endif // MEDIA_BASE_CDM_PROMISE_ADAPTER_H_ |
| OLD | NEW |