OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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/file_system_resource.h" | 5 #include "ppapi/proxy/file_system_resource.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "ipc/ipc_message.h" | 8 #include "ipc/ipc_message.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
11 #include "ppapi/shared_impl/tracked_callback.h" | 11 #include "ppapi/shared_impl/tracked_callback.h" |
12 | 12 |
13 using ppapi::thunk::PPB_FileSystem_API; | 13 using ppapi::thunk::PPB_FileSystem_API; |
14 | 14 |
15 namespace ppapi { | 15 namespace ppapi { |
16 namespace proxy { | 16 namespace proxy { |
17 | 17 |
18 FileSystemResource::FileSystemResource(Connection connection, | 18 FileSystemResource::FileSystemResource(Connection connection, |
19 PP_Instance instance, | 19 PP_Instance instance, |
20 PP_FileSystemType type) | 20 PP_FileSystemType type) |
21 : PluginResource(connection, instance), | 21 : PluginResource(connection, instance), |
22 type_(type), | 22 type_(type), |
23 called_open_(false), | 23 called_open_(false), |
24 callback_count_(0) { | 24 callback_count_(0), |
25 callback_result_(PP_OK) { | |
25 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID); | 26 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID); |
26 SendCreate(RENDERER, PpapiHostMsg_FileSystem_Create(type_)); | 27 SendCreate(RENDERER, PpapiHostMsg_FileSystem_Create(type_)); |
27 SendCreate(BROWSER, PpapiHostMsg_FileSystem_Create(type_)); | 28 SendCreate(BROWSER, PpapiHostMsg_FileSystem_Create(type_)); |
28 } | 29 } |
29 | 30 |
30 FileSystemResource::FileSystemResource(Connection connection, | 31 FileSystemResource::FileSystemResource(Connection connection, |
31 PP_Instance instance, | 32 PP_Instance instance, |
32 int pending_renderer_id, | 33 int pending_renderer_id, |
33 int pending_browser_id, | 34 int pending_browser_id, |
34 PP_FileSystemType type) | 35 PP_FileSystemType type) |
35 : PluginResource(connection, instance), | 36 : PluginResource(connection, instance), |
36 type_(type), | 37 type_(type), |
37 called_open_(true) { | 38 called_open_(true), |
39 callback_count_(0), | |
40 callback_result_(PP_OK) { | |
38 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID); | 41 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID); |
39 AttachToPendingHost(RENDERER, pending_renderer_id); | 42 AttachToPendingHost(RENDERER, pending_renderer_id); |
40 AttachToPendingHost(BROWSER, pending_browser_id); | 43 AttachToPendingHost(BROWSER, pending_browser_id); |
41 } | 44 } |
42 | 45 |
43 FileSystemResource::~FileSystemResource() { | 46 FileSystemResource::~FileSystemResource() { |
44 } | 47 } |
45 | 48 |
46 PPB_FileSystem_API* FileSystemResource::AsPPB_FileSystem_API() { | 49 PPB_FileSystem_API* FileSystemResource::AsPPB_FileSystem_API() { |
47 return this; | 50 return this; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 base::Bind(&FileSystemResource::InitIsolatedFileSystemComplete, | 95 base::Bind(&FileSystemResource::InitIsolatedFileSystemComplete, |
93 this, | 96 this, |
94 callback)); | 97 callback)); |
95 return PP_OK_COMPLETIONPENDING; | 98 return PP_OK_COMPLETIONPENDING; |
96 } | 99 } |
97 | 100 |
98 void FileSystemResource::OpenComplete( | 101 void FileSystemResource::OpenComplete( |
99 scoped_refptr<TrackedCallback> callback, | 102 scoped_refptr<TrackedCallback> callback, |
100 const ResourceMessageReplyParams& params) { | 103 const ResourceMessageReplyParams& params) { |
101 ++callback_count_; | 104 ++callback_count_; |
105 if (params.result() != PP_OK) | |
106 callback_result_ = params.result(); | |
teravest
2013/11/12 18:04:53
Thanks for cleaning this up.
| |
102 // Received callback from browser and renderer. | 107 // Received callback from browser and renderer. |
103 if (callback_count_ == 2) | 108 if (callback_count_ == 2) |
104 callback->Run(params.result()); | 109 callback->Run(callback_result_); |
105 } | 110 } |
106 | 111 |
107 void FileSystemResource::InitIsolatedFileSystemComplete( | 112 void FileSystemResource::InitIsolatedFileSystemComplete( |
108 const base::Callback<void(int32_t)>& callback, | 113 const base::Callback<void(int32_t)>& callback, |
109 const ResourceMessageReplyParams& params) { | 114 const ResourceMessageReplyParams& params) { |
110 ++callback_count_; | 115 ++callback_count_; |
116 if (params.result() != PP_OK) | |
117 callback_result_ = params.result(); | |
111 // Received callback from browser and renderer. | 118 // Received callback from browser and renderer. |
112 if (callback_count_ == 2) | 119 if (callback_count_ == 2) |
113 callback.Run(params.result()); | 120 callback.Run(callback_result_); |
114 } | 121 } |
115 | 122 |
116 } // namespace proxy | 123 } // namespace proxy |
117 } // namespace ppapi | 124 } // namespace ppapi |
OLD | NEW |