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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_file_system_browser_host.cc

Issue 130053003: [Pepper] Wire up append mode writing support of FileIO (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/max_written_offsets/file_sizes/g 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h " 5 #include "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h "
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "content/browser/renderer_host/pepper/pepper_file_io_host.h" 9 #include "content/browser/renderer_host/pepper/pepper_file_io_host.h"
10 #include "content/browser/renderer_host/pepper/quota_reservation.h" 10 #include "content/browser/renderer_host/pepper/quota_reservation.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 base::Bind(&GetFileSystemContextFromRenderId, render_process_id), 358 base::Bind(&GetFileSystemContextFromRenderId, render_process_id),
359 base::Bind(&PepperFileSystemBrowserHost::OpenIsolatedFileSystem, 359 base::Bind(&PepperFileSystemBrowserHost::OpenIsolatedFileSystem,
360 weak_factory_.GetWeakPtr(), 360 weak_factory_.GetWeakPtr(),
361 context->MakeReplyMessageContext(), fsid, type)); 361 context->MakeReplyMessageContext(), fsid, type));
362 return PP_OK_COMPLETIONPENDING; 362 return PP_OK_COMPLETIONPENDING;
363 } 363 }
364 364
365 int32_t PepperFileSystemBrowserHost::OnHostMsgReserveQuota( 365 int32_t PepperFileSystemBrowserHost::OnHostMsgReserveQuota(
366 ppapi::host::HostMessageContext* context, 366 ppapi::host::HostMessageContext* context,
367 int64_t amount, 367 int64_t amount,
368 const ppapi::FileSizeMap& file_sizes) { 368 const ppapi::FileGrowthMap& file_growths) {
369 DCHECK(ChecksQuota()); 369 DCHECK(ChecksQuota());
370 DCHECK(amount > 0); 370 DCHECK(amount > 0);
371 371
372 if (reserving_quota_) 372 if (reserving_quota_)
373 return PP_ERROR_INPROGRESS; 373 return PP_ERROR_INPROGRESS;
374 reserving_quota_ = true; 374 reserving_quota_ = true;
375 375
376 ppapi::FileGrowthMap file_growths;
377 for (ppapi::FileSizeMap::const_iterator it = file_sizes.begin();
378 it != file_sizes.end(); ++it)
379 file_growths[it->first] = ppapi::FileGrowth(it->second, 0);
380
381 int64_t reservation_amount = std::max<int64_t>(kMinimumQuotaReservationSize, 376 int64_t reservation_amount = std::max<int64_t>(kMinimumQuotaReservationSize,
382 amount); 377 amount);
383 file_system_context_->default_file_task_runner()->PostTask( 378 file_system_context_->default_file_task_runner()->PostTask(
384 FROM_HERE, 379 FROM_HERE,
385 base::Bind(&QuotaReservation::ReserveQuota, 380 base::Bind(&QuotaReservation::ReserveQuota,
386 quota_reservation_, 381 quota_reservation_,
387 reservation_amount, 382 reservation_amount,
388 file_growths, 383 file_growths,
389 base::Bind(&PepperFileSystemBrowserHost::GotReservedQuota, 384 base::Bind(&PepperFileSystemBrowserHost::GotReservedQuota,
390 weak_factory_.GetWeakPtr(), 385 weak_factory_.GetWeakPtr(),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 void PepperFileSystemBrowserHost::GotQuotaReservation( 451 void PepperFileSystemBrowserHost::GotQuotaReservation(
457 const base::Closure& callback, 452 const base::Closure& callback,
458 scoped_refptr<QuotaReservation> quota_reservation) { 453 scoped_refptr<QuotaReservation> quota_reservation) {
459 quota_reservation_ = quota_reservation; 454 quota_reservation_ = quota_reservation;
460 callback.Run(); 455 callback.Run();
461 } 456 }
462 457
463 void PepperFileSystemBrowserHost::GotReservedQuota( 458 void PepperFileSystemBrowserHost::GotReservedQuota(
464 ppapi::host::ReplyMessageContext reply_context, 459 ppapi::host::ReplyMessageContext reply_context,
465 int64_t amount, 460 int64_t amount,
466 const ppapi::FileSizeMap& max_written_offsets) { 461 const ppapi::FileSizeMap& file_sizes) {
467 DCHECK(reserving_quota_); 462 DCHECK(reserving_quota_);
468 reserving_quota_ = false; 463 reserving_quota_ = false;
469 reserved_quota_ = amount; 464 reserved_quota_ = amount;
470 465
471 reply_context.params.set_result(PP_OK); 466 reply_context.params.set_result(PP_OK);
472 host()->SendReply( 467 host()->SendReply(
473 reply_context, 468 reply_context,
474 PpapiPluginMsg_FileSystem_ReserveQuotaReply(amount, max_written_offsets)); 469 PpapiPluginMsg_FileSystem_ReserveQuotaReply(amount, file_sizes));
475 } 470 }
476 471
477 std::string PepperFileSystemBrowserHost::GetPluginMimeType() const { 472 std::string PepperFileSystemBrowserHost::GetPluginMimeType() const {
478 base::FilePath plugin_path = browser_ppapi_host_->GetPluginPath(); 473 base::FilePath plugin_path = browser_ppapi_host_->GetPluginPath();
479 PepperPluginInfo* info = 474 PepperPluginInfo* info =
480 PluginService::GetInstance()->GetRegisteredPpapiPluginInfo(plugin_path); 475 PluginService::GetInstance()->GetRegisteredPpapiPluginInfo(plugin_path);
481 if (!info || info->mime_types.empty()) 476 if (!info || info->mime_types.empty())
482 return std::string(); 477 return std::string();
483 // Use the first element in |info->mime_types| even if several elements exist. 478 // Use the first element in |info->mime_types| even if several elements exist.
484 return info->mime_types[0].mime_type; 479 return info->mime_types[0].mime_type;
(...skipping 19 matching lines...) Expand all
504 if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) && 499 if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it) &&
505 *it != '.' && *it != '_' && *it != '-') { 500 *it != '.' && *it != '_' && *it != '-') {
506 LOG(WARNING) << "Failed to generate a plugin id."; 501 LOG(WARNING) << "Failed to generate a plugin id.";
507 return std::string(); 502 return std::string();
508 } 503 }
509 } 504 }
510 return output; 505 return output;
511 } 506 }
512 507
513 } // namespace content 508 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698