OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "content/child/resource_scheduling_filter.h" |
| 6 |
| 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" |
| 12 |
| 13 namespace content { |
| 14 |
| 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_); |
| 23 } |
| 24 |
| 25 ResourceSchedulingFilter::~ResourceSchedulingFilter() { |
| 26 } |
| 27 |
| 28 bool ResourceSchedulingFilter::OnMessageReceived(const IPC::Message& message) { |
| 29 main_thread_task_runner_->PostTask( |
| 30 FROM_HERE, |
| 31 base::Bind(&ResourceSchedulingFilter::DispatchMessage, |
| 32 weak_ptr_factory_.GetWeakPtr(), |
| 33 message)); |
| 34 return true; |
| 35 } |
| 36 |
| 37 bool ResourceSchedulingFilter::GetSupportedMessageClasses( |
| 38 std::vector<uint32>* supported_message_classes) const { |
| 39 supported_message_classes->push_back(ResourceMsgStart); |
| 40 return true; |
| 41 } |
| 42 |
| 43 void ResourceSchedulingFilter::DispatchMessage(const IPC::Message& message) { |
| 44 resource_dispatcher_->OnMessageReceived(message); |
| 45 } |
| 46 |
| 47 } // namespace content |
OLD | NEW |