Home | History | Annotate | Download | only in child
      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 #include "content/child/child_resource_message_filter.h"
      6 
      7 #include "base/bind.h"
      8 #include "base/single_thread_task_runner.h"
      9 #include "base/thread_task_runner_handle.h"
     10 #include "content/child/resource_dispatcher.h"
     11 #include "content/common/resource_messages.h"
     12 
     13 namespace content {
     14 
     15 ChildResourceMessageFilter::ChildResourceMessageFilter(
     16     ResourceDispatcher* resource_dispatcher)
     17     : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
     18       resource_dispatcher_(resource_dispatcher) {}
     19 
     20 ChildResourceMessageFilter::~ChildResourceMessageFilter() {}
     21 
     22 bool ChildResourceMessageFilter::OnMessageReceived(
     23     const IPC::Message& message) {
     24   if (message.type() == ResourceMsg_RequestComplete::ID ||
     25       message.type() == ResourceMsg_ReceivedResponse::ID ||
     26       message.type() == ResourceMsg_ReceivedRedirect::ID) {
     27     main_thread_task_runner_->PostTask(FROM_HERE, base::Bind(
     28         &ResourceDispatcher::set_io_timestamp,
     29         base::Unretained(resource_dispatcher_),
     30         base::TimeTicks::Now()));
     31   }
     32   return false;
     33 }
     34 
     35 }  // namespace content
     36