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

Side by Side Diff: content/child/quota_message_filter.cc

Issue 20015002: Make Platform::queryStorageUsageAndQuota work from worker threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/child/quota_message_filter.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/pickle.h"
11 #include "content/child/quota_dispatcher.h"
12 #include "content/child/thread_safe_sender.h"
13 #include "content/common/quota_messages.h"
14 #include "webkit/child/worker_task_runner.h"
15
16 using webkit_glue::WorkerTaskRunner;
17
18 namespace content {
19
20 QuotaMessageFilter::QuotaMessageFilter(
21 ThreadSafeSender* thread_safe_sender)
22 : main_thread_loop_proxy_(base::MessageLoopProxy::current()),
23 thread_safe_sender_(thread_safe_sender) {
24 }
25
26 bool QuotaMessageFilter::OnMessageReceived(const IPC::Message& msg) {
27 if (IPC_MESSAGE_CLASS(msg) != QuotaMsgStart)
28 return false;
29 int ipc_thread_id = -1;
30 bool result = PickleIterator(msg).ReadInt(&ipc_thread_id);
31 DCHECK(result);
32 base::Closure closure = base::Bind(
33 &QuotaMessageFilter::DispatchMessage, this, msg);
34 if (!ipc_thread_id) {
35 main_thread_loop_proxy_->PostTask(FROM_HERE, closure);
36 return true;
37 }
38 WorkerTaskRunner::Instance()->PostTask(ipc_thread_id, closure);
39 return true;
40 }
41
42 QuotaMessageFilter::~QuotaMessageFilter() {}
43
44 void QuotaMessageFilter::DispatchMessage(const IPC::Message& msg) {
45 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get())
46 ->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.
47 }
48
49 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698