1 // Copyright 2013 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 #ifndef CONTENT_CHILD_CHILD_RESOURCE_MESSAGE_FILTER_H_
6 #define CONTENT_CHILD_CHILD_RESOURCE_MESSAGE_FILTER_H_
8 #include "base/memory/ref_counted.h"
9 #include "ipc/message_filter.h"
12 class SingleThreadTaskRunner;
16 class ResourceDispatcher;
18 // Supplies ResourceDispatcher with timestamps for some resource messages.
20 // Background: ResourceDispatcher converts browser process time to child
21 // process time. This is done to achieve coherent timeline. Conversion is
22 // a linear transformation such that given browser process time range is
23 // mapped to corresponding child process time range. Timestamps for child
24 // process time range should be taken by IO thread when resource messages
25 // arrive. Otherwise, timestamps may be affected by long rendering / JS task.
27 // When specific message is processed by this filter, new task charged
28 // with timestamp is posted to main thread. This task is processed just before
29 // resource message and invokes ResourceDispatcher::set_io_timestamp.
30 class ChildResourceMessageFilter : public IPC::MessageFilter {
32 explicit ChildResourceMessageFilter(ResourceDispatcher* resource_dispatcher);
34 // IPC::MessageFilter implementation.
35 bool OnMessageReceived(const IPC::Message& message) override;
38 ~ChildResourceMessageFilter() override;
40 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
41 ResourceDispatcher* resource_dispatcher_;
43 DISALLOW_COPY_AND_ASSIGN(ChildResourceMessageFilter);
46 } // namespace content
48 #endif // CONTENT_CHILD_CHILD_RESOURCE_MESSAGE_FILTER_H_