OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "content/browser/renderer_host/pepper/pepper_file_io_host.h" | 5 #include "content/browser/renderer_host/pepper/pepper_file_io_host.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
10 #include "base/files/file_util_proxy.h" | 12 #include "base/files/file_util_proxy.h" |
11 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
12 #include "content/browser/renderer_host/pepper/pepper_file_ref_host.h" | 14 #include "content/browser/renderer_host/pepper/pepper_file_ref_host.h" |
13 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
" | 15 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h
" |
14 #include "content/browser/renderer_host/pepper/pepper_security_helper.h" | 16 #include "content/browser/renderer_host/pepper/pepper_security_helper.h" |
15 #include "content/common/fileapi/file_system_messages.h" | 17 #include "content/common/fileapi/file_system_messages.h" |
16 #include "content/common/sandbox_util.h" | 18 #include "content/common/sandbox_util.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 void DidCloseFile(const base::Closure& on_close_callback) { | 86 void DidCloseFile(const base::Closure& on_close_callback) { |
85 if (!on_close_callback.is_null()) | 87 if (!on_close_callback.is_null()) |
86 on_close_callback.Run(); | 88 on_close_callback.Run(); |
87 } | 89 } |
88 | 90 |
89 void DidOpenFile(base::WeakPtr<PepperFileIOHost> file_host, | 91 void DidOpenFile(base::WeakPtr<PepperFileIOHost> file_host, |
90 storage::FileSystemOperation::OpenFileCallback callback, | 92 storage::FileSystemOperation::OpenFileCallback callback, |
91 base::File file, | 93 base::File file, |
92 const base::Closure& on_close_callback) { | 94 const base::Closure& on_close_callback) { |
93 if (file_host) { | 95 if (file_host) { |
94 callback.Run(file.Pass(), on_close_callback); | 96 callback.Run(std::move(file), on_close_callback); |
95 } else { | 97 } else { |
96 BrowserThread::PostTaskAndReply( | 98 BrowserThread::PostTaskAndReply( |
97 BrowserThread::FILE, | 99 BrowserThread::FILE, |
98 FROM_HERE, | 100 FROM_HERE, |
99 base::Bind(&FileCloser, base::Passed(&file)), | 101 base::Bind(&FileCloser, base::Passed(&file)), |
100 base::Bind(&DidCloseFile, on_close_callback)); | 102 base::Bind(&DidCloseFile, on_close_callback)); |
101 } | 103 } |
102 } | 104 } |
103 | 105 |
104 } // namespace | 106 } // namespace |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 AsWeakPtr(), | 279 AsWeakPtr(), |
278 reply_context, | 280 reply_context, |
279 base::Passed(&file))); | 281 base::Passed(&file))); |
280 return; | 282 return; |
281 } | 283 } |
282 } | 284 } |
283 | 285 |
284 DCHECK(!file_.IsValid()); | 286 DCHECK(!file_.IsValid()); |
285 base::File::Error error = | 287 base::File::Error error = |
286 file.IsValid() ? base::File::FILE_OK : file.error_details(); | 288 file.IsValid() ? base::File::FILE_OK : file.error_details(); |
287 file_.SetFile(file.Pass()); | 289 file_.SetFile(std::move(file)); |
288 OnOpenProxyCallback(reply_context, error); | 290 OnOpenProxyCallback(reply_context, error); |
289 } | 291 } |
290 | 292 |
291 void PepperFileIOHost::GotResolvedRenderProcessId( | 293 void PepperFileIOHost::GotResolvedRenderProcessId( |
292 ppapi::host::ReplyMessageContext reply_context, | 294 ppapi::host::ReplyMessageContext reply_context, |
293 base::FilePath path, | 295 base::FilePath path, |
294 int file_flags, | 296 int file_flags, |
295 base::ProcessId resolved_render_process_id) { | 297 base::ProcessId resolved_render_process_id) { |
296 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 298 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
297 resolved_render_process_id_ = resolved_render_process_id; | 299 resolved_render_process_id_ = resolved_render_process_id; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 return PP_OK; | 385 return PP_OK; |
384 } | 386 } |
385 | 387 |
386 void PepperFileIOHost::DidOpenQuotaFile( | 388 void PepperFileIOHost::DidOpenQuotaFile( |
387 ppapi::host::ReplyMessageContext reply_context, | 389 ppapi::host::ReplyMessageContext reply_context, |
388 base::File file, | 390 base::File file, |
389 int64_t max_written_offset) { | 391 int64_t max_written_offset) { |
390 DCHECK(!file_.IsValid()); | 392 DCHECK(!file_.IsValid()); |
391 DCHECK(file.IsValid()); | 393 DCHECK(file.IsValid()); |
392 max_written_offset_ = max_written_offset; | 394 max_written_offset_ = max_written_offset; |
393 file_.SetFile(file.Pass()); | 395 file_.SetFile(std::move(file)); |
394 | 396 |
395 OnOpenProxyCallback(reply_context, base::File::FILE_OK); | 397 OnOpenProxyCallback(reply_context, base::File::FILE_OK); |
396 } | 398 } |
397 | 399 |
398 void PepperFileIOHost::DidCloseFile(base::File::Error /*error*/) { | 400 void PepperFileIOHost::DidCloseFile(base::File::Error /*error*/) { |
399 // Silently ignore if we fail to close the file. | 401 // Silently ignore if we fail to close the file. |
400 if (!on_close_callback_.is_null()) { | 402 if (!on_close_callback_.is_null()) { |
401 on_close_callback_.Run(); | 403 on_close_callback_.Run(); |
402 on_close_callback_.Reset(); | 404 on_close_callback_.Reset(); |
403 } | 405 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 491 |
490 ppapi::proxy::SerializedHandle file_handle; | 492 ppapi::proxy::SerializedHandle file_handle; |
491 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc. | 493 // A non-zero resource id signals NaClIPCAdapter to create a NaClQuotaDesc. |
492 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0; | 494 PP_Resource quota_file_io = check_quota_ ? pp_resource() : 0; |
493 file_handle.set_file_handle(transit_file, open_flags, quota_file_io); | 495 file_handle.set_file_handle(transit_file, open_flags, quota_file_io); |
494 reply_context->params.AppendHandle(file_handle); | 496 reply_context->params.AppendHandle(file_handle); |
495 return true; | 497 return true; |
496 } | 498 } |
497 | 499 |
498 } // namespace content | 500 } // namespace content |
OLD | NEW |