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

Side by Side Diff: storage/browser/fileapi/file_system_operation_impl.cc

Issue 1498003003: Remove kint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: INT64_MAX Created 5 years 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
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 "storage/browser/fileapi/file_system_operation_impl.h" 5 #include "storage/browser/fileapi/file_system_operation_impl.h"
6 6
7 #include <limits>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
9 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 12 #include "base/time/time.h"
11 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
12 #include "net/base/escape.h" 14 #include "net/base/escape.h"
13 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
14 #include "storage/browser/blob/shareable_file_reference.h" 16 #include "storage/browser/blob/shareable_file_reference.h"
15 #include "storage/browser/fileapi/async_file_util.h" 17 #include "storage/browser/fileapi/async_file_util.h"
16 #include "storage/browser/fileapi/copy_or_move_operation_delegate.h" 18 #include "storage/browser/fileapi/copy_or_move_operation_delegate.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 scoped_ptr<net::URLRequest> blob_request, 193 scoped_ptr<net::URLRequest> blob_request,
192 const WriteCallback& callback) { 194 const WriteCallback& callback) {
193 DCHECK(SetPendingOperationType(kOperationWrite)); 195 DCHECK(SetPendingOperationType(kOperationWrite));
194 file_writer_delegate_ = writer_delegate.Pass(); 196 file_writer_delegate_ = writer_delegate.Pass();
195 file_writer_delegate_->Start( 197 file_writer_delegate_->Start(
196 blob_request.Pass(), 198 blob_request.Pass(),
197 base::Bind(&FileSystemOperationImpl::DidWrite, 199 base::Bind(&FileSystemOperationImpl::DidWrite,
198 weak_factory_.GetWeakPtr(), url, callback)); 200 weak_factory_.GetWeakPtr(), url, callback));
199 } 201 }
200 202
201 void FileSystemOperationImpl::Truncate(const FileSystemURL& url, int64 length, 203 void FileSystemOperationImpl::Truncate(const FileSystemURL& url,
204 int64_t length,
202 const StatusCallback& callback) { 205 const StatusCallback& callback) {
203 DCHECK(SetPendingOperationType(kOperationTruncate)); 206 DCHECK(SetPendingOperationType(kOperationTruncate));
204 207
205 // crbug.com/349708 208 // crbug.com/349708
206 TRACE_EVENT0("io", "FileSystemOperationImpl::Truncate"); 209 TRACE_EVENT0("io", "FileSystemOperationImpl::Truncate");
207 210
208 GetUsageAndQuotaThenRunTask( 211 GetUsageAndQuotaThenRunTask(
209 url, 212 url,
210 base::Bind(&FileSystemOperationImpl::DoTruncate, 213 base::Bind(&FileSystemOperationImpl::DoTruncate,
211 weak_factory_.GetWeakPtr(), url, callback, length), 214 weak_factory_.GetWeakPtr(), url, callback, length),
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 void FileSystemOperationImpl::GetUsageAndQuotaThenRunTask( 389 void FileSystemOperationImpl::GetUsageAndQuotaThenRunTask(
387 const FileSystemURL& url, 390 const FileSystemURL& url,
388 const base::Closure& task, 391 const base::Closure& task,
389 const base::Closure& error_callback) { 392 const base::Closure& error_callback) {
390 storage::QuotaManagerProxy* quota_manager_proxy = 393 storage::QuotaManagerProxy* quota_manager_proxy =
391 file_system_context()->quota_manager_proxy(); 394 file_system_context()->quota_manager_proxy();
392 if (!quota_manager_proxy || 395 if (!quota_manager_proxy ||
393 !file_system_context()->GetQuotaUtil(url.type())) { 396 !file_system_context()->GetQuotaUtil(url.type())) {
394 // If we don't have the quota manager or the requested filesystem type 397 // If we don't have the quota manager or the requested filesystem type
395 // does not support quota, we should be able to let it go. 398 // does not support quota, we should be able to let it go.
396 operation_context_->set_allowed_bytes_growth(kint64max); 399 operation_context_->set_allowed_bytes_growth(
400 std::numeric_limits<int64_t>::max());
397 task.Run(); 401 task.Run();
398 return; 402 return;
399 } 403 }
400 404
401 DCHECK(quota_manager_proxy); 405 DCHECK(quota_manager_proxy);
402 DCHECK(quota_manager_proxy->quota_manager()); 406 DCHECK(quota_manager_proxy->quota_manager());
403 quota_manager_proxy->quota_manager()->GetUsageAndQuota( 407 quota_manager_proxy->quota_manager()->GetUsageAndQuota(
404 url.origin(), 408 url.origin(),
405 FileSystemTypeToQuotaStorageType(url.type()), 409 FileSystemTypeToQuotaStorageType(url.type()),
406 base::Bind(&FileSystemOperationImpl::DidGetUsageAndQuotaAndRunTask, 410 base::Bind(&FileSystemOperationImpl::DidGetUsageAndQuotaAndRunTask,
407 weak_factory_.GetWeakPtr(), task, error_callback)); 411 weak_factory_.GetWeakPtr(), task, error_callback));
408 } 412 }
409 413
410 void FileSystemOperationImpl::DidGetUsageAndQuotaAndRunTask( 414 void FileSystemOperationImpl::DidGetUsageAndQuotaAndRunTask(
411 const base::Closure& task, 415 const base::Closure& task,
412 const base::Closure& error_callback, 416 const base::Closure& error_callback,
413 storage::QuotaStatusCode status, 417 storage::QuotaStatusCode status,
414 int64 usage, 418 int64_t usage,
415 int64 quota) { 419 int64_t quota) {
416 if (status != storage::kQuotaStatusOk) { 420 if (status != storage::kQuotaStatusOk) {
417 LOG(WARNING) << "Got unexpected quota error : " << status; 421 LOG(WARNING) << "Got unexpected quota error : " << status;
418 error_callback.Run(); 422 error_callback.Run();
419 return; 423 return;
420 } 424 }
421 425
422 operation_context_->set_allowed_bytes_growth(quota - usage); 426 operation_context_->set_allowed_bytes_growth(quota - usage);
423 task.Run(); 427 task.Run();
424 } 428 }
425 429
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 const StatusCallback& callback) { 480 const StatusCallback& callback) {
477 async_file_util_->CopyInForeignFile( 481 async_file_util_->CopyInForeignFile(
478 operation_context_.Pass(), 482 operation_context_.Pass(),
479 src_local_disk_file_path, dest_url, 483 src_local_disk_file_path, dest_url,
480 base::Bind(&FileSystemOperationImpl::DidFinishOperation, 484 base::Bind(&FileSystemOperationImpl::DidFinishOperation,
481 weak_factory_.GetWeakPtr(), callback)); 485 weak_factory_.GetWeakPtr(), callback));
482 } 486 }
483 487
484 void FileSystemOperationImpl::DoTruncate(const FileSystemURL& url, 488 void FileSystemOperationImpl::DoTruncate(const FileSystemURL& url,
485 const StatusCallback& callback, 489 const StatusCallback& callback,
486 int64 length) { 490 int64_t length) {
487 async_file_util_->Truncate( 491 async_file_util_->Truncate(
488 operation_context_.Pass(), url, length, 492 operation_context_.Pass(), url, length,
489 base::Bind(&FileSystemOperationImpl::DidFinishOperation, 493 base::Bind(&FileSystemOperationImpl::DidFinishOperation,
490 weak_factory_.GetWeakPtr(), callback)); 494 weak_factory_.GetWeakPtr(), callback));
491 } 495 }
492 496
493 void FileSystemOperationImpl::DoOpenFile(const FileSystemURL& url, 497 void FileSystemOperationImpl::DoOpenFile(const FileSystemURL& url,
494 const OpenFileCallback& callback, 498 const OpenFileCallback& callback,
495 int file_flags) { 499 int file_flags) {
496 async_file_util_->CreateOrOpen( 500 async_file_util_->CreateOrOpen(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 return; 569 return;
566 } 570 }
567 571
568 callback.Run(rv); 572 callback.Run(rv);
569 } 573 }
570 574
571 void FileSystemOperationImpl::DidWrite( 575 void FileSystemOperationImpl::DidWrite(
572 const FileSystemURL& url, 576 const FileSystemURL& url,
573 const WriteCallback& write_callback, 577 const WriteCallback& write_callback,
574 base::File::Error rv, 578 base::File::Error rv,
575 int64 bytes, 579 int64_t bytes,
576 FileWriterDelegate::WriteProgressStatus write_status) { 580 FileWriterDelegate::WriteProgressStatus write_status) {
577 const bool complete = ( 581 const bool complete = (
578 write_status != FileWriterDelegate::SUCCESS_IO_PENDING); 582 write_status != FileWriterDelegate::SUCCESS_IO_PENDING);
579 if (complete && write_status != FileWriterDelegate::ERROR_WRITE_NOT_STARTED) { 583 if (complete && write_status != FileWriterDelegate::ERROR_WRITE_NOT_STARTED) {
580 DCHECK(operation_context_); 584 DCHECK(operation_context_);
581 operation_context_->change_observers()->Notify( 585 operation_context_->change_observers()->Notify(
582 &FileChangeObserver::OnModifyFile, base::MakeTuple(url)); 586 &FileChangeObserver::OnModifyFile, base::MakeTuple(url));
583 } 587 }
584 588
585 StatusCallback cancel_callback = cancel_callback_; 589 StatusCallback cancel_callback = cancel_callback_;
586 write_callback.Run(rv, bytes, complete); 590 write_callback.Run(rv, bytes, complete);
587 if (!cancel_callback.is_null()) 591 if (!cancel_callback.is_null())
588 cancel_callback.Run(base::File::FILE_OK); 592 cancel_callback.Run(base::File::FILE_OK);
589 } 593 }
590 594
591 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) { 595 bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) {
592 if (pending_operation_ != kOperationNone) 596 if (pending_operation_ != kOperationNone)
593 return false; 597 return false;
594 pending_operation_ = type; 598 pending_operation_ = type;
595 return true; 599 return true;
596 } 600 }
597 601
598 } // namespace storage 602 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/file_system_operation_impl.h ('k') | storage/browser/fileapi/sandbox_file_stream_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698