Chromium Code Reviews| 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 af3ec67b22717eaecba02235507d6a57b08a3685..fdb5becd2f177e8f7b885c8bfe31f842f1970dde 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 |
| @@ -65,19 +65,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, |
| + 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::OpenExistingHaveContext, |
| + weak_factory_.GetWeakPtr(), callback)); |
| } |
| PepperFileSystemBrowserHost::~PepperFileSystemBrowserHost() { |
| @@ -148,6 +153,19 @@ int32_t PepperFileSystemBrowserHost::OnHostMsgOpen( |
| return PP_OK_COMPLETIONPENDING; |
| } |
| +void PepperFileSystemBrowserHost::OpenExistingHaveContext( |
| + base::Closure callback, |
| + scoped_refptr<fileapi::FileSystemContext> fs_context) { |
| + opened_ = true; |
|
yzshen1
2013/11/01 22:27:39
Is it intended to set it to true even if fs_contex
Matt Giuca
2013/11/01 23:19:47
Good point. I changed it so that opened_ is only t
|
| + // 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. |
| + if (!fs_context.get()) |
| + 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, |