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

Side by Side Diff: ppapi/cpp/file_io.cc

Issue 6899055: PPAPI: Force async callback invocation option. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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/cpp/dev/video_decoder_dev.cc ('k') | ppapi/cpp/file_ref.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/cpp/file_io.h" 5 #include "ppapi/cpp/file_io.h"
6 6
7 #include "ppapi/c/ppb_file_io.h" 7 #include "ppapi/c/ppb_file_io.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/trusted/ppb_file_io_trusted.h" 9 #include "ppapi/c/trusted/ppb_file_io_trusted.h"
10 #include "ppapi/cpp/completion_callback.h" 10 #include "ppapi/cpp/completion_callback.h"
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 FileIO::FileIO(const FileIO& other) 36 FileIO::FileIO(const FileIO& other)
37 : Resource(other) { 37 : Resource(other) {
38 } 38 }
39 39
40 int32_t FileIO::Open(const FileRef& file_ref, 40 int32_t FileIO::Open(const FileRef& file_ref,
41 int32_t open_flags, 41 int32_t open_flags,
42 const CompletionCallback& cc) { 42 const CompletionCallback& cc) {
43 if (!has_interface<PPB_FileIO>()) 43 if (!has_interface<PPB_FileIO>())
44 return PP_ERROR_NOINTERFACE; 44 return cc.MayForce(PP_ERROR_NOINTERFACE);
45 return get_interface<PPB_FileIO>()->Open( 45 return get_interface<PPB_FileIO>()->Open(
46 pp_resource(), file_ref.pp_resource(), open_flags, 46 pp_resource(), file_ref.pp_resource(), open_flags,
47 cc.pp_completion_callback()); 47 cc.pp_completion_callback());
48 } 48 }
49 49
50 int32_t FileIO::Query(PP_FileInfo* result_buf, 50 int32_t FileIO::Query(PP_FileInfo* result_buf,
51 const CompletionCallback& cc) { 51 const CompletionCallback& cc) {
52 if (!has_interface<PPB_FileIO>()) 52 if (!has_interface<PPB_FileIO>())
53 return PP_ERROR_NOINTERFACE; 53 return cc.MayForce(PP_ERROR_NOINTERFACE);
54 return get_interface<PPB_FileIO>()->Query( 54 return get_interface<PPB_FileIO>()->Query(
55 pp_resource(), result_buf, cc.pp_completion_callback()); 55 pp_resource(), result_buf, cc.pp_completion_callback());
56 } 56 }
57 57
58 int32_t FileIO::Touch(PP_Time last_access_time, 58 int32_t FileIO::Touch(PP_Time last_access_time,
59 PP_Time last_modified_time, 59 PP_Time last_modified_time,
60 const CompletionCallback& cc) { 60 const CompletionCallback& cc) {
61 if (!has_interface<PPB_FileIO>()) 61 if (!has_interface<PPB_FileIO>())
62 return PP_ERROR_NOINTERFACE; 62 return cc.MayForce(PP_ERROR_NOINTERFACE);
63 return get_interface<PPB_FileIO>()->Touch( 63 return get_interface<PPB_FileIO>()->Touch(
64 pp_resource(), last_access_time, last_modified_time, 64 pp_resource(), last_access_time, last_modified_time,
65 cc.pp_completion_callback()); 65 cc.pp_completion_callback());
66 } 66 }
67 67
68 int32_t FileIO::Read(int64_t offset, 68 int32_t FileIO::Read(int64_t offset,
69 char* buffer, 69 char* buffer,
70 int32_t bytes_to_read, 70 int32_t bytes_to_read,
71 const CompletionCallback& cc) { 71 const CompletionCallback& cc) {
72 if (!has_interface<PPB_FileIO>()) 72 if (!has_interface<PPB_FileIO>())
73 return PP_ERROR_NOINTERFACE; 73 return cc.MayForce(PP_ERROR_NOINTERFACE);
74 return get_interface<PPB_FileIO>()->Read(pp_resource(), 74 return get_interface<PPB_FileIO>()->Read(pp_resource(),
75 offset, buffer, bytes_to_read, cc.pp_completion_callback()); 75 offset, buffer, bytes_to_read, cc.pp_completion_callback());
76 } 76 }
77 77
78 int32_t FileIO::Write(int64_t offset, 78 int32_t FileIO::Write(int64_t offset,
79 const char* buffer, 79 const char* buffer,
80 int32_t bytes_to_write, 80 int32_t bytes_to_write,
81 const CompletionCallback& cc) { 81 const CompletionCallback& cc) {
82 if (!has_interface<PPB_FileIO>()) 82 if (!has_interface<PPB_FileIO>())
83 return PP_ERROR_NOINTERFACE; 83 return cc.MayForce(PP_ERROR_NOINTERFACE);
84 return get_interface<PPB_FileIO>()->Write( 84 return get_interface<PPB_FileIO>()->Write(
85 pp_resource(), offset, buffer, bytes_to_write, 85 pp_resource(), offset, buffer, bytes_to_write,
86 cc.pp_completion_callback()); 86 cc.pp_completion_callback());
87 } 87 }
88 88
89 int32_t FileIO::SetLength(int64_t length, 89 int32_t FileIO::SetLength(int64_t length,
90 const CompletionCallback& cc) { 90 const CompletionCallback& cc) {
91 if (!has_interface<PPB_FileIO>()) 91 if (!has_interface<PPB_FileIO>())
92 return PP_ERROR_NOINTERFACE; 92 return cc.MayForce(PP_ERROR_NOINTERFACE);
93 return get_interface<PPB_FileIO>()->SetLength( 93 return get_interface<PPB_FileIO>()->SetLength(
94 pp_resource(), length, cc.pp_completion_callback()); 94 pp_resource(), length, cc.pp_completion_callback());
95 } 95 }
96 96
97 int32_t FileIO::Flush(const CompletionCallback& cc) { 97 int32_t FileIO::Flush(const CompletionCallback& cc) {
98 if (!has_interface<PPB_FileIO>()) 98 if (!has_interface<PPB_FileIO>())
99 return PP_ERROR_NOINTERFACE; 99 return cc.MayForce(PP_ERROR_NOINTERFACE);
100 return get_interface<PPB_FileIO>()->Flush( 100 return get_interface<PPB_FileIO>()->Flush(
101 pp_resource(), cc.pp_completion_callback()); 101 pp_resource(), cc.pp_completion_callback());
102 } 102 }
103 103
104 void FileIO::Close() { 104 void FileIO::Close() {
105 if (!has_interface<PPB_FileIO>()) 105 if (!has_interface<PPB_FileIO>())
106 return; 106 return;
107 get_interface<PPB_FileIO>()->Close(pp_resource()); 107 get_interface<PPB_FileIO>()->Close(pp_resource());
108 } 108 }
109 109
110 } // namespace pp 110 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/dev/video_decoder_dev.cc ('k') | ppapi/cpp/file_ref.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698