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

Side by Side Diff: ppapi/cpp/dev/file_io_dev.cc

Issue 6899055: PPAPI: Force async callback invocation option. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
OLDNEW
1 // Copyright (c) 2010 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/dev/file_io_dev.h" 5 #include "ppapi/cpp/dev/file_io_dev.h"
6 6
7 #include "ppapi/c/dev/ppb_file_io_dev.h" 7 #include "ppapi/c/dev/ppb_file_io_dev.h"
8 #include "ppapi/c/dev/ppb_file_io_trusted_dev.h" 8 #include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/cpp/completion_callback.h" 10 #include "ppapi/cpp/completion_callback.h"
11 #include "ppapi/cpp/dev/file_ref_dev.h" 11 #include "ppapi/cpp/dev/file_ref_dev.h"
(...skipping 22 matching lines...) Expand all
34 } 34 }
35 35
36 FileIO_Dev::FileIO_Dev(const FileIO_Dev& other) 36 FileIO_Dev::FileIO_Dev(const FileIO_Dev& other)
37 : Resource(other) { 37 : Resource(other) {
38 } 38 }
39 39
40 int32_t FileIO_Dev::Open(const FileRef_Dev& file_ref, 40 int32_t FileIO_Dev::Open(const FileRef_Dev& 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_Dev>()) 43 if (!has_interface<PPB_FileIO_Dev>())
44 return PP_ERROR_NOINTERFACE; 44 return cc.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
piman 2011/06/07 17:32:14 no need for static_cast ? Here an below.
polina 2011/06/09 23:53:51 Done.
45 return get_interface<PPB_FileIO_Dev>()->Open( 45 return get_interface<PPB_FileIO_Dev>()->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_Dev::Query(PP_FileInfo_Dev* result_buf, 50 int32_t FileIO_Dev::Query(PP_FileInfo_Dev* result_buf,
51 const CompletionCallback& cc) { 51 const CompletionCallback& cc) {
52 if (!has_interface<PPB_FileIO_Dev>()) 52 if (!has_interface<PPB_FileIO_Dev>())
53 return PP_ERROR_NOINTERFACE; 53 return cc.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
54 return get_interface<PPB_FileIO_Dev>()->Query( 54 return get_interface<PPB_FileIO_Dev>()->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_Dev::Touch(PP_Time last_access_time, 58 int32_t FileIO_Dev::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_Dev>()) 61 if (!has_interface<PPB_FileIO_Dev>())
62 return PP_ERROR_NOINTERFACE; 62 return cc.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
63 return get_interface<PPB_FileIO_Dev>()->Touch( 63 return get_interface<PPB_FileIO_Dev>()->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_Dev::Read(int64_t offset, 68 int32_t FileIO_Dev::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_Dev>()) 72 if (!has_interface<PPB_FileIO_Dev>())
73 return PP_ERROR_NOINTERFACE; 73 return cc.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
74 return get_interface<PPB_FileIO_Dev>()->Read(pp_resource(), 74 return get_interface<PPB_FileIO_Dev>()->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_Dev::Write(int64_t offset, 78 int32_t FileIO_Dev::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_Dev>()) 82 if (!has_interface<PPB_FileIO_Dev>())
83 return PP_ERROR_NOINTERFACE; 83 return cc.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
84 return get_interface<PPB_FileIO_Dev>()->Write( 84 return get_interface<PPB_FileIO_Dev>()->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_Dev::SetLength(int64_t length, 89 int32_t FileIO_Dev::SetLength(int64_t length,
90 const CompletionCallback& cc) { 90 const CompletionCallback& cc) {
91 if (!has_interface<PPB_FileIO_Dev>()) 91 if (!has_interface<PPB_FileIO_Dev>())
92 return PP_ERROR_NOINTERFACE; 92 return cc.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
93 return get_interface<PPB_FileIO_Dev>()->SetLength( 93 return get_interface<PPB_FileIO_Dev>()->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_Dev::Flush(const CompletionCallback& cc) { 97 int32_t FileIO_Dev::Flush(const CompletionCallback& cc) {
98 if (!has_interface<PPB_FileIO_Dev>()) 98 if (!has_interface<PPB_FileIO_Dev>())
99 return PP_ERROR_NOINTERFACE; 99 return cc.MayForce(static_cast<int32_t>(PP_ERROR_NOINTERFACE));
100 return get_interface<PPB_FileIO_Dev>()->Flush( 100 return get_interface<PPB_FileIO_Dev>()->Flush(
101 pp_resource(), cc.pp_completion_callback()); 101 pp_resource(), cc.pp_completion_callback());
102 } 102 }
103 103
104 void FileIO_Dev::Close() { 104 void FileIO_Dev::Close() {
105 if (!has_interface<PPB_FileIO_Dev>()) 105 if (!has_interface<PPB_FileIO_Dev>())
106 return; 106 return;
107 get_interface<PPB_FileIO_Dev>()->Close(pp_resource()); 107 get_interface<PPB_FileIO_Dev>()->Close(pp_resource());
108 } 108 }
109 109
110 } // namespace pp 110 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698