summaryrefslogtreecommitdiffstats
path: root/chrome/browser/state_tracker.cc
blob: 03af6315f5a22f388fd6c7284e5da1f7351f9b87 (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 (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/state_tracker.h"

// Number of characters the buffer contains.
static const size_t kSize = 256;

StateTracker::StateTracker()
  : index_(0),
    content_(new char[kSize]) {
  for (size_t i = 0; i < kSize; ++i)
    content_[i] = '\0';
}

void StateTracker::Append(const std::string& text) {
  if (text.size() >= kSize) {
    NOTREACHED();
    return;
  }
  for (size_t i = 0; i < text.size(); ++i) {
    content_[index_] = text[i];
    index_ = (index_ + 1) % kSize;
  }
  content_[index_] = '!';
}

void StateTracker::Crash() {
  volatile char state[kSize];
  for (size_t i = 0; i < kSize; ++i)
    state[i] = content_[i];

  CHECK(false);
}