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

Unified Diff: content/browser/renderer_host/pepper/pepper_file_io_host.cc

Issue 306403005: Pepper: Use an adaptor to invoke FileSystemOperationRunner::OpenFile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/ppapi/ppapi_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/pepper/pepper_file_io_host.cc
diff --git a/content/browser/renderer_host/pepper/pepper_file_io_host.cc b/content/browser/renderer_host/pepper/pepper_file_io_host.cc
index d9a11b7cc440a3eb2dc011f595e70b53de988957..3b4f864e324e0f9c9404de19e0019236d9512091 100644
--- a/content/browser/renderer_host/pepper/pepper_file_io_host.cc
+++ b/content/browser/renderer_host/pepper/pepper_file_io_host.cc
@@ -78,6 +78,39 @@ bool FileOpenForWrite(int32_t open_flags) {
return (open_flags & (PP_FILEOPENFLAG_WRITE | PP_FILEOPENFLAG_APPEND)) != 0;
}
+void FileCloser(base::File auto_close) {
+}
+
+class OpenFileAdapter {
+ public:
+ OpenFileAdapter(PepperFileIOHost* file_host,
+ fileapi::FileSystemOperation::OpenFileCallback callback);
+
+ void DidOpenFile(base::File file,
+ const base::Closure& on_close_callback);
+ private:
+ base::WeakPtr<PepperFileIOHost> file_host_;
+ fileapi::FileSystemOperation::OpenFileCallback callback_;
+ DISALLOW_COPY_AND_ASSIGN(OpenFileAdapter);
+};
+
+OpenFileAdapter::OpenFileAdapter(
+ PepperFileIOHost* file_host,
+ fileapi::FileSystemOperation::OpenFileCallback callback)
+ : file_host_(AsWeakPtr(file_host)),
+ callback_(callback) {
+}
+
+void OpenFileAdapter::DidOpenFile(base::File file,
+ const base::Closure& on_close_callback) {
+ if (file_host_) {
+ callback_.Run(file.Pass(), on_close_callback);
+ } else {
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&FileCloser, Passed(&file)));
bbudge 2014/06/03 18:21:53 Shouldn't we call 'on_close_callback' on this path
rvargas (doing something else) 2014/06/03 23:04:54 That is an interesting question. FileSystemOperat
rvargas (doing something else) 2014/06/03 23:19:58 On second thought, now there is code to invoke the
+ }
+}
+
} // namespace
PepperFileIOHost::PepperFileIOHost(BrowserPpapiHostImpl* host,
@@ -227,12 +260,17 @@ void PepperFileIOHost::GotUIThreadStuffForInternalFileSystems(
DCHECK(file_system_host_.get());
DCHECK(file_system_host_->GetFileSystemOperationRunner());
+
+ OpenFileAdapter* open_adapter(new OpenFileAdapter(
+ this,
+ base::Bind(&PepperFileIOHost::DidOpenInternalFile,
+ weak_factory_.GetWeakPtr(),
+ reply_context)));
+
file_system_host_->GetFileSystemOperationRunner()->OpenFile(
file_system_url_,
platform_file_flags,
- base::Bind(&PepperFileIOHost::DidOpenInternalFile,
- weak_factory_.GetWeakPtr(),
- reply_context));
+ base::Bind(&OpenFileAdapter::DidOpenFile, base::Owned(open_adapter)));
bbudge 2014/06/03 18:21:53 Rather than define a new class, could you could de
rvargas (doing something else) 2014/06/03 23:04:54 Done.
}
void PepperFileIOHost::DidOpenInternalFile(
« no previous file with comments | « chrome/test/ppapi/ppapi_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698