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

Side by Side Diff: ppapi/proxy/ppb_file_system_proxy.cc

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export AssertLockHeld Created 8 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_file_ref_proxy.cc ('k') | ppapi/proxy/ppb_flash_menu_proxy.cc » ('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/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 28 matching lines...) Expand all
39 class FileSystem : public Resource, public PPB_FileSystem_API { 39 class FileSystem : public Resource, public PPB_FileSystem_API {
40 public: 40 public:
41 FileSystem(const HostResource& host_resource, PP_FileSystemType type); 41 FileSystem(const HostResource& host_resource, PP_FileSystemType type);
42 virtual ~FileSystem(); 42 virtual ~FileSystem();
43 43
44 // Resource override. 44 // Resource override.
45 virtual PPB_FileSystem_API* AsPPB_FileSystem_API() OVERRIDE; 45 virtual PPB_FileSystem_API* AsPPB_FileSystem_API() OVERRIDE;
46 46
47 // PPB_FileSystem_APi implementation. 47 // PPB_FileSystem_APi implementation.
48 virtual int32_t Open(int64_t expected_size, 48 virtual int32_t Open(int64_t expected_size,
49 PP_CompletionCallback callback) OVERRIDE; 49 scoped_refptr<TrackedCallback> callback) OVERRIDE;
50 virtual PP_FileSystemType GetType() OVERRIDE; 50 virtual PP_FileSystemType GetType() OVERRIDE;
51 51
52 // Called when the host has responded to our open request. 52 // Called when the host has responded to our open request.
53 void OpenComplete(int32_t result); 53 void OpenComplete(int32_t result);
54 54
55 private: 55 private:
56 PP_FileSystemType type_; 56 PP_FileSystemType type_;
57 bool called_open_; 57 bool called_open_;
58 scoped_refptr<TrackedCallback> current_open_callback_; 58 scoped_refptr<TrackedCallback> current_open_callback_;
59 59
60 DISALLOW_COPY_AND_ASSIGN(FileSystem); 60 DISALLOW_COPY_AND_ASSIGN(FileSystem);
61 }; 61 };
62 62
63 FileSystem::FileSystem(const HostResource& host_resource, 63 FileSystem::FileSystem(const HostResource& host_resource,
64 PP_FileSystemType type) 64 PP_FileSystemType type)
65 : Resource(OBJECT_IS_PROXY, host_resource), 65 : Resource(OBJECT_IS_PROXY, host_resource),
66 type_(type), 66 type_(type),
67 called_open_(false) { 67 called_open_(false) {
68 } 68 }
69 69
70 FileSystem::~FileSystem() { 70 FileSystem::~FileSystem() {
71 } 71 }
72 72
73 PPB_FileSystem_API* FileSystem::AsPPB_FileSystem_API() { 73 PPB_FileSystem_API* FileSystem::AsPPB_FileSystem_API() {
74 return this; 74 return this;
75 } 75 }
76 76
77 int32_t FileSystem::Open(int64_t expected_size, 77 int32_t FileSystem::Open(int64_t expected_size,
78 PP_CompletionCallback callback) { 78 scoped_refptr<TrackedCallback> callback) {
79 if (TrackedCallback::IsPending(current_open_callback_)) 79 if (TrackedCallback::IsPending(current_open_callback_))
80 return PP_ERROR_INPROGRESS; 80 return PP_ERROR_INPROGRESS;
81 if (called_open_) 81 if (called_open_)
82 return PP_ERROR_FAILED; 82 return PP_ERROR_FAILED;
83 83
84 current_open_callback_ = new TrackedCallback(this, callback); 84 current_open_callback_ = callback;
85 called_open_ = true; 85 called_open_ = true;
86 PluginDispatcher::GetForResource(this)->Send( 86 PluginDispatcher::GetForResource(this)->Send(
87 new PpapiHostMsg_PPBFileSystem_Open( 87 new PpapiHostMsg_PPBFileSystem_Open(
88 API_ID_PPB_FILE_SYSTEM, host_resource(), expected_size)); 88 API_ID_PPB_FILE_SYSTEM, host_resource(), expected_size));
89 return PP_OK_COMPLETIONPENDING; 89 return PP_OK_COMPLETIONPENDING;
90 } 90 }
91 91
92 PP_FileSystemType FileSystem::GetType() { 92 PP_FileSystemType FileSystem::GetType() {
93 return type_; 93 return type_;
94 } 94 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 void PPB_FileSystem_Proxy::OpenCompleteInHost( 176 void PPB_FileSystem_Proxy::OpenCompleteInHost(
177 int32_t result, 177 int32_t result,
178 const HostResource& host_resource) { 178 const HostResource& host_resource) {
179 dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete( 179 dispatcher()->Send(new PpapiMsg_PPBFileSystem_OpenComplete(
180 API_ID_PPB_FILE_SYSTEM, host_resource, result)); 180 API_ID_PPB_FILE_SYSTEM, host_resource, result));
181 } 181 }
182 182
183 } // namespace proxy 183 } // namespace proxy
184 } // namespace ppapi 184 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_file_ref_proxy.cc ('k') | ppapi/proxy/ppb_flash_menu_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698