Android WebView: build debug/release based on variant.
[chromium-blink-merge.git] / ppapi / proxy / file_system_resource.cc
blob16c92e81928775d4ab4bb894b3e54a6bce5b8423
1 // Copyright (c) 2013 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.
5 #include "ppapi/proxy/file_system_resource.h"
7 #include "base/bind.h"
8 #include "ipc/ipc_message.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/shared_impl/tracked_callback.h"
13 using ppapi::thunk::PPB_FileSystem_API;
15 namespace ppapi {
16 namespace proxy {
18 FileSystemResource::FileSystemResource(Connection connection,
19 PP_Instance instance,
20 PP_FileSystemType type)
21 : PluginResource(connection, instance),
22 type_(type),
23 called_open_(false) {
24 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID);
25 SendCreate(RENDERER, PpapiHostMsg_FileSystem_Create(type_));
28 FileSystemResource::~FileSystemResource() {
31 PPB_FileSystem_API* FileSystemResource::AsPPB_FileSystem_API() {
32 return this;
35 int32_t FileSystemResource::Open(int64_t expected_size,
36 scoped_refptr<TrackedCallback> callback) {
37 if (called_open_)
38 return PP_ERROR_FAILED;
39 called_open_ = true;
41 Call<PpapiPluginMsg_FileSystem_OpenReply>(RENDERER,
42 PpapiHostMsg_FileSystem_Open(expected_size),
43 base::Bind(&FileSystemResource::OpenComplete,
44 this,
45 callback));
46 return PP_OK_COMPLETIONPENDING;
49 PP_FileSystemType FileSystemResource::GetType() {
50 return type_;
53 void FileSystemResource::InitIsolatedFileSystem(const char* fsid) {
54 Post(RENDERER,
55 PpapiHostMsg_FileSystem_InitIsolatedFileSystem(std::string(fsid)));
58 void FileSystemResource::OpenComplete(
59 scoped_refptr<TrackedCallback> callback,
60 const ResourceMessageReplyParams& params) {
61 callback->Run(params.result());
64 } // namespace proxy
65 } // namespace ppapi