| Index: content/child/blob_storage/blob_message_filter.cc
|
| diff --git a/content/child/blob_storage/blob_message_filter.cc b/content/child/blob_storage/blob_message_filter.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b1d9c44ab30edd7faddb99cc99085049bf573e71
|
| --- /dev/null
|
| +++ b/content/child/blob_storage/blob_message_filter.cc
|
| @@ -0,0 +1,71 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/child/blob_storage/blob_message_filter.h"
|
| +
|
| +#include "content/child/blob_storage/blob_transport_controller.h"
|
| +#include "content/child/thread_safe_sender.h"
|
| +#include "content/child/worker_task_runner.h"
|
| +#include "content/common/blob_storage/blob_storage_messages.h"
|
| +#include "ipc/ipc_message.h"
|
| +#include "ipc/ipc_sender.h"
|
| +#include "storage/common/blob_storage/blob_item_bytes_request.h"
|
| +
|
| +namespace content {
|
| +
|
| +BlobMessageFilter::BlobMessageFilter()
|
| + : IPC::MessageFilter(),
|
| + sender_(nullptr),
|
| + controller_(BlobTransportController::GetInstance()) {}
|
| +
|
| +BlobMessageFilter::~BlobMessageFilter() {}
|
| +
|
| +void BlobMessageFilter::OnFilterAdded(IPC::Sender* sender) {
|
| + sender_ = sender;
|
| +}
|
| +
|
| +bool BlobMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
| + DCHECK_EQ(0, WorkerTaskRunner::Instance()->CurrentWorkerId());
|
| + bool handled = true;
|
| + IPC_BEGIN_MESSAGE_MAP(BlobMessageFilter, message)
|
| + IPC_MESSAGE_HANDLER(BlobStorageMsg_RequestMemoryItem, OnRequestMemoryItem)
|
| + IPC_MESSAGE_HANDLER(BlobStorageMsg_CancelBuildingBlob, OnCancelBuildingBlob)
|
| + IPC_MESSAGE_HANDLER(BlobStorageMsg_DoneBuildingBlob, OnDoneBuildingBlob)
|
| + IPC_MESSAGE_UNHANDLED(handled = false)
|
| + IPC_END_MESSAGE_MAP()
|
| + return handled;
|
| +}
|
| +
|
| +bool BlobMessageFilter::GetSupportedMessageClasses(
|
| + std::vector<uint32>* supported_message_classes) const {
|
| + supported_message_classes->push_back(BlobMsgStart);
|
| + return true;
|
| +}
|
| +
|
| +void BlobMessageFilter::OnChannelClosing() {
|
| + controller_->OnChannelClose();
|
| +}
|
| +
|
| +void BlobMessageFilter::OnRequestMemoryItem(
|
| + const std::string& uuid,
|
| + const std::vector<storage::BlobItemBytesRequest>& requests,
|
| + std::vector<base::SharedMemoryHandle> memory_handles,
|
| + const std::vector<IPC::PlatformFileForTransit>& file_handles) {
|
| + DCHECK_EQ(0, WorkerTaskRunner::Instance()->CurrentWorkerId());
|
| + controller_->OnMemoryRequest(uuid, requests, &memory_handles, file_handles,
|
| + sender_);
|
| +}
|
| +void BlobMessageFilter::OnCancelBuildingBlob(
|
| + const std::string& uuid,
|
| + storage::IPCBlobCreationCancelCode code) {
|
| + DCHECK_EQ(0, WorkerTaskRunner::Instance()->CurrentWorkerId());
|
| + controller_->OnCancel(uuid, code);
|
| +}
|
| +
|
| +void BlobMessageFilter::OnDoneBuildingBlob(const std::string& uuid) {
|
| + DCHECK_EQ(0, WorkerTaskRunner::Instance()->CurrentWorkerId());
|
| + controller_->OnDone(uuid);
|
| +}
|
| +
|
| +} // namespace content
|
|
|