OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 CriticalSectionScoped synchronize(table_lock_); | 198 CriticalSectionScoped synchronize(table_lock_); |
199 assert(columns_.count(column_name) > 0); | 199 assert(columns_.count(column_name) > 0); |
200 if (columns_.count(column_name) == 0) | 200 if (columns_.count(column_name) == 0) |
201 return -1; | 201 return -1; |
202 return current_row_->InsertCell(column_name, value_container); | 202 return current_row_->InsertCell(column_name, value_container); |
203 } | 203 } |
204 | 204 |
205 int LogTable::CreateLogFile(const std::string& file_name) { | 205 int LogTable::CreateLogFile(const std::string& file_name) { |
206 if (file_name.length() == 0) | 206 if (file_name.length() == 0) |
207 return -1; | 207 return -1; |
208 if (file_->Open()) | 208 if (file_->is_open()) |
209 return -1; | 209 return -1; |
210 file_->OpenFile(file_name.c_str(), | 210 // Open with read/write permissions |
211 false, // Open with read/write permissions | 211 return file_->OpenFile(file_name.c_str(), false) ? 0 : -1; |
212 false, // Don't wraparound and write at the beginning when | |
213 // the file is full | |
214 true); // Open as a text file | |
215 if (file_ == NULL) | |
216 return -1; | |
217 return 0; | |
218 } | 212 } |
219 | 213 |
220 void LogTable::Flush() { | 214 void LogTable::Flush() { |
221 ColumnMap::iterator column_it; | 215 ColumnMap::iterator column_it; |
222 bool commit_header = false; | 216 bool commit_header = false; |
223 if (write_header_) { | 217 if (write_header_) { |
224 CriticalSectionScoped synchronize(table_lock_); | 218 CriticalSectionScoped synchronize(table_lock_); |
225 if (write_header_) { | 219 if (write_header_) { |
226 commit_header = true; | 220 commit_header = true; |
227 write_header_ = false; | 221 write_header_ = false; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 flush_event_->Wait(WEBRTC_EVENT_INFINITE); | 419 flush_event_->Wait(WEBRTC_EVENT_INFINITE); |
426 Flush(); | 420 Flush(); |
427 } | 421 } |
428 | 422 |
429 void DataLogImpl::StopThread() { | 423 void DataLogImpl::StopThread() { |
430 flush_event_->Set(); | 424 flush_event_->Set(); |
431 file_writer_thread_->Stop(); | 425 file_writer_thread_->Stop(); |
432 } | 426 } |
433 | 427 |
434 } // namespace webrtc | 428 } // namespace webrtc |
OLD | NEW |