file_growth.cc revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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() 12 : max_written_offset(0), 13 append_mode_write_amount(0) { 14} 15 16FileGrowth::FileGrowth(int64_t max_written_offset, 17 int64_t append_mode_write_amount) 18 : max_written_offset(max_written_offset), 19 append_mode_write_amount(append_mode_write_amount) { 20 DCHECK_LE(0, max_written_offset); 21 DCHECK_LE(0, append_mode_write_amount); 22} 23 24FileGrowthMap FileSizeMapToFileGrowthMapForTesting( 25 const FileSizeMap& file_sizes) { 26 FileGrowthMap file_growths; 27 for (FileSizeMap::const_iterator it = file_sizes.begin(); 28 it != file_sizes.end(); ++it) 29 file_growths[it->first] = FileGrowth(it->second, 0); 30 return file_growths; 31} 32 33FileSizeMap FileGrowthMapToFileSizeMapForTesting( 34 const FileGrowthMap& file_growths) { 35 FileSizeMap file_sizes; 36 for (FileGrowthMap::const_iterator it = file_growths.begin(); 37 it != file_growths.end(); ++it) 38 file_sizes[it->first] = it->second.max_written_offset; 39 return file_sizes; 40} 41 42} // namespace ppapi 43