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

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

Issue 304513007: Remove PlatformFile from ppapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/proxy/file_mapping_resource.h ('k') | ppapi/proxy/file_mapping_resource_posix.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/file_mapping_resource.h" 5 #include "ppapi/proxy/file_mapping_resource.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 23 matching lines...) Expand all
34 uint32_t protection, 34 uint32_t protection,
35 uint32_t flags, 35 uint32_t flags,
36 int64_t offset, 36 int64_t offset,
37 void** address, 37 void** address,
38 scoped_refptr<TrackedCallback> callback) { 38 scoped_refptr<TrackedCallback> callback) {
39 thunk::EnterResourceNoLock<thunk::PPB_FileIO_API> enter(file_io, true); 39 thunk::EnterResourceNoLock<thunk::PPB_FileIO_API> enter(file_io, true);
40 if (enter.failed()) 40 if (enter.failed())
41 return PP_ERROR_BADARGUMENT; 41 return PP_ERROR_BADARGUMENT;
42 FileIOResource* file_io_resource = 42 FileIOResource* file_io_resource =
43 static_cast<FileIOResource*>(enter.object()); 43 static_cast<FileIOResource*>(enter.object());
44 scoped_refptr<FileIOResource::FileHandleHolder> file_handle = 44 scoped_refptr<FileIOResource::FileHolder> file_holder =
45 file_io_resource->file_handle(); 45 file_io_resource->file_holder();
46 if (!FileIOResource::FileHandleHolder::IsValid(file_handle)) 46 if (!FileIOResource::FileHolder::IsValid(file_holder))
47 return PP_ERROR_FAILED; 47 return PP_ERROR_FAILED;
48 if (length < 0 || offset < 0 || 48 if (length < 0 || offset < 0 ||
49 !base::IsValueInRangeForNumericType<off_t>(offset)) { 49 !base::IsValueInRangeForNumericType<off_t>(offset)) {
50 return PP_ERROR_BADARGUMENT; 50 return PP_ERROR_BADARGUMENT;
51 } 51 }
52 if (!base::IsValueInRangeForNumericType<size_t>(length)) { 52 if (!base::IsValueInRangeForNumericType<size_t>(length)) {
53 return PP_ERROR_NOMEMORY; 53 return PP_ERROR_NOMEMORY;
54 } 54 }
55 55
56 // Ensure any bits we don't recognize are zero. 56 // Ensure any bits we don't recognize are zero.
(...skipping 11 matching lines...) Expand all
68 return PP_ERROR_BADARGUMENT; 68 return PP_ERROR_BADARGUMENT;
69 // Ensure at most one of SHARED and PRIVATE is set. 69 // Ensure at most one of SHARED and PRIVATE is set.
70 if ((flags & PP_FILEMAPFLAG_SHARED) && 70 if ((flags & PP_FILEMAPFLAG_SHARED) &&
71 (flags & PP_FILEMAPFLAG_PRIVATE)) { 71 (flags & PP_FILEMAPFLAG_PRIVATE)) {
72 return PP_ERROR_BADARGUMENT; 72 return PP_ERROR_BADARGUMENT;
73 } 73 }
74 if (!address) 74 if (!address)
75 return PP_ERROR_BADARGUMENT; 75 return PP_ERROR_BADARGUMENT;
76 76
77 base::Callback<MapResult()> map_cb( 77 base::Callback<MapResult()> map_cb(
78 base::Bind(&FileMappingResource::DoMapBlocking, file_handle, *address, 78 base::Bind(&FileMappingResource::DoMapBlocking, file_holder, *address,
79 length, protection, flags, offset)); 79 length, protection, flags, offset));
80 if (callback->is_blocking()) { 80 if (callback->is_blocking()) {
81 // The plugin could release its reference to this instance when we release 81 // The plugin could release its reference to this instance when we release
82 // the proxy lock below. 82 // the proxy lock below.
83 scoped_refptr<FileMappingResource> protect(this); 83 scoped_refptr<FileMappingResource> protect(this);
84 MapResult map_result; 84 MapResult map_result;
85 { 85 {
86 // Release the proxy lock while making a potentially slow file call. 86 // Release the proxy lock while making a potentially slow file call.
87 ProxyAutoUnlock unlock; 87 ProxyAutoUnlock unlock;
88 map_result = map_cb.Run(); 88 map_result = map_cb.Run();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return; 151 return;
152 } 152 }
153 if (map_result.result == PP_OK) 153 if (map_result.result == PP_OK)
154 *mapped_address_out_param = map_result.address; 154 *mapped_address_out_param = map_result.address;
155 if (!callback->is_blocking()) 155 if (!callback->is_blocking())
156 callback->Run(map_result.result); 156 callback->Run(map_result.result);
157 } 157 }
158 158
159 } // namespace proxy 159 } // namespace proxy
160 } // namespace ppapi 160 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/file_mapping_resource.h ('k') | ppapi/proxy/file_mapping_resource_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698