summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history/visit_log.cc
blob: 00f9fdc951a2184f003ff3a18a56cdacf0323f17 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2009 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 "chrome/browser/history/visit_log.h"

namespace history {

static VisitLog* g_visit_log = NULL;

VisitLog::VisitLog()
    : index_(0),
      num_add_(0),
      num_delete_(0),
      num_update_(0),
      num_select_(0) {
  memset(events_, NO_OP, sizeof(events_));
}

VisitLog::~VisitLog() {
}

void VisitLog::AddEvent(EventType event) {
  switch (event) {
    case ADD_VISIT:
      num_add_++;
      break;
    case DELETE_VISIT:
      num_delete_++;
      break;
    case UPDATE_VISIT:
      num_update_++;
      break;
    case SELECT_VISIT:
      num_select_++;
      break;
    default:
      return;
  }

  events_[index_++] = event;
  if (index_ == kVisitLogBufferSize)
    index_ = 0;
}

void InitVisitLog(VisitLog* vlog) {
  g_visit_log = vlog;
}

void AddEventToVisitLog(VisitLog::EventType event) {
  if (!g_visit_log)
    return;
  g_visit_log->AddEvent(event);
}

void ClearVisitLog() {
  g_visit_log = NULL;
}


}  // namespace history