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

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

Issue 12595005: Parsing filesystem url before giving it to media player (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months 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/android/media_resource_getter_impl.cc
diff --git a/content/browser/android/cookie_getter_impl.cc b/content/browser/android/media_resource_getter_impl.cc
similarity index 54%
rename from content/browser/android/cookie_getter_impl.cc
rename to content/browser/android/media_resource_getter_impl.cc
index 18631ad5a24cd552261dac9309ef2443d828162e..f55335be50744ca0679ae72fc24e1eb10a990024 100644
--- a/content/browser/android/cookie_getter_impl.cc
+++ b/content/browser/android/media_resource_getter_impl.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/android/cookie_getter_impl.h"
+#include "content/browser/android/media_resource_getter_impl.h"
#include "base/bind.h"
#include "content/browser/child_process_security_policy_impl.h"
@@ -18,12 +18,11 @@
namespace content {
-static void ReturnCookieOnUIThread(
- const media::CookieGetter::GetCookieCB& callback,
- const std::string& cookies) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+static void ReturnResultOnUIThread(
+ const base::Callback<void(const std::string&)>& callback,
+ const std::string& result) {
BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE, base::Bind(callback, cookies));
+ BrowserThread::UI, FROM_HERE, base::Bind(callback, result));
}
// The task object that retrieves cookie on the IO thread.
@@ -38,7 +37,7 @@ class CookieGetterTask
// Called by CookieGetterImpl to start getting cookies for a URL.
void RequestCookies(
const GURL& url, const GURL& first_party_for_cookies,
- const media::CookieGetter::GetCookieCB& callback);
+ const media::MediaResourceGetter::GetCookieCB& callback);
private:
friend class base::RefCountedThreadSafe<CookieGetterTask>;
@@ -46,7 +45,7 @@ class CookieGetterTask
void CheckPolicyForCookies(
const GURL& url, const GURL& first_party_for_cookies,
- const media::CookieGetter::GetCookieCB& callback,
+ const media::MediaResourceGetter::GetCookieCB& callback,
const net::CookieList& cookie_list);
// Context getter used to get the CookieStore.
@@ -76,7 +75,7 @@ CookieGetterTask::~CookieGetterTask() {}
void CookieGetterTask::RequestCookies(
const GURL& url, const GURL& first_party_for_cookies,
- const media::CookieGetter::GetCookieCB& callback) {
+ const media::MediaResourceGetter::GetCookieCB& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ChildProcessSecurityPolicyImpl* policy =
ChildProcessSecurityPolicyImpl::GetInstance();
@@ -104,7 +103,7 @@ void CookieGetterTask::RequestCookies(
void CookieGetterTask::CheckPolicyForCookies(
const GURL& url, const GURL& first_party_for_cookies,
- const media::CookieGetter::GetCookieCB& callback,
+ const media::MediaResourceGetter::GetCookieCB& callback,
const net::CookieList& cookie_list) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
if (GetContentClient()->browser()->AllowGetCookie(
@@ -119,37 +118,109 @@ void CookieGetterTask::CheckPolicyForCookies(
}
}
-CookieGetterImpl::CookieGetterImpl(
- BrowserContext* browser_context, int renderer_id, int routing_id)
+// The task object that retrieves platform path on the FILE thread.
+class PlatformPathGetterTask
+ : public base::RefCountedThreadSafe<PlatformPathGetterTask> {
scherkus (not reviewing) 2013/03/08 21:26:27 should be 4 space indent
qinmin 2013/03/08 22:36:12 Done.
+ public:
+ PlatformPathGetterTask(fileapi::FileSystemContext* file_system_context,
+ int renderer_id);
+
+ // Called by MediaResourceGetterImpl to get the platform path from a file
+ // system URL.
+ void RequestPlaformPath(
+ const GURL& url,
+ const media::MediaResourceGetter::GetPlatformPathCB& callback);
+
+ private:
+ friend class base::RefCountedThreadSafe<PlatformPathGetterTask>;
+ virtual ~PlatformPathGetterTask();
+
+ // File system context for getting the platform path.
+ fileapi::FileSystemContext* file_system_context_;
+
+ // Render process id, used to check whether the process can access the URL.
+ int renderer_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(PlatformPathGetterTask);
+};
+
+PlatformPathGetterTask::PlatformPathGetterTask(
+ fileapi::FileSystemContext* file_system_context, int renderer_id)
+ : file_system_context_(file_system_context),
+ renderer_id_(renderer_id) {
+}
+
+PlatformPathGetterTask::~PlatformPathGetterTask() {}
+
+void PlatformPathGetterTask::RequestPlaformPath(
+ const GURL& url,
+ const media::MediaResourceGetter::GetPlatformPathCB& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ base::FilePath platform_path;
+ FileAPIMessageFilter::SyncGetPlatformPath(file_system_context_,
+ renderer_id_,
+ url,
+ &platform_path);
kinuko 2013/03/08 02:43:21 If you can implement this with async API, can you
qinmin 2013/03/08 03:09:28 For GetMetadata(), does it has to be on the IO thr
kinuko 2013/03/08 03:14:32 Ah- I see you're already on File thread, sorry I m
+ callback.Run(platform_path.value());
+}
+
+MediaResourceGetterImpl::MediaResourceGetterImpl(
+ BrowserContext* browser_context,
+ fileapi::FileSystemContext* file_system_context,
+ int renderer_id, int routing_id)
: browser_context_(browser_context),
+ file_system_context_(file_system_context),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_this_(this)),
renderer_id_(renderer_id),
routing_id_(routing_id) {
}
-CookieGetterImpl::~CookieGetterImpl() {}
+MediaResourceGetterImpl::~MediaResourceGetterImpl() {}
-void CookieGetterImpl::GetCookies(const std::string& url,
+void MediaResourceGetterImpl::GetCookies(const std::string& url,
const std::string& first_party_for_cookies,
const GetCookieCB& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
scoped_refptr<CookieGetterTask> task = new CookieGetterTask(
browser_context_, renderer_id_, routing_id_);
- GetCookieCB cb = base::Bind(
- &CookieGetterImpl::GetCookiesCallback, weak_this_.GetWeakPtr(), callback);
+ GetCookieCB cb = base::Bind(&MediaResourceGetterImpl::GetCookiesCallback,
+ weak_this_.GetWeakPtr(), callback);
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(&CookieGetterTask::RequestCookies,
task, GURL(url), GURL(first_party_for_cookies),
- base::Bind(&ReturnCookieOnUIThread, cb)));
+ base::Bind(&ReturnResultOnUIThread, cb)));
}
-void CookieGetterImpl::GetCookiesCallback(
+void MediaResourceGetterImpl::GetCookiesCallback(
const GetCookieCB& callback, const std::string& cookies) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
callback.Run(cookies);
}
+void MediaResourceGetterImpl::GetPlatformPathFromFileSystemURL(
+ const std::string& url, const GetPlatformPathCB& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ scoped_refptr<PlatformPathGetterTask> task = new PlatformPathGetterTask(
+ file_system_context_, renderer_id_);
+
+ GetPlatformPathCB cb = base::Bind(
+ &MediaResourceGetterImpl::GetPlatformPathCallback,
+ weak_this_.GetWeakPtr(), callback);
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&PlatformPathGetterTask::RequestPlaformPath,
+ task, GURL(url),
+ base::Bind(&ReturnResultOnUIThread, cb)));
+}
+
+void MediaResourceGetterImpl::GetPlatformPathCallback(
+ const GetPlatformPathCB& callback, const std::string& platform_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ callback.Run(platform_path);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698