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
3 // found in the LICENSE file.
5 #include "ppapi/shared_impl/file_io_state_manager.h"
7 #include "base/logging.h"
8 #include "ppapi/c/pp_errors.h"
12 FileIOStateManager::FileIOStateManager()
13 : num_pending_ops_(0),
14 pending_op_(OPERATION_NONE
),
18 FileIOStateManager::~FileIOStateManager() {
21 void FileIOStateManager::SetOpenSucceed() {
25 int32_t FileIOStateManager::CheckOperationState(OperationType new_op
,
26 bool should_be_open
) {
29 return PP_ERROR_FAILED
;
32 return PP_ERROR_FAILED
;
35 if (pending_op_
!= OPERATION_NONE
&&
36 (pending_op_
!= new_op
|| pending_op_
== OPERATION_EXCLUSIVE
))
37 return PP_ERROR_INPROGRESS
;
42 void FileIOStateManager::SetPendingOperation(OperationType new_op
) {
43 DCHECK(pending_op_
== OPERATION_NONE
||
44 (pending_op_
!= OPERATION_EXCLUSIVE
&& pending_op_
== new_op
));
49 void FileIOStateManager::SetOperationFinished() {
50 DCHECK_GT(num_pending_ops_
, 0);
51 if (--num_pending_ops_
== 0)
52 pending_op_
= OPERATION_NONE
;