Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / media / android / media_resource_getter_impl.cc
index 7083da4..686e01c 100644 (file)
@@ -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;
   }