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 __ClearKeyStorage_h__
18 #define __ClearKeyStorage_h__
19 
20 #include <stdint.h>
21 
22 #include <functional>
23 #include <string>
24 #include <vector>
25 
26 #include "ClearKeySessionManager.h"
27 
28 #define IO_SUCCEEDED(x) ((x) == cdm::FileIOClient::Status::kSuccess)
29 #define IO_FAILED(x) ((x) != cdm::FileIOClient::Status::kSuccess)
30 
31 // Writes data to a file and fires the appropriate callback when complete.
32 void WriteData(cdm::Host_10* aHost, std::string& aRecordName,
33                const std::vector<uint8_t>& aData,
34                std::function<void()>&& aOnSuccess,
35                std::function<void()>&& aOnFailure);
36 
37 // Reads data from a file and fires the appropriate callback when complete.
38 void ReadData(cdm::Host_10* aHost, std::string& aRecordName,
39               std::function<void(const uint8_t*, uint32_t)>&& aOnSuccess,
40               std::function<void()>&& aOnFailure);
41 
42 #endif  // __ClearKeyStorage_h__
43