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

Unified Diff: storage/browser/blob/blob_url_request_job_factory.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 side-by-side diff with in-line comments
Download patch
Index: storage/browser/blob/blob_url_request_job_factory.cc
diff --git a/storage/browser/blob/blob_url_request_job_factory.cc b/storage/browser/blob/blob_url_request_job_factory.cc
index 60f9c738b9e74245871d167d2c9c2b8eb9bd3d6e..c834990d41e0f9cf983f0b88bed7391772e42025 100644
--- a/storage/browser/blob/blob_url_request_job_factory.cc
+++ b/storage/browser/blob/blob_url_request_job_factory.cc
@@ -22,15 +22,16 @@ namespace {
int kUserDataKey; // The value is not important, the addr is a key.
-BlobDataHandle* GetRequestedBlobDataHandle(net::URLRequest* request) {
- return static_cast<BlobDataHandle*>(request->GetUserData(&kUserDataKey));
+BlobDataSnapshotHandle* GetRequestedBlobDataHandle(net::URLRequest* request) {
+ return static_cast<BlobDataSnapshotHandle*>(
+ request->GetUserData(&kUserDataKey));
}
} // namespace
// static
scoped_ptr<net::URLRequest> BlobProtocolHandler::CreateBlobRequest(
- scoped_ptr<BlobDataHandle> blob_data_handle,
+ scoped_ptr<BlobDataSnapshotHandle> blob_data_handle,
const net::URLRequestContext* request_context,
net::URLRequest::Delegate* request_delegate) {
const GURL kBlobUrl("blob://see_user_data/");
@@ -43,7 +44,7 @@ scoped_ptr<net::URLRequest> BlobProtocolHandler::CreateBlobRequest(
// static
void BlobProtocolHandler::SetRequestedBlobDataHandle(
net::URLRequest* request,
- scoped_ptr<BlobDataHandle> blob_data_handle) {
+ scoped_ptr<BlobDataSnapshotHandle> blob_data_handle) {
request->SetUserData(&kUserDataKey, blob_data_handle.release());
}
@@ -68,9 +69,10 @@ net::URLRequestJob* BlobProtocolHandler::MaybeCreateJob(
file_loop_proxy_.get());
}
-scoped_refptr<storage::BlobData> BlobProtocolHandler::LookupBlobData(
+const storage::BlobDataSnapshot* BlobProtocolHandler::LookupBlobData(
net::URLRequest* request) const {
- BlobDataHandle* blob_data_handle = GetRequestedBlobDataHandle(request);
+ BlobDataSnapshotHandle* blob_data_handle =
+ GetRequestedBlobDataHandle(request);
if (blob_data_handle)
return blob_data_handle->data();
if (!context_.get())
@@ -83,8 +85,14 @@ scoped_refptr<storage::BlobData> BlobProtocolHandler::LookupBlobData(
if (!StartsWithASCII(request->url().spec(), kPrefix, true))
return NULL;
std::string uuid = request->url().spec().substr(kPrefix.length());
- scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(uuid);
- return handle.get() ? handle->data() : NULL;
+ scoped_ptr<BlobDataSnapshotHandle> handle =
+ context_->GetBlobDataFromUUID(uuid);
+ const BlobDataSnapshot* snapshot = nullptr;
+ if (handle) {
+ snapshot = handle->data();
+ SetRequestedBlobDataHandle(request, handle.Pass());
+ }
+ return snapshot;
}
} // namespace storage

Powered by Google App Engine
This is Rietveld 408576698