OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 return result; | 170 return result; |
171 } | 171 } |
172 | 172 |
173 bool FileRotatingStream::Flush() { | 173 bool FileRotatingStream::Flush() { |
174 if (!file_stream_) { | 174 if (!file_stream_) { |
175 return false; | 175 return false; |
176 } | 176 } |
177 return file_stream_->Flush(); | 177 return file_stream_->Flush(); |
178 } | 178 } |
179 | 179 |
| 180 bool FileRotatingStream::GetSize(size_t* size) const { |
| 181 if (mode_ != kRead) { |
| 182 // Not possible to get accurate size on disk when writing because of |
| 183 // potential buffering. |
| 184 return false; |
| 185 } |
| 186 DCHECK(size); |
| 187 *size = 0; |
| 188 size_t total_size = 0; |
| 189 for (auto file_name : file_names_) { |
| 190 Pathname pathname(file_name); |
| 191 size_t file_size = 0; |
| 192 if (Filesystem::GetFileSize(file_name, &file_size)) { |
| 193 total_size += file_size; |
| 194 } |
| 195 } |
| 196 *size = total_size; |
| 197 return true; |
| 198 } |
| 199 |
180 void FileRotatingStream::Close() { | 200 void FileRotatingStream::Close() { |
181 CloseCurrentFile(); | 201 CloseCurrentFile(); |
182 } | 202 } |
183 | 203 |
184 bool FileRotatingStream::Open() { | 204 bool FileRotatingStream::Open() { |
185 switch (mode_) { | 205 switch (mode_) { |
186 case kRead: | 206 case kRead: |
187 // Defer opening to when we first read since we want to return read error | 207 // Defer opening to when we first read since we want to return read error |
188 // if we fail to open next file. | 208 // if we fail to open next file. |
189 return true; | 209 return true; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 391 |
372 size_t CallSessionFileRotatingStream::GetNumRotatingLogFiles( | 392 size_t CallSessionFileRotatingStream::GetNumRotatingLogFiles( |
373 size_t max_total_log_size) { | 393 size_t max_total_log_size) { |
374 // At minimum have two rotating files. Otherwise split the available log size | 394 // At minimum have two rotating files. Otherwise split the available log size |
375 // evenly across 1MB files. | 395 // evenly across 1MB files. |
376 return std::max((size_t)2, | 396 return std::max((size_t)2, |
377 (max_total_log_size / 2) / kRotatingLogFileDefaultSize); | 397 (max_total_log_size / 2) / kRotatingLogFileDefaultSize); |
378 } | 398 } |
379 | 399 |
380 } // namespace rtc | 400 } // namespace rtc |
OLD | NEW |