| 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 #ifndef CONTENT_CHILD_RESOURCE_SCHEDULING_FILTER_H_ | 5 #ifndef CONTENT_CHILD_RESOURCE_SCHEDULING_FILTER_H_ |
| 6 #define CONTENT_CHILD_RESOURCE_SCHEDULING_FILTER_H_ | 6 #define CONTENT_CHILD_RESOURCE_SCHEDULING_FILTER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <map> | 10 #include <map> |
| 9 | 11 |
| 10 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 12 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 13 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 14 #include "ipc/message_filter.h" | 17 #include "ipc/message_filter.h" |
| 15 | 18 |
| 16 namespace blink { | 19 namespace blink { |
| 17 class WebTaskRunner; | 20 class WebTaskRunner; |
| 18 } | 21 } |
| 19 | 22 |
| 20 namespace content { | 23 namespace content { |
| 21 class ResourceDispatcher; | 24 class ResourceDispatcher; |
| 22 | 25 |
| 23 // This filter is used to dispatch resource messages on a specific | 26 // This filter is used to dispatch resource messages on a specific |
| 24 // SingleThreadTaskRunner to facilitate task scheduling. | 27 // SingleThreadTaskRunner to facilitate task scheduling. |
| 25 class CONTENT_EXPORT ResourceSchedulingFilter : public IPC::MessageFilter { | 28 class CONTENT_EXPORT ResourceSchedulingFilter : public IPC::MessageFilter { |
| 26 public: | 29 public: |
| 27 ResourceSchedulingFilter(const scoped_refptr<base::SingleThreadTaskRunner>& | 30 ResourceSchedulingFilter(const scoped_refptr<base::SingleThreadTaskRunner>& |
| 28 main_thread_task_runner, | 31 main_thread_task_runner, |
| 29 ResourceDispatcher* resource_dispatcher); | 32 ResourceDispatcher* resource_dispatcher); |
| 30 | 33 |
| 31 // IPC::MessageFilter overrides: | 34 // IPC::MessageFilter overrides: |
| 32 bool OnMessageReceived(const IPC::Message& message) override; | 35 bool OnMessageReceived(const IPC::Message& message) override; |
| 33 | 36 |
| 34 bool GetSupportedMessageClasses( | 37 bool GetSupportedMessageClasses( |
| 35 std::vector<uint32>* supported_message_classes) const override; | 38 std::vector<uint32_t>* supported_message_classes) const override; |
| 36 | 39 |
| 37 // Sets the task runner associated with request messages with |id|. | 40 // Sets the task runner associated with request messages with |id|. |
| 38 void SetRequestIdTaskRunner( | 41 void SetRequestIdTaskRunner( |
| 39 int id, scoped_ptr<blink::WebTaskRunner> web_task_runner); | 42 int id, scoped_ptr<blink::WebTaskRunner> web_task_runner); |
| 40 | 43 |
| 41 // Removes the task runner associated with |id|. | 44 // Removes the task runner associated with |id|. |
| 42 void ClearRequestIdTaskRunner(int id); | 45 void ClearRequestIdTaskRunner(int id); |
| 43 | 46 |
| 44 void DispatchMessage(const IPC::Message& message); | 47 void DispatchMessage(const IPC::Message& message); |
| 45 | 48 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 57 ResourceDispatcher* resource_dispatcher_; // NOT OWNED | 60 ResourceDispatcher* resource_dispatcher_; // NOT OWNED |
| 58 base::WeakPtrFactory<ResourceSchedulingFilter> weak_ptr_factory_; | 61 base::WeakPtrFactory<ResourceSchedulingFilter> weak_ptr_factory_; |
| 59 | 62 |
| 60 private: | 63 private: |
| 61 DISALLOW_COPY_AND_ASSIGN(ResourceSchedulingFilter); | 64 DISALLOW_COPY_AND_ASSIGN(ResourceSchedulingFilter); |
| 62 }; | 65 }; |
| 63 | 66 |
| 64 } // namespace content | 67 } // namespace content |
| 65 | 68 |
| 66 #endif // CONTENT_CHILD_RESOURCE_SCHEDULING_FILTER_H_ | 69 #endif // CONTENT_CHILD_RESOURCE_SCHEDULING_FILTER_H_ |
| OLD | NEW |