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

Unified Diff: content/browser/media/android/media_resource_getter_impl.cc

Issue 693263003: Fixed some crashes when playing media from the blob URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/android/media_resource_getter_impl.cc
diff --git a/content/browser/media/android/media_resource_getter_impl.cc b/content/browser/media/android/media_resource_getter_impl.cc
index 7083da4e435d55a390854495b5367de3b0868c07..686e01c331c43ca5535f49931315006fafe1ccf8 100644
--- a/content/browser/media/android/media_resource_getter_impl.cc
+++ b/content/browser/media/android/media_resource_getter_impl.cc
@@ -12,6 +12,7 @@
#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"
@@ -44,16 +45,23 @@ static void ReturnResultOnUIThread(
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;
}
@@ -329,7 +337,8 @@ void MediaResourceGetterImpl::GetPlatformPathFromURL(
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
- base::Bind(&RequestPlatformPathFromBlobURL, url, browser_context_, cb));
+ base::Bind(&RequestPlatformPathFromBlobURL, url,
+ browser_context_->GetResourceContext(), cb));
return;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698