OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "ppapi/proxy/file_system_resource.h" |
| 6 |
| 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" |
| 12 |
| 13 using ppapi::thunk::PPB_FileSystem_API; |
| 14 |
| 15 namespace ppapi { |
| 16 namespace proxy { |
| 17 |
| 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_)); |
| 26 } |
| 27 |
| 28 FileSystemResource::~FileSystemResource() { |
| 29 } |
| 30 |
| 31 PPB_FileSystem_API* FileSystemResource::AsPPB_FileSystem_API() { |
| 32 return this; |
| 33 } |
| 34 |
| 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; |
| 40 |
| 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; |
| 47 } |
| 48 |
| 49 PP_FileSystemType FileSystemResource::GetType() { |
| 50 return type_; |
| 51 } |
| 52 |
| 53 void FileSystemResource::OpenComplete( |
| 54 scoped_refptr<TrackedCallback> callback, |
| 55 const ResourceMessageReplyParams& params) { |
| 56 callback->Run(params.result()); |
| 57 } |
| 58 |
| 59 } // namespace proxy |
| 60 } // namespace ppapi |
OLD | NEW |