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 "ipc/ipc_message.h"
11 #include "ipc/ipc_message_start.h"
15 ResourceSchedulingFilter::ResourceSchedulingFilter(
16 const scoped_refptr
<base::SingleThreadTaskRunner
>& main_thread_task_runner
,
17 ResourceDispatcher
* resource_dispatcher
)
18 : main_thread_task_runner_(main_thread_task_runner
),
19 resource_dispatcher_(resource_dispatcher
),
20 weak_ptr_factory_(this) {
21 DCHECK(main_thread_task_runner_
.get());
22 DCHECK(resource_dispatcher_
);
25 ResourceSchedulingFilter::~ResourceSchedulingFilter() {
28 bool ResourceSchedulingFilter::OnMessageReceived(const IPC::Message
& message
) {
29 main_thread_task_runner_
->PostTask(
30 FROM_HERE
, base::Bind(&ResourceSchedulingFilter::DispatchMessage
,
31 weak_ptr_factory_
.GetWeakPtr(), message
));
35 bool ResourceSchedulingFilter::GetSupportedMessageClasses(
36 std::vector
<uint32
>* supported_message_classes
) const {
37 supported_message_classes
->push_back(ResourceMsgStart
);
41 void ResourceSchedulingFilter::DispatchMessage(const IPC::Message
& message
) {
42 resource_dispatcher_
->OnMessageReceived(message
);
45 } // namespace content