0
Files
android_webview
apps
ash
base
build
build_overrides
buildtools
cc
chrome
chrome_elf
chromecast
chromeos
cloud_print
components
content
courgette
crypto
dbus
device
docs
extensions
fuchsia
gin
google_apis
google_update
gpu
headless
infra
ios
ipc
jingle
media
mojo
native_client_sdk
net
pdf
ppapi
api
buildflags
c
cpp
dev
documentation
private
trusted
BUILD.gn
DEPS
array_output.cc
array_output.h
audio.cc
audio.h
audio_buffer.cc
audio_buffer.h
audio_config.cc
audio_config.h
audio_encoder.cc
audio_encoder.h
completion_callback.h
core.cc
core.h
directory_entry.cc
directory_entry.h
file_io.cc
file_io.h
file_ref.cc
file_ref.h
file_system.cc
file_system.h
fullscreen.cc
fullscreen.h
graphics_2d.cc
graphics_2d.h
graphics_3d.cc
graphics_3d.h
graphics_3d_client.cc
graphics_3d_client.h
host_resolver.cc
host_resolver.h
image_data.cc
image_data.h
input_event.cc
input_event.h
input_event_interface_name.h
instance.cc
instance.h
instance_handle.cc
instance_handle.h
logging.h
media_stream_audio_track.cc
media_stream_audio_track.h
media_stream_video_track.cc
media_stream_video_track.h
message_handler.h
message_loop.cc
message_loop.h
module.cc
module.h
module_embedder.h
module_impl.h
mouse_cursor.cc
mouse_cursor.h
mouse_lock.cc
mouse_lock.h
net_address.cc
net_address.h
network_list.cc
network_list.h
network_monitor.cc
network_monitor.h
network_proxy.cc
network_proxy.h
output_traits.h
pass_ref.h
point.h
ppp_entrypoints.cc
rect.cc
rect.h
resource.cc
resource.h
size.h
tcp_socket.cc
tcp_socket.h
text_input_controller.cc
text_input_controller.h
touch_point.h
udp_socket.cc
udp_socket.h
url_loader.cc
url_loader.h
url_request_info.cc
url_request_info.h
url_response_info.cc
url_response_info.h
var.cc
var.h
var_array.cc
var_array.h
var_array_buffer.cc
var_array_buffer.h
var_dictionary.cc
var_dictionary.h
video_decoder.cc
video_decoder.h
video_encoder.cc
video_encoder.h
video_frame.cc
video_frame.h
view.cc
view.h
vpn_provider.cc
vpn_provider.h
websocket.cc
websocket.h
examples
generators
host
lib
nacl_irt
native_client
proxy
shared_impl
tests
thunk
tools
utility
BUILD.gn
DEPS
LICENSE
OWNERS
PRESUBMIT.py
generate_ppapi_include_tests.py
generate_ppapi_size_checks.py
printing
remoting
rlz
sandbox
services
skia
sql
storage
styleguide
testing
third_party
tools
ui
url
.clang-format
.eslintrc.js
.git-blame-ignore-revs
.gitattributes
.gitignore
.gn
.vpython
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
DEPS
ENG_REVIEW_OWNERS
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings
src/ppapi/cpp/file_system.cc
yzshen@chromium.org 60accc164f [PPAPI] Added pp::VarResource_Dev class.
This is a C++ wrapper for the C API PPB_VarResource_Dev.

Also added methods to pp::FileSystem for converting a pp::Resource to a
pp::FileSystem, which are necessary for making use of a resource
extracted using pp::VarResource_Dev.

(Committed by yzshen@chromium.org on behalf of mgiuca@chromium.org)

BUG=177017
R=dmichael@chromium.org, noelallen@chromium.org, noelallen@google.com, yzshen@chromium.org

Review URL: https://codereview.chromium.org/52233002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232482 0039d316-1c4b-4281-b951-d872f2087c98
2013-11-01 22:16:43 +00:00

70 lines
1.8 KiB
C++

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/cpp/file_system.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_file_system.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/file_ref.h"
#include "ppapi/cpp/instance_handle.h"
#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
namespace pp {
namespace {
template <> const char* interface_name<PPB_FileSystem_1_0>() {
return PPB_FILESYSTEM_INTERFACE_1_0;
}
} // namespace
FileSystem::FileSystem() {
}
FileSystem::FileSystem(const FileSystem& other) : Resource(other) {
}
FileSystem::FileSystem(const Resource& resource) : Resource(resource) {
if (!IsFileSystem(resource)) {
PP_NOTREACHED();
// On release builds, set this to null.
Clear();
}
}
FileSystem::FileSystem(PassRef, PP_Resource resource)
: Resource(PASS_REF, resource) {
}
FileSystem::FileSystem(const InstanceHandle& instance,
PP_FileSystemType type) {
if (!has_interface<PPB_FileSystem_1_0>())
return;
PassRefFromConstructor(get_interface<PPB_FileSystem_1_0>()->Create(
instance.pp_instance(), type));
}
int32_t FileSystem::Open(int64_t expected_size,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileSystem_1_0>())
return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileSystem_1_0>()->Open(
pp_resource(), expected_size, cc.pp_completion_callback());
}
// static
bool FileSystem::IsFileSystem(const Resource& resource) {
if (!has_interface<PPB_FileSystem_1_0>())
return false;
return get_interface<PPB_FileSystem_1_0>()->IsFileSystem(
resource.pp_resource()) == PP_TRUE;
}
} // namespace pp