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

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

Issue 25328002: PPAPI: Remove instance param from GetFileTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | « content/renderer/pepper/host_globals.cc ('k') | ppapi/proxy/plugin_globals.h » ('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) 2012 The Chromium Authors. All rights reserved. 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 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_io_resource.h" 5 #include "ppapi/proxy/file_io_resource.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/task_runner_util.h" 8 #include "base/task_runner_util.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // Release the proxy lock while making a potentially slow file call. 147 // Release the proxy lock while making a potentially slow file call.
148 ProxyAutoUnlock unlock; 148 ProxyAutoUnlock unlock;
149 result = query_op->DoWork(); 149 result = query_op->DoWork();
150 } 150 }
151 return OnQueryComplete(query_op, info, result); 151 return OnQueryComplete(query_op, info, result);
152 } 152 }
153 153
154 // For the non-blocking case, post a task to the file thread and add a 154 // For the non-blocking case, post a task to the file thread and add a
155 // completion task to write the result. 155 // completion task to write the result.
156 base::PostTaskAndReplyWithResult( 156 base::PostTaskAndReplyWithResult(
157 PpapiGlobals::Get()->GetFileTaskRunner(pp_instance()), 157 PpapiGlobals::Get()->GetFileTaskRunner(),
158 FROM_HERE, 158 FROM_HERE,
159 Bind(&FileIOResource::QueryOp::DoWork, query_op), 159 Bind(&FileIOResource::QueryOp::DoWork, query_op),
160 RunWhileLocked(Bind(&TrackedCallback::Run, callback))); 160 RunWhileLocked(Bind(&TrackedCallback::Run, callback)));
161 callback->set_completion_task( 161 callback->set_completion_task(
162 Bind(&FileIOResource::OnQueryComplete, this, query_op, info)); 162 Bind(&FileIOResource::OnQueryComplete, this, query_op, info));
163 163
164 return PP_OK_COMPLETIONPENDING; 164 return PP_OK_COMPLETIONPENDING;
165 } 165 }
166 166
167 int32_t FileIOResource::Touch(PP_Time last_access_time, 167 int32_t FileIOResource::Touch(PP_Time last_access_time,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 { 310 {
311 // Release the proxy lock while making a potentially slow file call. 311 // Release the proxy lock while making a potentially slow file call.
312 ProxyAutoUnlock unlock; 312 ProxyAutoUnlock unlock;
313 result = read_op->DoWork(); 313 result = read_op->DoWork();
314 } 314 }
315 return OnReadComplete(read_op, array_output, result); 315 return OnReadComplete(read_op, array_output, result);
316 } 316 }
317 317
318 // For the non-blocking case, post a task to the file thread. 318 // For the non-blocking case, post a task to the file thread.
319 base::PostTaskAndReplyWithResult( 319 base::PostTaskAndReplyWithResult(
320 PpapiGlobals::Get()->GetFileTaskRunner(pp_instance()), 320 PpapiGlobals::Get()->GetFileTaskRunner(),
321 FROM_HERE, 321 FROM_HERE,
322 Bind(&FileIOResource::ReadOp::DoWork, read_op), 322 Bind(&FileIOResource::ReadOp::DoWork, read_op),
323 RunWhileLocked(Bind(&TrackedCallback::Run, callback))); 323 RunWhileLocked(Bind(&TrackedCallback::Run, callback)));
324 callback->set_completion_task( 324 callback->set_completion_task(
325 Bind(&FileIOResource::OnReadComplete, this, read_op, array_output)); 325 Bind(&FileIOResource::OnReadComplete, this, read_op, array_output));
326 326
327 return PP_OK_COMPLETIONPENDING; 327 return PP_OK_COMPLETIONPENDING;
328 } 328 }
329 329
330 void FileIOResource::CloseFileHandle() { 330 void FileIOResource::CloseFileHandle() {
331 if (file_handle_ != base::kInvalidPlatformFileValue) { 331 if (file_handle_ != base::kInvalidPlatformFileValue) {
332 // Close our local fd on the file thread. 332 // Close our local fd on the file thread.
333 base::TaskRunner* file_task_runner = 333 base::TaskRunner* file_task_runner =
334 PpapiGlobals::Get()->GetFileTaskRunner(pp_instance()); 334 PpapiGlobals::Get()->GetFileTaskRunner();
335 file_task_runner->PostTask(FROM_HERE, 335 file_task_runner->PostTask(FROM_HERE,
336 base::Bind(&DoClose, file_handle_)); 336 base::Bind(&DoClose, file_handle_));
337 337
338 file_handle_ = base::kInvalidPlatformFileValue; 338 file_handle_ = base::kInvalidPlatformFileValue;
339 } 339 }
340 } 340 }
341 341
342 int32_t FileIOResource::OnQueryComplete(scoped_refptr<QueryOp> query_op, 342 int32_t FileIOResource::OnQueryComplete(scoped_refptr<QueryOp> query_op,
343 PP_FileInfo* info, 343 PP_FileInfo* info,
344 int32_t result) { 344 int32_t result) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 *output_handle = IPC::PlatformFileForTransitToPlatformFile(transit_file); 428 *output_handle = IPC::PlatformFileForTransitToPlatformFile(transit_file);
429 429
430 // End this operation now, so the user's callback can execute another FileIO 430 // End this operation now, so the user's callback can execute another FileIO
431 // operation, assuming there are no other pending operations. 431 // operation, assuming there are no other pending operations.
432 state_manager_.SetOperationFinished(); 432 state_manager_.SetOperationFinished();
433 callback->Run(result); 433 callback->Run(result);
434 } 434 }
435 435
436 } // namespace proxy 436 } // namespace proxy
437 } // namespace ppapi 437 } // namespace ppapi
OLDNEW
« no previous file with comments | « content/renderer/pepper/host_globals.cc ('k') | ppapi/proxy/plugin_globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698