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 "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 callback_result_ = params.result(); | 168 callback_result_ = params.result(); |
169 // Received callback from browser and renderer. | 169 // Received callback from browser and renderer. |
170 if (callback_count_ == 2) | 170 if (callback_count_ == 2) |
171 callback.Run(callback_result_); | 171 callback.Run(callback_result_); |
172 } | 172 } |
173 | 173 |
174 void FileSystemResource::ReserveQuota(int64_t amount) { | 174 void FileSystemResource::ReserveQuota(int64_t amount) { |
175 DCHECK(!reserving_quota_); | 175 DCHECK(!reserving_quota_); |
176 reserving_quota_ = true; | 176 reserving_quota_ = true; |
177 | 177 |
178 // TODO(tzik): Use FileGrowthMap here after the IPC signature changed. | 178 FileGrowthMap file_growths; |
179 FileSizeMap file_sizes; | |
180 for (std::set<PP_Resource>::iterator it = files_.begin(); | 179 for (std::set<PP_Resource>::iterator it = files_.begin(); |
181 it != files_.end(); ++it) { | 180 it != files_.end(); ++it) { |
182 EnterResourceNoLock<PPB_FileIO_API> enter(*it, true); | 181 EnterResourceNoLock<PPB_FileIO_API> enter(*it, true); |
183 if (enter.failed()) { | 182 if (enter.failed()) { |
184 NOTREACHED(); | 183 NOTREACHED(); |
185 continue; | 184 continue; |
186 } | 185 } |
187 PPB_FileIO_API* file_io_api = enter.object(); | 186 PPB_FileIO_API* file_io_api = enter.object(); |
188 file_sizes[*it] = | 187 file_growths[*it] = FileGrowth( |
189 file_io_api->GetMaxWrittenOffset() + | 188 file_io_api->GetMaxWrittenOffset(), |
190 file_io_api->GetAppendModeWriteAmount(); | 189 file_io_api->GetAppendModeWriteAmount()); |
191 } | 190 } |
192 Call<PpapiPluginMsg_FileSystem_ReserveQuotaReply>(BROWSER, | 191 Call<PpapiPluginMsg_FileSystem_ReserveQuotaReply>(BROWSER, |
193 PpapiHostMsg_FileSystem_ReserveQuota(amount, file_sizes), | 192 PpapiHostMsg_FileSystem_ReserveQuota(amount, file_growths), |
194 base::Bind(&FileSystemResource::ReserveQuotaComplete, | 193 base::Bind(&FileSystemResource::ReserveQuotaComplete, |
195 this)); | 194 this)); |
196 } | 195 } |
197 | 196 |
198 void FileSystemResource::ReserveQuotaComplete( | 197 void FileSystemResource::ReserveQuotaComplete( |
199 const ResourceMessageReplyParams& params, | 198 const ResourceMessageReplyParams& params, |
200 int64_t amount, | 199 int64_t amount, |
201 const FileSizeMap& max_written_offsets) { | 200 const FileSizeMap& max_written_offsets) { |
202 DCHECK(reserving_quota_); | 201 DCHECK(reserving_quota_); |
203 reserving_quota_ = false; | 202 reserving_quota_ = false; |
(...skipping 29 matching lines...) Expand all Loading... |
233 // Refresh the quota reservation for the first pending request that we | 232 // Refresh the quota reservation for the first pending request that we |
234 // can't satisfy. | 233 // can't satisfy. |
235 ReserveQuota(request.amount); | 234 ReserveQuota(request.amount); |
236 break; | 235 break; |
237 } | 236 } |
238 } | 237 } |
239 } | 238 } |
240 | 239 |
241 } // namespace proxy | 240 } // namespace proxy |
242 } // namespace ppapi | 241 } // namespace ppapi |
OLD | NEW |