| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/shared_impl/file_io_state_manager.h" | 5 #include "ppapi/shared_impl/file_io_state_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 | 9 |
| 10 namespace ppapi { | 10 namespace ppapi { |
| 11 | 11 |
| 12 FileIOStateManager::FileIOStateManager() | 12 FileIOStateManager::FileIOStateManager() |
| 13 : num_pending_ops_(0), | 13 : num_pending_ops_(0), pending_op_(OPERATION_NONE), file_open_(false) {} |
| 14 pending_op_(OPERATION_NONE), | |
| 15 file_open_(false) { | |
| 16 } | |
| 17 | 14 |
| 18 FileIOStateManager::~FileIOStateManager() { | 15 FileIOStateManager::~FileIOStateManager() {} |
| 19 } | |
| 20 | 16 |
| 21 void FileIOStateManager::SetOpenSucceed() { | 17 void FileIOStateManager::SetOpenSucceed() { file_open_ = true; } |
| 22 file_open_ = true; | |
| 23 } | |
| 24 | 18 |
| 25 int32_t FileIOStateManager::CheckOperationState(OperationType new_op, | 19 int32_t FileIOStateManager::CheckOperationState(OperationType new_op, |
| 26 bool should_be_open) { | 20 bool should_be_open) { |
| 27 if (should_be_open) { | 21 if (should_be_open) { |
| 28 if (!file_open_) | 22 if (!file_open_) |
| 29 return PP_ERROR_FAILED; | 23 return PP_ERROR_FAILED; |
| 30 } else { | 24 } else { |
| 31 if (file_open_) | 25 if (file_open_) |
| 32 return PP_ERROR_FAILED; | 26 return PP_ERROR_FAILED; |
| 33 } | 27 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 46 num_pending_ops_++; | 40 num_pending_ops_++; |
| 47 } | 41 } |
| 48 | 42 |
| 49 void FileIOStateManager::SetOperationFinished() { | 43 void FileIOStateManager::SetOperationFinished() { |
| 50 DCHECK_GT(num_pending_ops_, 0); | 44 DCHECK_GT(num_pending_ops_, 0); |
| 51 if (--num_pending_ops_ == 0) | 45 if (--num_pending_ops_ == 0) |
| 52 pending_op_ = OPERATION_NONE; | 46 pending_op_ = OPERATION_NONE; |
| 53 } | 47 } |
| 54 | 48 |
| 55 } // namespace ppapi | 49 } // namespace ppapi |
| 56 | |
| OLD | NEW |