| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "content/child/resource_dispatcher.h" | 11 #include "content/child/resource_dispatcher.h" |
| 12 #include "ipc/ipc_message.h" | 12 #include "ipc/ipc_message.h" |
| 13 #include "ipc/ipc_message_start.h" | 13 #include "ipc/ipc_message_start.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 ResourceSchedulingFilter::ResourceSchedulingFilter( | 17 ResourceSchedulingFilter::ResourceSchedulingFilter( |
| 18 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, | 18 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_task_runner, |
| 19 ResourceDispatcher* resource_dispatcher) | 19 ResourceDispatcher* resource_dispatcher) |
| 20 : main_thread_task_runner_(main_thread_task_runner), | 20 : main_thread_task_runner_(main_thread_task_runner), |
| 21 resource_dispatcher_(resource_dispatcher), | 21 resource_dispatcher_(resource_dispatcher->GetWeakPtr()), |
| 22 weak_ptr_factory_(this) { | 22 weak_ptr_factory_(this) { |
| 23 DCHECK(main_thread_task_runner_.get()); | 23 DCHECK(main_thread_task_runner_.get()); |
| 24 DCHECK(resource_dispatcher_); | |
| 25 } | 24 } |
| 26 | 25 |
| 27 ResourceSchedulingFilter::~ResourceSchedulingFilter() { | 26 ResourceSchedulingFilter::~ResourceSchedulingFilter() { |
| 28 } | 27 } |
| 29 | 28 |
| 30 bool ResourceSchedulingFilter::OnMessageReceived(const IPC::Message& message) { | 29 bool ResourceSchedulingFilter::OnMessageReceived(const IPC::Message& message) { |
| 31 base::AutoLock lock(request_id_to_task_runner_map_lock_); | 30 base::AutoLock lock(request_id_to_task_runner_map_lock_); |
| 32 int request_id; | 31 int request_id; |
| 33 | 32 |
| 34 base::PickleIterator pickle_iterator(message); | 33 base::PickleIterator pickle_iterator(message); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 64 request_id_to_task_runner_map_.erase(id); | 63 request_id_to_task_runner_map_.erase(id); |
| 65 } | 64 } |
| 66 | 65 |
| 67 bool ResourceSchedulingFilter::GetSupportedMessageClasses( | 66 bool ResourceSchedulingFilter::GetSupportedMessageClasses( |
| 68 std::vector<uint32_t>* supported_message_classes) const { | 67 std::vector<uint32_t>* supported_message_classes) const { |
| 69 supported_message_classes->push_back(ResourceMsgStart); | 68 supported_message_classes->push_back(ResourceMsgStart); |
| 70 return true; | 69 return true; |
| 71 } | 70 } |
| 72 | 71 |
| 73 void ResourceSchedulingFilter::DispatchMessage(const IPC::Message& message) { | 72 void ResourceSchedulingFilter::DispatchMessage(const IPC::Message& message) { |
| 74 resource_dispatcher_->OnMessageReceived(message); | 73 if (resource_dispatcher_) |
| 74 resource_dispatcher_->OnMessageReceived(message); |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace content | 77 } // namespace content |
| OLD | NEW |