summaryrefslogtreecommitdiffstats
path: root/content/child/child_resource_message_filter.cc
blob: 0a761713ad4ad857c89149d6a9230152643af791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/child/child_resource_message_filter.h"

#include "base/bind.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "content/child/resource_dispatcher.h"
#include "content/common/resource_messages.h"

namespace content {

ChildResourceMessageFilter::ChildResourceMessageFilter(
    ResourceDispatcher* resource_dispatcher)
    : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
      resource_dispatcher_(resource_dispatcher) {}

ChildResourceMessageFilter::~ChildResourceMessageFilter() {}

bool ChildResourceMessageFilter::OnMessageReceived(
    const IPC::Message& message) {
  if (message.type() == ResourceMsg_RequestComplete::ID ||
      message.type() == ResourceMsg_ReceivedResponse::ID ||
      message.type() == ResourceMsg_ReceivedRedirect::ID) {
    main_thread_task_runner_->PostTask(FROM_HERE, base::Bind(
        &ResourceDispatcher::set_io_timestamp,
        base::Unretained(resource_dispatcher_),
        base::TimeTicks::Now()));
  }
  return false;
}

}  // namespace content