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

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

Issue 7387011: Clean up the file dev interfaces. The combination of some dev and some non (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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ppapi/cpp/dev/file_io_dev.h"
6
7 #include "ppapi/c/dev/ppb_file_io_dev.h"
8 #include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/cpp/completion_callback.h"
11 #include "ppapi/cpp/dev/file_ref_dev.h"
12 #include "ppapi/cpp/instance.h"
13 #include "ppapi/cpp/module.h"
14 #include "ppapi/cpp/module_impl.h"
15
16 namespace pp {
17
18 namespace {
19
20 template <> const char* interface_name<PPB_FileIO_Dev>() {
21 return PPB_FILEIO_DEV_INTERFACE;
22 }
23
24 } // namespace
25
26 FileIO_Dev::FileIO_Dev() {
27 }
28
29 FileIO_Dev::FileIO_Dev(Instance* instance) {
30 if (!has_interface<PPB_FileIO_Dev>())
31 return;
32 PassRefFromConstructor(get_interface<PPB_FileIO_Dev>()->Create(
33 instance->pp_instance()));
34 }
35
36 FileIO_Dev::FileIO_Dev(const FileIO_Dev& other)
37 : Resource(other) {
38 }
39
40 int32_t FileIO_Dev::Open(const FileRef_Dev& file_ref,
41 int32_t open_flags,
42 const CompletionCallback& cc) {
43 if (!has_interface<PPB_FileIO_Dev>())
44 return cc.MayForce(PP_ERROR_NOINTERFACE);
45 return get_interface<PPB_FileIO_Dev>()->Open(
46 pp_resource(), file_ref.pp_resource(), open_flags,
47 cc.pp_completion_callback());
48 }
49
50 int32_t FileIO_Dev::Query(PP_FileInfo_Dev* result_buf,
51 const CompletionCallback& cc) {
52 if (!has_interface<PPB_FileIO_Dev>())
53 return cc.MayForce(PP_ERROR_NOINTERFACE);
54 return get_interface<PPB_FileIO_Dev>()->Query(
55 pp_resource(), result_buf, cc.pp_completion_callback());
56 }
57
58 int32_t FileIO_Dev::Touch(PP_Time last_access_time,
59 PP_Time last_modified_time,
60 const CompletionCallback& cc) {
61 if (!has_interface<PPB_FileIO_Dev>())
62 return cc.MayForce(PP_ERROR_NOINTERFACE);
63 return get_interface<PPB_FileIO_Dev>()->Touch(
64 pp_resource(), last_access_time, last_modified_time,
65 cc.pp_completion_callback());
66 }
67
68 int32_t FileIO_Dev::Read(int64_t offset,
69 char* buffer,
70 int32_t bytes_to_read,
71 const CompletionCallback& cc) {
72 if (!has_interface<PPB_FileIO_Dev>())
73 return cc.MayForce(PP_ERROR_NOINTERFACE);
74 return get_interface<PPB_FileIO_Dev>()->Read(pp_resource(),
75 offset, buffer, bytes_to_read, cc.pp_completion_callback());
76 }
77
78 int32_t FileIO_Dev::Write(int64_t offset,
79 const char* buffer,
80 int32_t bytes_to_write,
81 const CompletionCallback& cc) {
82 if (!has_interface<PPB_FileIO_Dev>())
83 return cc.MayForce(PP_ERROR_NOINTERFACE);
84 return get_interface<PPB_FileIO_Dev>()->Write(
85 pp_resource(), offset, buffer, bytes_to_write,
86 cc.pp_completion_callback());
87 }
88
89 int32_t FileIO_Dev::SetLength(int64_t length,
90 const CompletionCallback& cc) {
91 if (!has_interface<PPB_FileIO_Dev>())
92 return cc.MayForce(PP_ERROR_NOINTERFACE);
93 return get_interface<PPB_FileIO_Dev>()->SetLength(
94 pp_resource(), length, cc.pp_completion_callback());
95 }
96
97 int32_t FileIO_Dev::Flush(const CompletionCallback& cc) {
98 if (!has_interface<PPB_FileIO_Dev>())
99 return cc.MayForce(PP_ERROR_NOINTERFACE);
100 return get_interface<PPB_FileIO_Dev>()->Flush(
101 pp_resource(), cc.pp_completion_callback());
102 }
103
104 void FileIO_Dev::Close() {
105 if (!has_interface<PPB_FileIO_Dev>())
106 return;
107 get_interface<PPB_FileIO_Dev>()->Close(pp_resource());
108 }
109
110 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698