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

Side by Side Diff: ppapi/proxy/pdf_resource.cc

Issue 13004012: Implement the host side of the PPB_PDF proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 8 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
« no previous file with comments | « ppapi/ppapi_sources.gypi ('k') | ppapi/proxy/pdf_resource_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 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 #include "ppapi/proxy/pdf_resource.h" 5 #include "ppapi/proxy/pdf_resource.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 IPC::Message reply; 157 IPC::Message reply;
158 ResourceMessageReplyParams reply_params; 158 ResourceMessageReplyParams reply_params;
159 int32_t result = GenericSyncCall( 159 int32_t result = GenericSyncCall(
160 RENDERER, PpapiHostMsg_PDF_GetResourceImage(image_id, scale), &reply, 160 RENDERER, PpapiHostMsg_PDF_GetResourceImage(image_id, scale), &reply,
161 &reply_params); 161 &reply_params);
162 if (result != PP_OK) 162 if (result != PP_OK)
163 return 0; 163 return 0;
164 164
165 HostResource resource; 165 HostResource resource;
166 std::string image_data_desc; 166 std::string image_data_desc;
167 int fd;
167 if (!UnpackMessage<PpapiPluginMsg_PDF_GetResourceImageReply>( 168 if (!UnpackMessage<PpapiPluginMsg_PDF_GetResourceImageReply>(
168 reply, &resource, &image_data_desc)) { 169 reply, &resource, &image_data_desc, &fd)) {
169 return 0; 170 return 0;
170 } 171 }
171 172
172 if (resource.is_null() || image_data_desc.size() != sizeof(PP_ImageDataDesc)) 173 if (resource.is_null() || image_data_desc.size() != sizeof(PP_ImageDataDesc))
173 return 0; 174 return 0;
174 175
175 // We serialize the PP_ImageDataDesc just by copying to a string. 176 // We serialize the PP_ImageDataDesc just by copying to a string.
176 PP_ImageDataDesc desc; 177 PP_ImageDataDesc desc;
177 memcpy(&desc, image_data_desc.data(), sizeof(PP_ImageDataDesc)); 178 memcpy(&desc, image_data_desc.data(), sizeof(PP_ImageDataDesc));
178 179
179 base::SharedMemoryHandle handle;
180 if (!reply_params.TakeSharedMemoryHandleAtIndex(0, &handle))
181 return 0;
182 // We always succeed after this point (on non-android platforms, so we don't
183 // have to worry about leaking |handle|.
184
185 #if defined(OS_ANDROID) 180 #if defined(OS_ANDROID)
186 // This is compiled into android for tests only. 181 // This is compiled into android for tests only.
187 return 0; 182 return 0;
188 #elif defined(OS_WIN) || defined(OS_MACOSX) 183 #elif defined(OS_WIN) || defined(OS_MACOSX)
184 base::SharedMemoryHandle handle;
185 if (!reply_params.TakeSharedMemoryHandleAtIndex(0, &handle))
186 return 0;
189 return (new ImageData(resource, desc, handle))->GetReference(); 187 return (new ImageData(resource, desc, handle))->GetReference();
188 #elif defined(OS_LINUX)
189 return (new ImageData(resource, desc, fd))->GetReference();
190 #else 190 #else
191 return (new ImageData(resource, desc, handle.fd))->GetReference(); 191 #error Not implemented.
192 #endif 192 #endif
193 } 193 }
194 194
195 PP_Resource PDFResource::GetResourceImage(PP_ResourceImage image_id) { 195 PP_Resource PDFResource::GetResourceImage(PP_ResourceImage image_id) {
196 return GetResourceImageForScale(image_id, 1.0f); 196 return GetResourceImageForScale(image_id, 1.0f);
197 } 197 }
198 198
199 } // namespace proxy 199 } // namespace proxy
200 } // namespace ppapi 200 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/ppapi_sources.gypi ('k') | ppapi/proxy/pdf_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698