Chromium Code Reviews| Index: content/child/quota_message_filter.cc |
| diff --git a/content/child/quota_message_filter.cc b/content/child/quota_message_filter.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3114a72696db309271f51c591623c51c70d571ff |
| --- /dev/null |
| +++ b/content/child/quota_message_filter.cc |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2013 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/quota_message_filter.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/location.h" |
| +#include "base/message_loop/message_loop_proxy.h" |
| +#include "base/pickle.h" |
| +#include "content/child/quota_dispatcher.h" |
| +#include "content/child/thread_safe_sender.h" |
| +#include "content/common/quota_messages.h" |
| +#include "webkit/child/worker_task_runner.h" |
| + |
| +using webkit_glue::WorkerTaskRunner; |
| + |
| +namespace content { |
| + |
| +QuotaMessageFilter::QuotaMessageFilter( |
| + ThreadSafeSender* thread_safe_sender) |
| + : main_thread_loop_proxy_(base::MessageLoopProxy::current()), |
| + thread_safe_sender_(thread_safe_sender) { |
| +} |
| + |
| +bool QuotaMessageFilter::OnMessageReceived(const IPC::Message& msg) { |
| + if (IPC_MESSAGE_CLASS(msg) != QuotaMsgStart) |
| + return false; |
| + int ipc_thread_id = -1; |
| + bool result = PickleIterator(msg).ReadInt(&ipc_thread_id); |
| + DCHECK(result); |
| + base::Closure closure = base::Bind( |
| + &QuotaMessageFilter::DispatchMessage, this, msg); |
| + if (!ipc_thread_id) { |
| + main_thread_loop_proxy_->PostTask(FROM_HERE, closure); |
| + return true; |
| + } |
| + WorkerTaskRunner::Instance()->PostTask(ipc_thread_id, closure); |
| + return true; |
| +} |
| + |
| +QuotaMessageFilter::~QuotaMessageFilter() {} |
| + |
| +void QuotaMessageFilter::DispatchMessage(const IPC::Message& msg) { |
| + QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get()) |
| + ->OnMessageReceived(msg); |
|
jam
2013/07/26 04:57:30
nit: the "->" needs to be on the previous line...
kinuko
2013/07/29 04:31:55
Done.
|
| +} |
| + |
| +} // namespace content |