This source file includes following definitions.
- message_port_message_filter_
- OnChannelClosing
- OnMessageReceived
- GetNextRoutingID
- OnCreateWorker
- OnForwardToWorker
- OnDocumentDetached
#include "content/browser/worker_host/worker_message_filter.h"
#include "content/browser/message_port_message_filter.h"
#include "content/browser/worker_host/worker_service_impl.h"
#include "content/common/view_messages.h"
#include "content/common/worker_messages.h"
#include "content/public/browser/resource_context.h"
namespace content {
WorkerMessageFilter::WorkerMessageFilter(
int render_process_id,
ResourceContext* resource_context,
const WorkerStoragePartition& partition,
MessagePortMessageFilter* message_port_message_filter)
: BrowserMessageFilter(ViewMsgStart),
render_process_id_(render_process_id),
resource_context_(resource_context),
partition_(partition),
message_port_message_filter_(message_port_message_filter) {
DCHECK(resource_context);
}
WorkerMessageFilter::~WorkerMessageFilter() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
void WorkerMessageFilter::OnChannelClosing() {
WorkerServiceImpl::GetInstance()->OnWorkerMessageFilterClosing(this);
}
bool WorkerMessageFilter::OnMessageReceived(const IPC::Message& message,
bool* message_was_ok) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(WorkerMessageFilter, message, *message_was_ok)
IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWorker, OnCreateWorker)
IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToWorker, OnForwardToWorker)
IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentDetached, OnDocumentDetached)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
return handled;
}
int WorkerMessageFilter::GetNextRoutingID() {
return message_port_message_filter_->GetNextRoutingID();
}
void WorkerMessageFilter::OnCreateWorker(
const ViewHostMsg_CreateWorker_Params& params,
int* route_id) {
bool url_error = false;
*route_id = GetNextRoutingID();
WorkerServiceImpl::GetInstance()->CreateWorker(
params, *route_id, this, resource_context_, partition_, &url_error);
if (url_error)
*route_id = MSG_ROUTING_NONE;
}
void WorkerMessageFilter::OnForwardToWorker(const IPC::Message& message) {
WorkerServiceImpl::GetInstance()->ForwardToWorker(message, this);
}
void WorkerMessageFilter::OnDocumentDetached(unsigned long long document_id) {
WorkerServiceImpl::GetInstance()->DocumentDetached(document_id, this);
}
}