OLD | NEW |
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/proxy/ppb_file_system_proxy.h" | 5 #include "ppapi/proxy/ppb_file_system_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/c/ppb_file_system.h" | 10 #include "ppapi/c/ppb_file_system.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 class FileSystem : public Resource, public PPB_FileSystem_API { | 40 class FileSystem : public Resource, public PPB_FileSystem_API { |
41 public: | 41 public: |
42 FileSystem(const HostResource& host_resource, PP_FileSystemType type); | 42 FileSystem(const HostResource& host_resource, PP_FileSystemType type); |
43 virtual ~FileSystem(); | 43 virtual ~FileSystem(); |
44 | 44 |
45 // Resource override. | 45 // Resource override. |
46 virtual PPB_FileSystem_API* AsPPB_FileSystem_API() OVERRIDE; | 46 virtual PPB_FileSystem_API* AsPPB_FileSystem_API() OVERRIDE; |
47 | 47 |
48 // PPB_FileSystem_APi implementation. | 48 // PPB_FileSystem_APi implementation. |
49 virtual int32_t Open(int64_t expected_size, | 49 virtual int32_t Open(int64_t expected_size, |
50 PP_CompletionCallback callback) OVERRIDE; | 50 ApiCallbackType callback) OVERRIDE; |
51 virtual PP_FileSystemType GetType() OVERRIDE; | 51 virtual PP_FileSystemType GetType() OVERRIDE; |
52 | 52 |
53 // Called when the host has responded to our open request. | 53 // Called when the host has responded to our open request. |
54 void OpenComplete(int32_t result); | 54 void OpenComplete(int32_t result); |
55 | 55 |
56 private: | 56 private: |
57 PP_FileSystemType type_; | 57 PP_FileSystemType type_; |
58 bool called_open_; | 58 bool called_open_; |
59 scoped_refptr<TrackedCallback> current_open_callback_; | 59 scoped_refptr<TrackedCallback> current_open_callback_; |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(FileSystem); | 61 DISALLOW_COPY_AND_ASSIGN(FileSystem); |
62 }; | 62 }; |
63 | 63 |
64 FileSystem::FileSystem(const HostResource& host_resource, | 64 FileSystem::FileSystem(const HostResource& host_resource, |
65 PP_FileSystemType type) | 65 PP_FileSystemType type) |
66 : Resource(OBJECT_IS_PROXY, host_resource), | 66 : Resource(OBJECT_IS_PROXY, host_resource), |
67 type_(type), | 67 type_(type), |
68 called_open_(false) { | 68 called_open_(false) { |
69 } | 69 } |
70 | 70 |
71 FileSystem::~FileSystem() { | 71 FileSystem::~FileSystem() { |
72 } | 72 } |
73 | 73 |
74 PPB_FileSystem_API* FileSystem::AsPPB_FileSystem_API() { | 74 PPB_FileSystem_API* FileSystem::AsPPB_FileSystem_API() { |
75 return this; | 75 return this; |
76 } | 76 } |
77 | 77 |
78 int32_t FileSystem::Open(int64_t expected_size, | 78 int32_t FileSystem::Open(int64_t expected_size, |
79 PP_CompletionCallback callback) { | 79 ApiCallbackType callback) { |
80 if (TrackedCallback::IsPending(current_open_callback_)) | 80 if (TrackedCallback::IsPending(current_open_callback_)) |
81 return PP_ERROR_INPROGRESS; | 81 return PP_ERROR_INPROGRESS; |
82 if (called_open_) | 82 if (called_open_) |
83 return PP_ERROR_FAILED; | 83 return PP_ERROR_FAILED; |
84 | 84 |
85 current_open_callback_ = new TrackedCallback(this, callback); | 85 current_open_callback_ = callback; |
86 called_open_ = true; | 86 called_open_ = true; |
87 PluginDispatcher::GetForResource(this)->Send( | 87 PluginDispatcher::GetForResource(this)->Send( |
88 new PpapiHostMsg_PPBFileSystem_Open( | 88 new PpapiHostMsg_PPBFileSystem_Open( |
89 API_ID_PPB_FILE_SYSTEM, host_resource(), expected_size)); | 89 API_ID_PPB_FILE_SYSTEM, host_resource(), expected_size)); |
90 return PP_OK_COMPLETIONPENDING; | 90 return PP_OK_COMPLETIONPENDING; |
91 } | 91 } |
92 | 92 |
93 PP_FileSystemType FileSystem::GetType() { | 93 PP_FileSystemType FileSystem::GetType() { |
94 return type_; | 94 return type_; |
95 } | 95 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 void PPB_FileSystem_Proxy::OpenCompleteInHost( | 177 void PPB_FileSystem_Proxy::OpenCompleteInHost( |
178 int32_t result, | 178 int32_t result, |
179 const HostResource& host_resource) { | 179 const HostResource& host_resource) { |
180 dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete( | 180 dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete( |
181 API_ID_PPB_FILE_SYSTEM, host_resource, result)); | 181 API_ID_PPB_FILE_SYSTEM, host_resource, result)); |
182 } | 182 } |
183 | 183 |
184 } // namespace proxy | 184 } // namespace proxy |
185 } // namespace ppapi | 185 } // namespace ppapi |
OLD | NEW |