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

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

Issue 130053003: [Pepper] Wire up append mode writing support of FileIO (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
OLDNEW
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
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 continue; 183 continue;
185 PPB_FileIO_API* file_io_api = enter.object(); 184 PPB_FileIO_API* file_io_api = enter.object();
186 file_sizes[*it] = 185 file_growths[*it] = FileGrowth(
187 file_io_api->GetMaxWrittenOffset() + 186 file_io_api->GetMaxWrittenOffset(),
188 file_io_api->GetAppendModeWriteAmount(); 187 file_io_api->GetAppendModeWriteAmount());
189 } 188 }
190 Call<PpapiPluginMsg_FileSystem_ReserveQuotaReply>(BROWSER, 189 Call<PpapiPluginMsg_FileSystem_ReserveQuotaReply>(BROWSER,
191 PpapiHostMsg_FileSystem_ReserveQuota(amount, file_sizes), 190 PpapiHostMsg_FileSystem_ReserveQuota(amount, file_growths),
192 base::Bind(&FileSystemResource::ReserveQuotaComplete, 191 base::Bind(&FileSystemResource::ReserveQuotaComplete,
193 this)); 192 this));
194 } 193 }
195 194
196 void FileSystemResource::ReserveQuotaComplete( 195 void FileSystemResource::ReserveQuotaComplete(
197 const ResourceMessageReplyParams& params, 196 const ResourceMessageReplyParams& params,
198 int64_t amount, 197 int64_t amount,
199 const FileSizeMap& max_written_offsets) { 198 const FileSizeMap& max_written_offsets) {
200 DCHECK(reserving_quota_); 199 DCHECK(reserving_quota_);
201 reserving_quota_ = false; 200 reserving_quota_ = false;
(...skipping 26 matching lines...) Expand all
228 // Refresh the quota reservation for the first pending request that we 227 // Refresh the quota reservation for the first pending request that we
229 // can't satisfy. 228 // can't satisfy.
230 ReserveQuota(request.amount); 229 ReserveQuota(request.amount);
231 break; 230 break;
232 } 231 }
233 } 232 }
234 } 233 }
235 234
236 } // namespace proxy 235 } // namespace proxy
237 } // namespace ppapi 236 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698