Revert of Move Extension ScriptContext creation into ScriptContextSet. (patchset...
[chromium-blink-merge.git] / content / child / resource_scheduling_filter.cc
blob843cd8713f4c58047c2a4699a9a88875d51e5acf
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"
7 #include "base/bind.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"
13 namespace content {
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));
32 return true;
35 bool ResourceSchedulingFilter::GetSupportedMessageClasses(
36 std::vector<uint32>* supported_message_classes) const {
37 supported_message_classes->push_back(ResourceMsgStart);
38 return true;
41 void ResourceSchedulingFilter::DispatchMessage(const IPC::Message& message) {
42 resource_dispatcher_->OnMessageReceived(message);
45 } // namespace content