#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/fileapi/browser_file_system_helper.h"
#include "content/browser/fileapi/chrome_blob_storage_context.h"
+#include "content/browser/resource_context_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
static void RequestPlatformPathFromBlobURL(
const GURL& url,
- BrowserContext* browser_context,
+ ResourceContext* resource_context,
const base::Callback<void(const std::string&)>& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- ChromeBlobStorageContext* context =
- ChromeBlobStorageContext::GetFor(browser_context);
+ ChromeBlobStorageContext* blob_storage_context =
+ GetChromeBlobStorageContextForResourceContext(resource_context);
+
scoped_ptr<storage::BlobDataHandle> handle =
- context->context()->GetBlobDataFromPublicURL(url);
+ blob_storage_context->context()->GetBlobDataFromPublicURL(url);
+ if (!handle) {
+ // There are plenty of cases where handle can be empty. The most trivial is
+ // when JS has aready revoked the given blob URL via URL.revokeObjectURL
+ ReturnResultOnUIThread(callback, std::string());
+ return;
+ }
storage::BlobData* data = handle->data();
if (!data) {
- ReturnResultOnUIThread(callback, "");
+ ReturnResultOnUIThread(callback, std::string());
NOTREACHED();
return;
}
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
- base::Bind(&RequestPlatformPathFromBlobURL, url, browser_context_, cb));
+ base::Bind(&RequestPlatformPathFromBlobURL, url,
+ browser_context_->GetResourceContext(), cb));
return;
}