OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/child/resource_scheduling_filter.h" | 5 #include "content/child/resource_scheduling_filter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "content/child/resource_dispatcher.h" | 9 #include "content/child/resource_dispatcher.h" |
10 #include "content/common/resource_messages.h" | |
11 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
12 #include "ipc/ipc_message_start.h" | 11 #include "ipc/ipc_message_start.h" |
13 | 12 |
14 namespace content { | 13 namespace content { |
15 | 14 |
16 ResourceSchedulingFilter::ResourceSchedulingFilter( | 15 ResourceSchedulingFilter::ResourceSchedulingFilter( |
17 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, | 16 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, |
18 ResourceDispatcher* resource_dispatcher) | 17 ResourceDispatcher* resource_dispatcher) |
19 : main_thread_task_runner_(main_thread_task_runner), | 18 : main_thread_task_runner_(main_thread_task_runner), |
20 resource_dispatcher_(resource_dispatcher), | 19 resource_dispatcher_(resource_dispatcher), |
21 weak_ptr_factory_(this) { | 20 weak_ptr_factory_(this) { |
22 DCHECK(main_thread_task_runner_.get()); | 21 DCHECK(main_thread_task_runner_.get()); |
23 DCHECK(resource_dispatcher_); | 22 DCHECK(resource_dispatcher_); |
24 } | 23 } |
25 | 24 |
26 ResourceSchedulingFilter::~ResourceSchedulingFilter() { | 25 ResourceSchedulingFilter::~ResourceSchedulingFilter() { |
27 } | 26 } |
28 | 27 |
29 bool ResourceSchedulingFilter::OnMessageReceived(const IPC::Message& message) { | 28 bool ResourceSchedulingFilter::OnMessageReceived(const IPC::Message& message) { |
30 // TODO(erikchen): Temporary code to help track http://crbug.com/527588. | |
31 content::CheckContentsOfDataReceivedMessage(&message); | |
32 | |
33 main_thread_task_runner_->PostTask( | 29 main_thread_task_runner_->PostTask( |
34 FROM_HERE, base::Bind(&ResourceSchedulingFilter::DispatchMessage, | 30 FROM_HERE, base::Bind(&ResourceSchedulingFilter::DispatchMessage, |
35 weak_ptr_factory_.GetWeakPtr(), message)); | 31 weak_ptr_factory_.GetWeakPtr(), message)); |
36 return true; | 32 return true; |
37 } | 33 } |
38 | 34 |
39 bool ResourceSchedulingFilter::GetSupportedMessageClasses( | 35 bool ResourceSchedulingFilter::GetSupportedMessageClasses( |
40 std::vector<uint32>* supported_message_classes) const { | 36 std::vector<uint32>* supported_message_classes) const { |
41 supported_message_classes->push_back(ResourceMsgStart); | 37 supported_message_classes->push_back(ResourceMsgStart); |
42 return true; | 38 return true; |
43 } | 39 } |
44 | 40 |
45 void ResourceSchedulingFilter::DispatchMessage(const IPC::Message& message) { | 41 void ResourceSchedulingFilter::DispatchMessage(const IPC::Message& message) { |
46 resource_dispatcher_->OnMessageReceived(message); | 42 resource_dispatcher_->OnMessageReceived(message); |
47 } | 43 } |
48 | 44 |
49 } // namespace content | 45 } // namespace content |
OLD | NEW |