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

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

Issue 55133010: [PPAPI] Fixed FileSystems from JavaScript not having a context. (Closed) Base URL: http://git.chromium.org/chromium/src.git@pepper-fs-fileio-test-disable
Patch Set: Nit: Return early, and un-indent code. Created 7 years, 1 month 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
Index: content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc
diff --git a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc
index 923ee684c719ca00d3de435bc42edceb0d00380a..76bff32bc2f7f44e3f8a4e519601a133f7311f10 100644
--- a/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc
+++ b/content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc
@@ -52,19 +52,24 @@ PepperFileSystemBrowserHost::PepperFileSystemBrowserHost(BrowserPpapiHost* host,
weak_factory_(this) {
}
-PepperFileSystemBrowserHost::PepperFileSystemBrowserHost(BrowserPpapiHost* host,
- PP_Instance instance,
- PP_Resource resource,
- const GURL& root_url,
- PP_FileSystemType type)
- : ResourceHost(host->GetPpapiHost(), instance, resource),
- browser_ppapi_host_(host),
- type_(type),
- opened_(true),
- root_url_(root_url),
- fs_context_(NULL),
- called_open_(true),
- weak_factory_(this) {
+void PepperFileSystemBrowserHost::OpenExisting(const GURL& root_url,
+ const base::Closure& callback) {
+ root_url_ = root_url;
+ int render_process_id = 0;
+ int unused;
+ if (!browser_ppapi_host_->GetRenderViewIDsForInstance(
+ pp_instance(), &render_process_id, &unused)) {
+ NOTREACHED();
+ }
+ called_open_ = true;
+ // Get the file system context asynchronously, and then complete the Open
+ // operation by calling |callback|.
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&GetFileSystemContextFromRenderId, render_process_id),
+ base::Bind(&PepperFileSystemBrowserHost::OpenExistingWithContext,
+ weak_factory_.GetWeakPtr(), callback));
}
PepperFileSystemBrowserHost::~PepperFileSystemBrowserHost() {
@@ -135,6 +140,21 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgOpen(
return PP_OK_COMPLETIONPENDING;
}
+void PepperFileSystemBrowserHost::OpenExistingWithContext(
+ const base::Closure& callback,
+ scoped_refptr<fileapi::FileSystemContext> fs_context) {
+ if (fs_context.get()) {
+ opened_ = true;
+ } else {
+ // If there is no file system context, we log a warning and continue with an
+ // invalid resource (which will produce errors when used), since we have no
+ // way to communicate the error to the caller.
+ LOG(WARNING) << "Could not retrieve file system context.";
+ }
+ fs_context_ = fs_context;
+ callback.Run();
+}
+
void PepperFileSystemBrowserHost::GotFileSystemContext(
ppapi::host::ReplyMessageContext reply_context,
fileapi::FileSystemType file_system_type,

Powered by Google App Engine
This is Rietveld 408576698