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

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: use map 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
« no previous file with comments | « content/child/quota_message_filter.h ('k') | content/content_child.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 request_id = -1;
30 bool result = PickleIterator(msg).ReadInt(&request_id);
31 DCHECK(result);
32 base::Closure closure = base::Bind(
33 &QuotaMessageFilter::DispatchMessage, this, msg);
34 int thread_id = 0;
35 {
36 base::AutoLock lock(request_id_map_lock_);
37 RequestIdToThreadId::iterator found = request_id_map_.find(request_id);
38 if (found != request_id_map_.end()) {
39 thread_id = found->second;
40 request_id_map_.erase(found);
41 }
42 }
43 if (!thread_id) {
44 main_thread_loop_proxy_->PostTask(FROM_HERE, closure);
45 return true;
46 }
47 WorkerTaskRunner::Instance()->PostTask(thread_id, closure);
48 return true;
49 }
50
51 void QuotaMessageFilter::RegisterRequestID(int request_id, int thread_id) {
52 base::AutoLock lock(request_id_map_lock_);
53 request_id_map_[request_id] = thread_id;
54 }
55
56 QuotaMessageFilter::~QuotaMessageFilter() {}
57
58 void QuotaMessageFilter::DispatchMessage(const IPC::Message& msg) {
59 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(), this)
60 ->OnMessageReceived(msg);
jam 2013/07/26 04:57:31 nit: normally lines don't start with "->"
kinuko 2013/07/29 04:31:55 Done.
61 }
62
63 } // namespace content
OLDNEW
« no previous file with comments | « content/child/quota_message_filter.h ('k') | content/content_child.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698