1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file.
4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/renderer/stats_collection_observer.h"
6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
7eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h"
8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/renderer/render_view_impl.h"
9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content {
11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)StatsCollectionObserver::StatsCollectionObserver(RenderViewImpl* render_view)
13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    : RenderViewObserver(render_view) {
14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)StatsCollectionObserver::~StatsCollectionObserver() {
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void StatsCollectionObserver::DidStartLoading() {
20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  DCHECK(start_time_.is_null());
21f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  start_time_ = base::Time::Now();
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void StatsCollectionObserver::DidStopLoading() {
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  DCHECK(stop_time_.is_null());
26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  stop_time_ = base::Time::Now();
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // Stop observing so we don't get called again.
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view());
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  impl->RemoveObserver(this);
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}  // namespace content
34