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

Side by Side Diff: ppapi/proxy/serialized_handle.h

Issue 11894003: PPAPI/NaCl: Move handle extraction code to ppapi/proxy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 PPAPI_PROXY_SERIALIZED_STRUCTS_H_ 5 #ifndef PPAPI_PROXY_SERIALIZED_HANDLES_H_
6 #define PPAPI_PROXY_SERIALIZED_STRUCTS_H_ 6 #define PPAPI_PROXY_SERIALIZED_HANDLES_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/shared_memory.h" 12 #include "base/shared_memory.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "ipc/ipc_platform_file.h" 14 #include "ipc/ipc_platform_file.h"
15 #include "ppapi/c/pp_bool.h"
16 #include "ppapi/c/pp_instance.h"
17 #include "ppapi/c/pp_point.h"
18 #include "ppapi/c/pp_rect.h"
19 #include "ppapi/proxy/ppapi_proxy_export.h" 15 #include "ppapi/proxy/ppapi_proxy_export.h"
20 #include "ppapi/shared_impl/host_resource.h"
21 16
22 class Pickle; 17 class Pickle;
23 struct PP_FontDescription_Dev;
24 struct PP_BrowserFont_Trusted_Description;
25 18
26 namespace ppapi { 19 namespace ppapi {
27 namespace proxy { 20 namespace proxy {
28 21
29 // PP_FontDescription_Dev/PP_BrowserFontDescription (same definition, different 22 // SerializedHandle is a unified structure for holding a handle (e.g., a shared
30 // names) has to be redefined with a string in place of the PP_Var used for the 23 // memory handle, socket descriptor, etc). This is useful for passing handles in
31 // face name. 24 // resource messages and also makes it easier to translate handles in
32 struct PPAPI_PROXY_EXPORT SerializedFontDescription { 25 // NaClIPCAdapter for use in NaCl.
33 SerializedFontDescription();
34 ~SerializedFontDescription();
35
36 // Converts a PP_FontDescription_Dev to a SerializedFontDescription.
37 //
38 // The reference of |face| owned by the PP_FontDescription_Dev will be
39 // unchanged and the caller is responsible for freeing it.
40 void SetFromPPFontDescription(const PP_FontDescription_Dev& desc);
41 void SetFromPPBrowserFontDescription(
42 const PP_BrowserFont_Trusted_Description& desc);
43
44 // Converts to a PP_FontDescription_Dev. The face name will have one ref
45 // assigned to it. The caller is responsible for freeing it.
46 void SetToPPFontDescription(PP_FontDescription_Dev* desc) const;
47 void SetToPPBrowserFontDescription(
48 PP_BrowserFont_Trusted_Description* desc) const;
49
50 std::string face;
51 int32_t family;
52 uint32_t size;
53 int32_t weight;
54 PP_Bool italic;
55 PP_Bool small_caps;
56 int32_t letter_spacing;
57 int32_t word_spacing;
58 };
59
60 struct SerializedDirEntry {
61 std::string name;
62 bool is_dir;
63 };
64
65 struct PPAPI_PROXY_EXPORT PPBFlash_DrawGlyphs_Params {
66 PPBFlash_DrawGlyphs_Params();
67 ~PPBFlash_DrawGlyphs_Params();
68
69 PP_Instance instance;
70 ppapi::HostResource image_data;
71 SerializedFontDescription font_desc;
72 uint32_t color;
73 PP_Point position;
74 PP_Rect clip;
75 float transformation[3][3];
76 PP_Bool allow_subpixel_aa;
77 std::vector<uint16_t> glyph_indices;
78 std::vector<PP_Point> glyph_advances;
79 };
80
81 struct PPBURLLoader_UpdateProgress_Params {
82 PP_Instance instance;
83 ppapi::HostResource resource;
84 int64_t bytes_sent;
85 int64_t total_bytes_to_be_sent;
86 int64_t bytes_received;
87 int64_t total_bytes_to_be_received;
88 };
89
90 // We put all our handles in a unified structure to make it easy to translate
91 // them in NaClIPCAdapter for use in NaCl.
92 class PPAPI_PROXY_EXPORT SerializedHandle { 26 class PPAPI_PROXY_EXPORT SerializedHandle {
93 public: 27 public:
94 enum Type { INVALID, SHARED_MEMORY, SOCKET, CHANNEL_HANDLE, FILE }; 28 enum Type { INVALID, SHARED_MEMORY, SOCKET, CHANNEL_HANDLE, FILE };
95 struct Header { 29 struct Header {
96 Header() : type(INVALID), size(0) {} 30 Header() : type(INVALID), size(0) {}
97 Header(Type type_arg, uint32_t size_arg) 31 Header(Type type_arg, uint32_t size_arg)
98 : type(type_arg), size(size_arg) { 32 : type(type_arg), size(size_arg) {
99 } 33 }
100 Type type; 34 Type type;
101 uint32_t size; 35 uint32_t size;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // we add more complex things later, we should come up with a more memory- 127 // we add more complex things later, we should come up with a more memory-
194 // efficient strategy. 128 // efficient strategy.
195 // These are valid if type == SHARED_MEMORY. 129 // These are valid if type == SHARED_MEMORY.
196 base::SharedMemoryHandle shm_handle_; 130 base::SharedMemoryHandle shm_handle_;
197 uint32_t size_; 131 uint32_t size_;
198 132
199 // This is valid if type == SOCKET || type == CHANNEL_HANDLE. 133 // This is valid if type == SOCKET || type == CHANNEL_HANDLE.
200 IPC::PlatformFileForTransit descriptor_; 134 IPC::PlatformFileForTransit descriptor_;
201 }; 135 };
202 136
203 struct PPPDecryptor_Buffer {
204 ppapi::HostResource resource;
205 uint32_t size;
206 base::SharedMemoryHandle handle;
207 };
208
209 #if defined(OS_WIN)
210 typedef HANDLE ImageHandle;
211 #elif defined(OS_MACOSX) || defined(OS_ANDROID)
212 typedef base::SharedMemoryHandle ImageHandle;
213 #else
214 // On X Windows this is a SysV shared memory key.
215 typedef int ImageHandle;
216 #endif
217
218 } // namespace proxy 137 } // namespace proxy
219 } // namespace ppapi 138 } // namespace ppapi
220 139
221 #endif // PPAPI_PROXY_SERIALIZED_STRUCTS_H_ 140 #endif // PPAPI_PROXY_SERIALIZED_HANDLES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698