Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef PPAPI_SHARED_IMPL_FILE_IO_STATE_MANAGER_H_ | |
| 6 #define PPAPI_SHARED_IMPL_FILE_IO_STATE_MANAGER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "ppapi/shared_impl/ppapi_shared_export.h" | |
| 11 | |
| 12 namespace ppapi { | |
| 13 | |
| 14 // FileIOStateManager is a helper class that maintains the state of operations. | |
| 15 // For example, some operations are mutually exclusive, meaning that an | |
| 16 // operation could be recjected because of the current pending operation. Also, | |
|
raymes
2012/11/29 23:55:19
-recjected->rejected
-There are 2 spaces at the en
victorhsieh
2012/11/30 01:17:21
I do see other 2 spaces after period in other ppap
| |
| 17 // most of the operations only work when the file has been opened. | |
| 18 class PPAPI_SHARED_EXPORT FileIOStateManager { | |
| 19 public: | |
| 20 FileIOStateManager(); | |
| 21 ~FileIOStateManager(); | |
| 22 | |
| 23 enum OperationType { | |
| 24 // There is no pending operation right now. | |
| 25 OPERATION_NONE, | |
| 26 | |
| 27 // If there are pending reads, any other kind of async operation is not | |
| 28 // allowed. | |
| 29 OPERATION_READ, | |
| 30 | |
| 31 // If there are pending writes, any other kind of async operation is not | |
| 32 // allowed. | |
| 33 OPERATION_WRITE, | |
| 34 | |
| 35 // If there is a pending operation that is neither read nor write, no | |
| 36 // further async operation is allowed. | |
| 37 OPERATION_EXCLUSIVE | |
| 38 }; | |
| 39 | |
| 40 OperationType GetPendingOperation() const { return pending_op_; } | |
|
raymes
2012/11/29 23:55:19
Check the style guide for naming of inline getters
victorhsieh
2012/11/30 01:17:21
Done.
| |
| 41 | |
| 42 void SetOpenSucceed(); | |
| 43 | |
| 44 // Called before every "Validated" function. It is responsible to make sure | |
|
raymes
2012/11/29 23:55:19
There are no longer "Validated" functions. Just sa
victorhsieh
2012/11/30 01:17:21
Done.
| |
| 45 // that "state" is correct. For example, some operations are only valid after | |
|
raymes
2012/11/29 23:55:19
"state"->state (no quotations needed)
victorhsieh
2012/11/30 01:17:21
Done.
| |
| 46 // the file is opened, or operations might need to run excludively. See | |
|
raymes
2012/11/29 23:55:19
-excludively->exclusively
-There are no subclasses
victorhsieh
2012/11/30 01:17:21
Done.
| |
| 47 // subclasses implementation for detail. | |
| 48 // | |
| 49 // It returns |PP_OK| on success, or |PP_ERROR_...| for various reasons. | |
| 50 int32_t CheckOperationState(OperationType new_op, bool should_be_open); | |
| 51 | |
| 52 // Marks the state of current operations as started or finished. | |
| 53 void SetPendingOperation(OperationType op); | |
| 54 void OperationFinished(); | |
|
raymes
2012/11/29 23:55:19
I would change this to SetOperationFinished to be
victorhsieh
2012/11/30 01:17:21
Done.
| |
| 55 | |
| 56 private: | |
| 57 int num_pending_ops_; | |
| 58 OperationType pending_op_; | |
| 59 | |
| 60 // Set to true when the file has been successfully opened. | |
| 61 bool file_open_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(FileIOStateManager); | |
| 64 }; | |
| 65 | |
| 66 } // namespace ppapi | |
| 67 | |
| 68 #endif // PPAPI_SHARED_IMPL_FILE_IO_STATE_MANAGER_H_ | |
| OLD | NEW |