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

Side by Side Diff: content/browser/media/android/media_resource_getter_impl.cc

Issue 810403004: [Storage] Blob Storage Refactoring pt 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: memory leak fixed Created 5 years, 11 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 unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
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_storage_context.h" 31 #include "storage/browser/blob/blob_storage_context.h"
32 #include "storage/common/blob/blob_data.h"
32 #include "url/gurl.h" 33 #include "url/gurl.h"
33 34
34 using base::android::ConvertUTF8ToJavaString; 35 using base::android::ConvertUTF8ToJavaString;
35 using base::android::ScopedJavaLocalRef; 36 using base::android::ScopedJavaLocalRef;
36 37
37 namespace content { 38 namespace content {
38 39
39 static void ReturnResultOnUIThread( 40 static void ReturnResultOnUIThread(
40 const base::Callback<void(const std::string&)>& callback, 41 const base::Callback<void(const std::string&)>& callback,
41 const std::string& result) { 42 const std::string& result) {
42 BrowserThread::PostTask( 43 BrowserThread::PostTask(
43 BrowserThread::UI, FROM_HERE, base::Bind(callback, result)); 44 BrowserThread::UI, FROM_HERE, base::Bind(callback, result));
44 } 45 }
45 46
46 static void RequestPlatformPathFromBlobURL( 47 static void RequestPlatformPathFromBlobURL(
47 const GURL& url, 48 const GURL& url,
48 ResourceContext* resource_context, 49 ResourceContext* resource_context,
49 const base::Callback<void(const std::string&)>& callback) { 50 const base::Callback<void(const std::string&)>& callback) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
51 ChromeBlobStorageContext* blob_storage_context = 52 ChromeBlobStorageContext* blob_storage_context =
52 GetChromeBlobStorageContextForResourceContext(resource_context); 53 GetChromeBlobStorageContextForResourceContext(resource_context);
53 54
54 scoped_ptr<storage::BlobDataHandle> handle = 55 scoped_ptr<storage::BlobDataSnapshotHandle> handle =
55 blob_storage_context->context()->GetBlobDataFromPublicURL(url); 56 blob_storage_context->context()->GetBlobDataFromPublicURL(url);
56 if (!handle) { 57 if (!handle) {
57 // There are plenty of cases where handle can be empty. The most trivial is 58 // 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 59 // when JS has aready revoked the given blob URL via URL.revokeObjectURL
59 ReturnResultOnUIThread(callback, std::string()); 60 ReturnResultOnUIThread(callback, std::string());
60 return; 61 return;
61 } 62 }
62 storage::BlobData* data = handle->data(); 63 const storage::BlobDataSnapshot* data = handle->data();
63 if (!data) { 64 if (!data) {
64 ReturnResultOnUIThread(callback, std::string()); 65 ReturnResultOnUIThread(callback, std::string());
65 NOTREACHED(); 66 NOTREACHED();
66 return; 67 return;
67 } 68 }
68 const std::vector<storage::BlobData::Item> items = data->items(); 69 const std::vector<scoped_refptr<storage::BlobDataItem>>& items =
70 data->items();
69 71
70 // TODO(qinmin): handle the case when the blob data is not a single file. 72 // TODO(qinmin): handle the case when the blob data is not a single file.
71 DLOG_IF(WARNING, items.size() != 1u) 73 DLOG_IF(WARNING, items.size() != 1u)
72 << "More than one blob data are present: " << items.size(); 74 << "More than one blob data are present: " << items.size();
73 ReturnResultOnUIThread(callback, items[0].path().value()); 75 ReturnResultOnUIThread(callback, items[0]->path().value());
74 } 76 }
75 77
76 static void RequestPlaformPathFromFileSystemURL( 78 static void RequestPlaformPathFromFileSystemURL(
77 const GURL& url, 79 const GURL& url,
78 int render_process_id, 80 int render_process_id,
79 scoped_refptr<storage::FileSystemContext> file_system_context, 81 scoped_refptr<storage::FileSystemContext> file_system_context,
80 const base::Callback<void(const std::string&)>& callback) { 82 const base::Callback<void(const std::string&)>& callback) {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
82 base::FilePath platform_path; 84 base::FilePath platform_path;
83 SyncGetPlatformPath(file_system_context.get(), 85 SyncGetPlatformPath(file_system_context.get(),
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 FROM_HERE, 377 FROM_HERE,
376 base::Bind(&GetMediaMetadataFromFd, fd, offset, size, callback)); 378 base::Bind(&GetMediaMetadataFromFd, fd, offset, size, callback));
377 } 379 }
378 380
379 // static 381 // static
380 bool MediaResourceGetterImpl::RegisterMediaResourceGetter(JNIEnv* env) { 382 bool MediaResourceGetterImpl::RegisterMediaResourceGetter(JNIEnv* env) {
381 return RegisterNativesImpl(env); 383 return RegisterNativesImpl(env);
382 } 384 }
383 385
384 } // namespace content 386 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698