Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: ppapi/shared_impl/file_io_state_manager.cc

Issue 11941022: Refactor FileIO to the new resource host system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/shared_impl/file_io_state_manager.h ('k') | ppapi/shared_impl/ppb_file_io_shared.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "ppapi/shared_impl/file_io_state_manager.h"
6
7 #include "base/logging.h"
8 #include "ppapi/c/pp_errors.h"
9
10 namespace ppapi {
11
12 FileIOStateManager::FileIOStateManager()
13 : num_pending_ops_(0),
14 pending_op_(OPERATION_NONE),
15 file_open_(false) {
16 }
17
18 FileIOStateManager::~FileIOStateManager() {
19 }
20
21 void FileIOStateManager::SetOpenSucceed() {
22 file_open_ = true;
23 }
24
25 int32_t FileIOStateManager::CheckOperationState(OperationType new_op,
26 bool should_be_open) {
27 if (should_be_open) {
28 if (!file_open_)
29 return PP_ERROR_FAILED;
30 } else {
31 if (file_open_)
32 return PP_ERROR_FAILED;
33 }
34
35 if (pending_op_ != OPERATION_NONE &&
36 (pending_op_ != new_op || pending_op_ == OPERATION_EXCLUSIVE))
37 return PP_ERROR_INPROGRESS;
38
39 return PP_OK;
40 }
41
42 void FileIOStateManager::SetPendingOperation(OperationType new_op) {
43 DCHECK(pending_op_ == OPERATION_NONE ||
44 (pending_op_ != OPERATION_EXCLUSIVE && pending_op_ == new_op));
45 pending_op_ = new_op;
46 num_pending_ops_++;
47 }
48
49 void FileIOStateManager::SetOperationFinished() {
50 DCHECK_GT(num_pending_ops_, 0);
51 if (--num_pending_ops_ == 0)
52 pending_op_ = OPERATION_NONE;
53 }
54
55 } // namespace ppapi
56
OLDNEW
« no previous file with comments | « ppapi/shared_impl/file_io_state_manager.h ('k') | ppapi/shared_impl/ppb_file_io_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698