1// Copyright 2014 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 "ppapi/shared_impl/file_growth.h"
6
7#include "base/logging.h"
8
9namespace ppapi {
10
11FileGrowth::FileGrowth() : max_written_offset(0), append_mode_write_amount(0) {}
12
13FileGrowth::FileGrowth(int64_t max_written_offset,
14                       int64_t append_mode_write_amount)
15    : max_written_offset(max_written_offset),
16      append_mode_write_amount(append_mode_write_amount) {
17  DCHECK_LE(0, max_written_offset);
18  DCHECK_LE(0, append_mode_write_amount);
19}
20
21FileGrowthMap FileSizeMapToFileGrowthMapForTesting(
22    const FileSizeMap& file_sizes) {
23  FileGrowthMap file_growths;
24  for (FileSizeMap::const_iterator it = file_sizes.begin();
25       it != file_sizes.end();
26       ++it)
27    file_growths[it->first] = FileGrowth(it->second, 0);
28  return file_growths;
29}
30
31FileSizeMap FileGrowthMapToFileSizeMapForTesting(
32    const FileGrowthMap& file_growths) {
33  FileSizeMap file_sizes;
34  for (FileGrowthMap::const_iterator it = file_growths.begin();
35       it != file_growths.end();
36       ++it)
37    file_sizes[it->first] = it->second.max_written_offset;
38  return file_sizes;
39}
40
41}  // namespace ppapi
42