Index: content/renderer/render_thread_impl.cc |
=================================================================== |
--- content/renderer/render_thread_impl.cc (revision 214423) |
+++ content/renderer/render_thread_impl.cc (working copy) |
@@ -12,6 +12,7 @@ |
#include "base/allocator/allocator_extension.h" |
#include "base/command_line.h" |
#include "base/debug/trace_event.h" |
+#include "base/files/file_util_proxy.h" |
#include "base/lazy_instance.h" |
#include "base/logging.h" |
#include "base/memory/discardable_memory.h" |
@@ -1137,6 +1138,7 @@ |
IPC_MESSAGE_HANDLER(ViewMsg_TempCrashWithData, OnTempCrashWithData) |
IPC_MESSAGE_HANDLER(ViewMsg_SetWebKitSharedTimersSuspended, |
OnSetWebKitSharedTimersSuspended) |
+ IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
return handled; |
@@ -1276,6 +1278,28 @@ |
ToggleWebKitSharedTimer(suspend); |
} |
+void RenderThreadImpl::OnAsyncFileOpened( |
+ base::PlatformFileError error_code, |
+ IPC::PlatformFileForTransit file_for_transit, |
+ int message_id) { |
+ AsyncOpenFileCallback* callback = |
dmichael (off chromium)
2013/08/01 22:43:01
nit: scoped_ptr?
|
+ pending_async_open_files_.Lookup(message_id); |
+ DCHECK(callback); |
+ pending_async_open_files_.Remove(message_id); |
+ |
+ base::PlatformFile file = |
+ IPC::PlatformFileForTransitToPlatformFile(file_for_transit); |
+ callback->Run(error_code, base::PassPlatformFile(&file)); |
+ // Make sure we won't leak file handle if the requester has died. |
+ if (file != base::kInvalidPlatformFileValue) { |
+ base::FileUtilProxy::Close( |
+ GetFileThreadMessageLoopProxy().get(), |
+ file, |
+ base::FileUtilProxy::StatusCallback()); |
+ } |
+ delete callback; |
+} |
+ |
void RenderThreadImpl::OnMemoryPressure( |
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { |
base::allocator::ReleaseFreeMemory(); |
@@ -1318,7 +1342,14 @@ |
const std::vector<float>& new_touchscreen) { |
webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
new_touchscreen); |
+} |
+void RenderThreadImpl::AsyncOpenFile(const base::FilePath& path, |
+ int flags, |
+ const AsyncOpenFileCallback& callback) { |
+ int message_id = pending_async_open_files_.Add( |
+ new AsyncOpenFileCallback(callback)); |
+ Send(new ViewHostMsg_AsyncOpenFile(path, flags, message_id)); |
} |
} // namespace content |