1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef TEST_CDM_STORAGE_H__
7 #define TEST_CDM_STORAGE_H__
8 
9 #include <functional>
10 #include <string>
11 #include <vector>
12 // This include is required in order for content_decryption_module to work
13 // on Unix systems.
14 #include "stddef.h"
15 #include "content_decryption_module.h"
16 
17 #define IO_SUCCEEDED(x) ((x) == cdm::FileIOClient::Status::kSuccess)
18 #define IO_FAILED(x) ((x) != cdm::FileIOClient::Status::kSuccess)
19 
20 class ReadContinuation {
21  public:
22   virtual ~ReadContinuation() = default;
23   virtual void operator()(bool aSuccess, const uint8_t* aData,
24                           uint32_t aDataSize) = 0;
25 };
26 
27 void WriteRecord(cdm::Host_10* aHost, const std::string& aRecordName,
28                  const std::string& aData, std::function<void()>&& aOnSuccess,
29                  std::function<void()>&& aOnFailure);
30 
31 void WriteRecord(cdm::Host_10* aHost, const std::string& aRecordName,
32                  const uint8_t* aData, uint32_t aNumBytes,
33                  std::function<void()>&& aOnSuccess,
34                  std::function<void()>&& aOnFailure);
35 
36 void ReadRecord(
37     cdm::Host_10* aHost, const std::string& aRecordName,
38     std::function<void(bool, const uint8_t*, uint32_t)>&& aOnReadComplete);
39 
40 class OpenContinuation {
41  public:
42   virtual ~OpenContinuation() = default;
43   virtual void operator()(bool aSuccess) = 0;
44 };
45 
46 void OpenRecord(cdm::Host_10* aHost, const std::string& aRecordName,
47                 std::function<void(bool)>&& aOpenComplete);
48 #endif  // TEST_CDM_STORAGE_H__
49