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
3 // found in the LICENSE file.
5 #include "content/child/resource_scheduling_filter.h"
8 #include "base/location.h"
9 #include "content/child/resource_dispatcher.h"
10 #include "content/common/resource_messages.h"
11 #include "ipc/ipc_message.h"
12 #include "ipc/ipc_message_start.h"
16 ResourceSchedulingFilter::ResourceSchedulingFilter(
17 const scoped_refptr
<base::SingleThreadTaskRunner
>& main_thread_task_runner
,
18 ResourceDispatcher
* resource_dispatcher
)
19 : main_thread_task_runner_(main_thread_task_runner
),
20 resource_dispatcher_(resource_dispatcher
),
21 weak_ptr_factory_(this) {
22 DCHECK(main_thread_task_runner_
.get());
23 DCHECK(resource_dispatcher_
);
26 ResourceSchedulingFilter::~ResourceSchedulingFilter() {
29 bool ResourceSchedulingFilter::OnMessageReceived(const IPC::Message
& message
) {
30 // TODO(erikchen): Temporary code to help track http://crbug.com/527588.
31 content::CheckContentsOfDataReceivedMessage(&message
);
33 main_thread_task_runner_
->PostTask(
34 FROM_HERE
, base::Bind(&ResourceSchedulingFilter::DispatchMessage
,
35 weak_ptr_factory_
.GetWeakPtr(), message
));
39 bool ResourceSchedulingFilter::GetSupportedMessageClasses(
40 std::vector
<uint32
>* supported_message_classes
) const {
41 supported_message_classes
->push_back(ResourceMsgStart
);
45 void ResourceSchedulingFilter::DispatchMessage(const IPC::Message
& message
) {
46 resource_dispatcher_
->OnMessageReceived(message
);
49 } // namespace content