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. 4 5#ifndef CONTENT_CHILD_CHILD_RESOURCE_MESSAGE_FILTER_H_ 6#define CONTENT_CHILD_CHILD_RESOURCE_MESSAGE_FILTER_H_ 7 8#include "base/memory/ref_counted.h" 9#include "ipc/message_filter.h" 10 11namespace base { 12class SingleThreadTaskRunner; 13} 14 15namespace content { 16class ResourceDispatcher; 17 18// Supplies ResourceDispatcher with timestamps for some resource messages. 19// 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. 26// 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. 30class ChildResourceMessageFilter : public IPC::MessageFilter { 31 public: 32 explicit ChildResourceMessageFilter(ResourceDispatcher* resource_dispatcher); 33 34 // IPC::MessageFilter implementation. 35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 36 37 private: 38 virtual ~ChildResourceMessageFilter(); 39 40 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 41 ResourceDispatcher* resource_dispatcher_; 42 43 DISALLOW_COPY_AND_ASSIGN(ChildResourceMessageFilter); 44}; 45 46} // namespace content 47 48#endif // CONTENT_CHILD_CHILD_RESOURCE_MESSAGE_FILTER_H_ 49