Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Side by Side Diff: ppapi/proxy/content_decryptor_private_serializer-inl.h

Issue 10854209: Modify the PPAPI CDM interface to pass more info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
Tom Finegan 2012/08/20 21:31:45 Two questions about this file: 1) Is this file sm
dmichael (off chromium) 2012/08/21 17:37:08 Yeah, we don't use the -inl suffix anywhere else i
Tom Finegan 2012/08/21 22:57:38 Done.
5 #ifndef PPAPI_PROXY_CONTENT_DECRYPTOR_PRIVATE_SERIALIZER_INL_H_
6 #define PPAPI_PROXY_CONTENT_DECRYPTOR_PRIVATE_SERIALIZER_INL_H_
7
8 #include <cstring>
9 #include <string>
10
11 #include "ppapi/c/private/pp_content_decryptor.h"
12
13 namespace ppapi {
14 namespace proxy {
15
16 // Serialization/deserialization utility functions for storing/extracting
17 // PP_{De|En}cryptedBlockInfo structs within std::string's for passing through
18 // IPC. Return true upon success, and false upon failure.
xhwang 2012/08/20 22:19:31 nit: Return+s+
Tom Finegan 2012/08/20 22:50:03 Done, but did s/Return/Both functions return/ inst
19 //
20 // Note, these functions check the size of |block_info| against the size of
21 // the "serialized" data stored within |serialized_block_info|, and will report
22 // failure if expectations are not met. Use of CHECK/DCHECK has been avoided
23 // because the functions are intended for use on both sides of the IPC proxy.
24
25 template <typename T>
26 bool SerializeBlockInfo(const T* block_info,
xhwang 2012/08/20 22:19:31 Google style strongly recommends passing const ref
Tom Finegan 2012/08/20 22:50:03 Done.
27 std::string* serialized_block_info) {
28 if (!block_info || !serialized_block_info)
29 return false;
30
31 if (serialized_block_info->size() != sizeof(T))
xhwang 2012/08/20 22:19:31 If we pass block_info as ref, we can use "sizeof(b
Tom Finegan 2012/08/20 22:50:03 Done/bug fixed.
32 return false;
33
34 serialized_block_info->assign(reinterpret_cast<const char*>(block_info),
35 sizeof(T));
36 return true;
37 }
38
39 template <typename T>
40 bool DeserializeBlockInfo(const std::string& serialized_block_info,
41 T* block_info) {
42 if (!block_info)
43 return false;
44
45 if (serialized_block_info.size() != sizeof(T))
46 return false;
47
48 std::memcpy(block_info, serialized_block_info.data(), sizeof(T));
49 return true;
50 }
51
52 } // namespace proxy
53 } // namespace ppapi
54
55 #endif // PPAPI_PROXY_CONTENT_DECRYPTOR_PRIVATE_SERIALIZER_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698