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

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

Issue 52233002: [PPAPI] Added VarResource_Dev class. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix Windows compile. Created 7 years, 1 month 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
« no previous file with comments | « ppapi/cpp/file_system.h ('k') | ppapi/cpp/resource.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) 2012 The Chromium Authors. All rights reserved. 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 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_system.h" 5 #include "ppapi/cpp/file_system.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_file_system.h" 8 #include "ppapi/c/ppb_file_system.h"
9 #include "ppapi/cpp/completion_callback.h" 9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/file_ref.h" 10 #include "ppapi/cpp/file_ref.h"
11 #include "ppapi/cpp/instance_handle.h" 11 #include "ppapi/cpp/instance_handle.h"
12 #include "ppapi/cpp/logging.h"
12 #include "ppapi/cpp/module.h" 13 #include "ppapi/cpp/module.h"
13 #include "ppapi/cpp/module_impl.h" 14 #include "ppapi/cpp/module_impl.h"
14 15
15 namespace pp { 16 namespace pp {
16 17
17 namespace { 18 namespace {
18 19
19 template <> const char* interface_name<PPB_FileSystem_1_0>() { 20 template <> const char* interface_name<PPB_FileSystem_1_0>() {
20 return PPB_FILESYSTEM_INTERFACE_1_0; 21 return PPB_FILESYSTEM_INTERFACE_1_0;
21 } 22 }
22 23
23 } // namespace 24 } // namespace
24 25
25 FileSystem::FileSystem() { 26 FileSystem::FileSystem() {
26 } 27 }
27 28
28 FileSystem::FileSystem(const FileSystem& other) : Resource(other) { 29 FileSystem::FileSystem(const FileSystem& other) : Resource(other) {
29 } 30 }
30 31
32 FileSystem::FileSystem(const Resource& resource) : Resource(resource) {
33 if (!IsFileSystem(resource)) {
34 PP_NOTREACHED();
35
36 // On release builds, set this to null.
37 Clear();
38 }
39 }
40
31 FileSystem::FileSystem(PassRef, PP_Resource resource) 41 FileSystem::FileSystem(PassRef, PP_Resource resource)
32 : Resource(PASS_REF, resource) { 42 : Resource(PASS_REF, resource) {
33 } 43 }
34 44
35 FileSystem::FileSystem(const InstanceHandle& instance, 45 FileSystem::FileSystem(const InstanceHandle& instance,
36 PP_FileSystemType type) { 46 PP_FileSystemType type) {
37 if (!has_interface<PPB_FileSystem_1_0>()) 47 if (!has_interface<PPB_FileSystem_1_0>())
38 return; 48 return;
39 PassRefFromConstructor(get_interface<PPB_FileSystem_1_0>()->Create( 49 PassRefFromConstructor(get_interface<PPB_FileSystem_1_0>()->Create(
40 instance.pp_instance(), type)); 50 instance.pp_instance(), type));
41 } 51 }
42 52
43 int32_t FileSystem::Open(int64_t expected_size, 53 int32_t FileSystem::Open(int64_t expected_size,
44 const CompletionCallback& cc) { 54 const CompletionCallback& cc) {
45 if (!has_interface<PPB_FileSystem_1_0>()) 55 if (!has_interface<PPB_FileSystem_1_0>())
46 return cc.MayForce(PP_ERROR_NOINTERFACE); 56 return cc.MayForce(PP_ERROR_NOINTERFACE);
47 return get_interface<PPB_FileSystem_1_0>()->Open( 57 return get_interface<PPB_FileSystem_1_0>()->Open(
48 pp_resource(), expected_size, cc.pp_completion_callback()); 58 pp_resource(), expected_size, cc.pp_completion_callback());
49 } 59 }
50 60
61 // static
62 bool FileSystem::IsFileSystem(const Resource& resource) {
63 if (!has_interface<PPB_FileSystem_1_0>())
64 return false;
65 return get_interface<PPB_FileSystem_1_0>()->IsFileSystem(
66 resource.pp_resource()) == PP_TRUE;
67 }
68
51 } // namespace pp 69 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/file_system.h ('k') | ppapi/cpp/resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698