| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/media/android/media_resource_getter_impl.h" | 5 #include "content/browser/media/android/media_resource_getter_impl.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | |
| 8 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/bind.h" | 10 #include "base/bind.h" |
| 12 #include "base/macros.h" | 11 #include "base/macros.h" |
| 13 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 14 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 15 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 14 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| 16 #include "content/browser/child_process_security_policy_impl.h" | 15 #include "content/browser/child_process_security_policy_impl.h" |
| 17 #include "content/browser/fileapi/browser_file_system_helper.h" | 16 #include "content/browser/fileapi/browser_file_system_helper.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Gets the metadata from a media URL. When finished, a task is posted to the UI | 115 // Gets the metadata from a media URL. When finished, a task is posted to the UI |
| 117 // thread to run the callback function. | 116 // thread to run the callback function. |
| 118 static void GetMediaMetadata( | 117 static void GetMediaMetadata( |
| 119 const std::string& url, const std::string& cookies, | 118 const std::string& url, const std::string& cookies, |
| 120 const std::string& user_agent, | 119 const std::string& user_agent, |
| 121 const media::MediaResourceGetter::ExtractMediaMetadataCB& callback) { | 120 const media::MediaResourceGetter::ExtractMediaMetadataCB& callback) { |
| 122 JNIEnv* env = base::android::AttachCurrentThread(); | 121 JNIEnv* env = base::android::AttachCurrentThread(); |
| 123 | 122 |
| 124 ScopedJavaLocalRef<jstring> j_url_string = ConvertUTF8ToJavaString(env, url); | 123 ScopedJavaLocalRef<jstring> j_url_string = ConvertUTF8ToJavaString(env, url); |
| 125 ScopedJavaLocalRef<jstring> j_cookies = ConvertUTF8ToJavaString(env, cookies); | 124 ScopedJavaLocalRef<jstring> j_cookies = ConvertUTF8ToJavaString(env, cookies); |
| 126 const JavaRef<jobject>& j_context = base::android::GetApplicationContext(); | |
| 127 ScopedJavaLocalRef<jstring> j_user_agent = ConvertUTF8ToJavaString( | 125 ScopedJavaLocalRef<jstring> j_user_agent = ConvertUTF8ToJavaString( |
| 128 env, user_agent); | 126 env, user_agent); |
| 129 ScopedJavaLocalRef<jobject> j_metadata = | 127 ScopedJavaLocalRef<jobject> j_metadata = |
| 130 Java_MediaResourceGetter_extractMediaMetadata( | 128 Java_MediaResourceGetter_extractMediaMetadata(env, j_url_string, |
| 131 env, j_context, j_url_string, j_cookies, j_user_agent); | 129 j_cookies, j_user_agent); |
| 132 | 130 |
| 133 PostMediaMetadataCallbackTask(callback, env, j_metadata); | 131 PostMediaMetadataCallbackTask(callback, env, j_metadata); |
| 134 } | 132 } |
| 135 | 133 |
| 136 // Gets the metadata from a file descriptor. When finished, a task is posted to | 134 // Gets the metadata from a file descriptor. When finished, a task is posted to |
| 137 // the UI thread to run the callback function. | 135 // the UI thread to run the callback function. |
| 138 static void GetMediaMetadataFromFd( | 136 static void GetMediaMetadataFromFd( |
| 139 const int fd, | 137 const int fd, |
| 140 const int64_t offset, | 138 const int64_t offset, |
| 141 const int64_t size, | 139 const int64_t size, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 const int64_t size, | 372 const int64_t size, |
| 375 const ExtractMediaMetadataCB& callback) { | 373 const ExtractMediaMetadataCB& callback) { |
| 376 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 374 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 377 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); | 375 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); |
| 378 pool->PostWorkerTask( | 376 pool->PostWorkerTask( |
| 379 FROM_HERE, | 377 FROM_HERE, |
| 380 base::Bind(&GetMediaMetadataFromFd, fd, offset, size, callback)); | 378 base::Bind(&GetMediaMetadataFromFd, fd, offset, size, callback)); |
| 381 } | 379 } |
| 382 | 380 |
| 383 } // namespace content | 381 } // namespace content |
| OLD | NEW |