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/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "jni/MediaResourceGetter_jni.h" | 21 #include "jni/MediaResourceGetter_jni.h" |
22 #include "media/base/android/media_url_interceptor.h" | 22 #include "media/base/android/media_url_interceptor.h" |
23 #include "net/base/auth.h" | 23 #include "net/base/auth.h" |
24 #include "net/cookies/cookie_monster.h" | 24 #include "net/cookies/cookie_monster.h" |
25 #include "net/cookies/cookie_store.h" | 25 #include "net/cookies/cookie_store.h" |
26 #include "net/http/http_auth.h" | 26 #include "net/http/http_auth.h" |
27 #include "net/http/http_transaction_factory.h" | 27 #include "net/http/http_transaction_factory.h" |
28 #include "net/url_request/url_request_context.h" | 28 #include "net/url_request/url_request_context.h" |
29 #include "net/url_request/url_request_context_getter.h" | 29 #include "net/url_request/url_request_context_getter.h" |
30 #include "storage/browser/blob/blob_data_handle.h" | 30 #include "storage/browser/blob/blob_data_handle.h" |
| 31 #include "storage/browser/blob/blob_data_item.h" |
| 32 #include "storage/browser/blob/blob_data_snapshot.h" |
31 #include "storage/browser/blob/blob_storage_context.h" | 33 #include "storage/browser/blob/blob_storage_context.h" |
32 #include "url/gurl.h" | 34 #include "url/gurl.h" |
33 | 35 |
34 using base::android::ConvertUTF8ToJavaString; | 36 using base::android::ConvertUTF8ToJavaString; |
35 using base::android::ScopedJavaLocalRef; | 37 using base::android::ScopedJavaLocalRef; |
36 | 38 |
37 namespace content { | 39 namespace content { |
38 | 40 |
39 static void ReturnResultOnUIThread( | 41 static void ReturnResultOnUIThread( |
40 const base::Callback<void(const std::string&)>& callback, | 42 const base::Callback<void(const std::string&)>& callback, |
(...skipping 11 matching lines...) Expand all Loading... |
52 GetChromeBlobStorageContextForResourceContext(resource_context); | 54 GetChromeBlobStorageContextForResourceContext(resource_context); |
53 | 55 |
54 scoped_ptr<storage::BlobDataHandle> handle = | 56 scoped_ptr<storage::BlobDataHandle> handle = |
55 blob_storage_context->context()->GetBlobDataFromPublicURL(url); | 57 blob_storage_context->context()->GetBlobDataFromPublicURL(url); |
56 if (!handle) { | 58 if (!handle) { |
57 // There are plenty of cases where handle can be empty. The most trivial is | 59 // There are plenty of cases where handle can be empty. The most trivial is |
58 // when JS has aready revoked the given blob URL via URL.revokeObjectURL | 60 // when JS has aready revoked the given blob URL via URL.revokeObjectURL |
59 ReturnResultOnUIThread(callback, std::string()); | 61 ReturnResultOnUIThread(callback, std::string()); |
60 return; | 62 return; |
61 } | 63 } |
62 storage::BlobData* data = handle->data(); | 64 scoped_ptr<storage::BlobDataSnapshot> data = handle->CreateSnapshot(); |
63 if (!data) { | 65 if (!data) { |
64 ReturnResultOnUIThread(callback, std::string()); | 66 ReturnResultOnUIThread(callback, std::string()); |
65 NOTREACHED(); | 67 NOTREACHED(); |
66 return; | 68 return; |
67 } | 69 } |
68 const std::vector<storage::BlobData::Item> items = data->items(); | 70 const std::vector<scoped_refptr<storage::BlobDataItem>>& items = |
| 71 data->items(); |
69 | 72 |
70 // TODO(qinmin): handle the case when the blob data is not a single file. | 73 // TODO(qinmin): handle the case when the blob data is not a single file. |
71 DLOG_IF(WARNING, items.size() != 1u) | 74 DLOG_IF(WARNING, items.size() != 1u) |
72 << "More than one blob data are present: " << items.size(); | 75 << "More than one blob item is present: " << items.size(); |
73 ReturnResultOnUIThread(callback, items[0].path().value()); | 76 ReturnResultOnUIThread(callback, items[0]->path().value()); |
74 } | 77 } |
75 | 78 |
76 static void RequestPlaformPathFromFileSystemURL( | 79 static void RequestPlaformPathFromFileSystemURL( |
77 const GURL& url, | 80 const GURL& url, |
78 int render_process_id, | 81 int render_process_id, |
79 scoped_refptr<storage::FileSystemContext> file_system_context, | 82 scoped_refptr<storage::FileSystemContext> file_system_context, |
80 const base::Callback<void(const std::string&)>& callback) { | 83 const base::Callback<void(const std::string&)>& callback) { |
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
82 base::FilePath platform_path; | 85 base::FilePath platform_path; |
83 SyncGetPlatformPath(file_system_context.get(), | 86 SyncGetPlatformPath(file_system_context.get(), |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 FROM_HERE, | 378 FROM_HERE, |
376 base::Bind(&GetMediaMetadataFromFd, fd, offset, size, callback)); | 379 base::Bind(&GetMediaMetadataFromFd, fd, offset, size, callback)); |
377 } | 380 } |
378 | 381 |
379 // static | 382 // static |
380 bool MediaResourceGetterImpl::RegisterMediaResourceGetter(JNIEnv* env) { | 383 bool MediaResourceGetterImpl::RegisterMediaResourceGetter(JNIEnv* env) { |
381 return RegisterNativesImpl(env); | 384 return RegisterNativesImpl(env); |
382 } | 385 } |
383 | 386 |
384 } // namespace content | 387 } // namespace content |
OLD | NEW |