| OLD | NEW |
| 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 Loading... |
| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |