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

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

Issue 7210027: Part I of many. Moving FileIO, FileRef, and FileSystem out of Dev. For now, just copying over s... (Closed) Base URL: http://src.chromium.org/svn/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
« no previous file with comments | « ppapi/cpp/file_io.h ('k') | ppapi/cpp/file_ref.h » ('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) 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/file_io.h"
6 6
7 #include "ppapi/c/dev/ppb_file_io_dev.h" 7 #include "ppapi/c/ppb_file_io.h"
8 #include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
9 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.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"
11 #include "ppapi/cpp/dev/file_ref_dev.h" 11 #include "ppapi/cpp/file_ref.h"
12 #include "ppapi/cpp/instance.h" 12 #include "ppapi/cpp/instance.h"
13 #include "ppapi/cpp/module.h" 13 #include "ppapi/cpp/module.h"
14 #include "ppapi/cpp/module_impl.h" 14 #include "ppapi/cpp/module_impl.h"
15 15
16 namespace pp { 16 namespace pp {
17 17
18 namespace { 18 namespace {
19 19
20 template <> const char* interface_name<PPB_FileIO_Dev>() { 20 template <> const char* interface_name<PPB_FileIO>() {
21 return PPB_FILEIO_DEV_INTERFACE; 21 return PPB_FILEIO_INTERFACE;
22 } 22 }
23 23
24 } // namespace 24 } // namespace
25 25
26 FileIO_Dev::FileIO_Dev() { 26 FileIO::FileIO() {
27 } 27 }
28 28
29 FileIO_Dev::FileIO_Dev(Instance* instance) { 29 FileIO::FileIO(Instance* instance) {
30 if (!has_interface<PPB_FileIO_Dev>()) 30 if (!has_interface<PPB_FileIO>())
31 return; 31 return;
32 PassRefFromConstructor(get_interface<PPB_FileIO_Dev>()->Create( 32 PassRefFromConstructor(get_interface<PPB_FileIO>()->Create(
33 instance->pp_instance())); 33 instance->pp_instance()));
34 } 34 }
35 35
36 FileIO_Dev::FileIO_Dev(const FileIO_Dev& other) 36 FileIO::FileIO(const FileIO& 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::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_Dev>()) 43 if (!has_interface<PPB_FileIO>())
44 return PP_ERROR_NOINTERFACE; 44 return PP_ERROR_NOINTERFACE;
45 return get_interface<PPB_FileIO_Dev>()->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_Dev::Query(PP_FileInfo_Dev* 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_Dev>()) 52 if (!has_interface<PPB_FileIO>())
53 return PP_ERROR_NOINTERFACE; 53 return PP_ERROR_NOINTERFACE;
54 return get_interface<PPB_FileIO_Dev>()->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_Dev::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_Dev>()) 61 if (!has_interface<PPB_FileIO>())
62 return PP_ERROR_NOINTERFACE; 62 return PP_ERROR_NOINTERFACE;
63 return get_interface<PPB_FileIO_Dev>()->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_Dev::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_Dev>()) 72 if (!has_interface<PPB_FileIO>())
73 return PP_ERROR_NOINTERFACE; 73 return PP_ERROR_NOINTERFACE;
74 return get_interface<PPB_FileIO_Dev>()->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_Dev::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_Dev>()) 82 if (!has_interface<PPB_FileIO>())
83 return PP_ERROR_NOINTERFACE; 83 return PP_ERROR_NOINTERFACE;
84 return get_interface<PPB_FileIO_Dev>()->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_Dev::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_Dev>()) 91 if (!has_interface<PPB_FileIO>())
92 return PP_ERROR_NOINTERFACE; 92 return PP_ERROR_NOINTERFACE;
93 return get_interface<PPB_FileIO_Dev>()->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_Dev::Flush(const CompletionCallback& cc) { 97 int32_t FileIO::Flush(const CompletionCallback& cc) {
98 if (!has_interface<PPB_FileIO_Dev>()) 98 if (!has_interface<PPB_FileIO>())
99 return PP_ERROR_NOINTERFACE; 99 return PP_ERROR_NOINTERFACE;
100 return get_interface<PPB_FileIO_Dev>()->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_Dev::Close() { 104 void FileIO::Close() {
105 if (!has_interface<PPB_FileIO_Dev>()) 105 if (!has_interface<PPB_FileIO>())
106 return; 106 return;
107 get_interface<PPB_FileIO_Dev>()->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/file_io.h ('k') | ppapi/cpp/file_ref.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698