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

Unified Diff: content/child/blob_storage/blob_transport_controller.cc

Issue 2340133006: [WIP] Hack on Blob mojom (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « content/child/blob_storage/blob_transport_controller.h ('k') | content/child/thread_safe_sender.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/blob_storage/blob_transport_controller.cc
diff --git a/content/child/blob_storage/blob_transport_controller.cc b/content/child/blob_storage/blob_transport_controller.cc
index b5cc88416ca6f89b5c319c100d175ac2460b0f8e..db16bd15adc2af9b3e4d4d53617a1340ab016591 100644
--- a/content/child/blob_storage/blob_transport_controller.cc
+++ b/content/child/blob_storage/blob_transport_controller.cc
@@ -4,8 +4,10 @@
#include "content/child/blob_storage/blob_transport_controller.h"
+#include <algorithm>
#include <limits>
#include <memory>
+#include <set>
#include <utility>
#include <vector>
@@ -33,6 +35,7 @@
#include "content/common/fileapi/webblob_messages.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_sender.h"
+#include "ipc/ipc_sync_message_filter.h"
#include "storage/common/blob_storage/blob_item_bytes_request.h"
#include "storage/common/blob_storage/blob_item_bytes_response.h"
#include "storage/common/data_element.h"
@@ -170,22 +173,13 @@ void BlobTransportController::InitiateBlobTransfer(
main_runner->PostTask(FROM_HERE, base::Bind(&IncChildProcessRefCount));
}
- std::vector<storage::DataElement> descriptions;
- std::set<std::string> referenced_blobs = consolidation->referenced_blobs();
- BlobTransportController::GetDescriptions(
- consolidation.get(), kBlobStorageIPCThresholdBytes, &descriptions);
- // I post the task first to make sure that we store our consolidation before
- // we get a request back from the browser.
io_runner->PostTask(
FROM_HERE,
base::Bind(&BlobTransportController::StoreBlobDataForRequests,
base::Unretained(BlobTransportController::GetInstance()), uuid,
- base::Passed(std::move(consolidation)),
+ content_type, base::Passed(std::move(consolidation)),
+ sender->sync_message_filter(),
base::Passed(std::move(main_runner))));
- // TODO(dmurph): Merge register and start messages.
- sender->Send(new BlobStorageMsg_RegisterBlobUUID(uuid, content_type, "",
- referenced_blobs));
- sender->Send(new BlobStorageMsg_StartBuildingBlob(uuid, descriptions));
}
void BlobTransportController::OnMemoryRequest(
@@ -304,16 +298,18 @@ void BlobTransportController::OnMemoryRequest(
sender->Send(new BlobStorageMsg_MemoryItemResponse(uuid, responses));
}
-void BlobTransportController::OnCancel(
+void BlobTransportController::OnBuildBlobComplete(
const std::string& uuid,
- storage::IPCBlobCreationCancelCode code) {
- DVLOG(1) << "Received blob cancel for blob " << uuid
- << " with code: " << static_cast<int>(code);
- ReleaseBlobConsolidation(uuid);
-}
-
-void BlobTransportController::OnDone(const std::string& uuid) {
- ReleaseBlobConsolidation(uuid);
+ mojom::BlobAssociatedPtr blob,
+ mojom::BlobCreationCancelCode cancel_code) {
+ if (blob) {
+ ReleaseBlobConsolidation(uuid);
+ blob_proxies_.insert(uuid, std::move(blob));
+ } else {
+ DVLOG(1) << "Received blob cancel for blob " << uuid
+ << " with code: " << static_cast<int>(code);
+ ReleaseBlobConsolidation(uuid);
+ }
}
void BlobTransportController::CancelAllBlobTransfers() {
@@ -402,11 +398,28 @@ void BlobTransportController::OnFileWriteComplete(
void BlobTransportController::StoreBlobDataForRequests(
const std::string& uuid,
+ const std::string& content_type,
scoped_refptr<BlobConsolidation> consolidation,
+ scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
scoped_refptr<base::SingleThreadTaskRunner> main_runner) {
if (!main_thread_runner_.get()) {
+ DCHECK(!blob_factory_.is_bound());
main_thread_runner_ = std::move(main_runner);
+ sync_message_filter->GetRemoteAssociatedInterface(&blob_factory_);
}
+
+ std::set<std::string> referenced_blob_set = consolidation->referenced_blobs();
+ std::vector<std::string> referenced_blobs;
+ std::copy(referenced_blob_set.begin(), referenced_blob_set.end(),
+ std::back_inserter(referenced_blobs));
+
+ std::vector<storage::DataElement> descriptions;
+ BlobTransportController::GetDescriptions(
+ consolidation.get(), kBlobStorageIPCThresholdBytes, &descriptions);
+
+ blob_factory_->BuildBlob(
+ uuid, content_type, "", referenced_blobs, descriptions,
+ base::Bind(&OnBuildBlobComplete, base::Unretained(this), uuid));
blob_storage_[uuid] = std::move(consolidation);
}
« no previous file with comments | « content/child/blob_storage/blob_transport_controller.h ('k') | content/child/thread_safe_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698