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

Side by Side Diff: chrome/browser/sync_file_system/local/canned_syncable_file_system.cc

Issue 1545223002: Switch to standard integer types in chrome/browser/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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
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 "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" 5 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h"
6 6
7 #include <stddef.h>
8
7 #include <algorithm> 9 #include <algorithm>
8 #include <iterator> 10 #include <iterator>
9 11
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
12 #include "base/files/file.h" 14 #include "base/files/file.h"
13 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
14 #include "base/guid.h" 16 #include "base/guid.h"
17 #include "base/macros.h"
15 #include "base/run_loop.h" 18 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
17 #include "base/task_runner_util.h" 20 #include "base/task_runner_util.h"
18 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
19 #include "base/trace_event/trace_event.h" 22 #include "base/trace_event/trace_event.h"
20 #include "chrome/browser/sync_file_system/file_change.h" 23 #include "chrome/browser/sync_file_system/file_change.h"
21 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" 24 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h"
22 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" 25 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h"
23 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" 26 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
24 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" 27 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 164
162 ~WriteHelper() { 165 ~WriteHelper() {
163 if (request_context_) { 166 if (request_context_) {
164 base::ThreadTaskRunnerHandle::Get()->DeleteSoon( 167 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
165 FROM_HERE, request_context_.release()); 168 FROM_HERE, request_context_.release());
166 } 169 }
167 } 170 }
168 171
169 ScopedTextBlob* scoped_text_blob() const { return blob_data_.get(); } 172 ScopedTextBlob* scoped_text_blob() const { return blob_data_.get(); }
170 173
171 void DidWrite(const base::Callback<void(int64 result)>& completion_callback, 174 void DidWrite(const base::Callback<void(int64_t result)>& completion_callback,
172 File::Error error, int64 bytes, bool complete) { 175 File::Error error,
176 int64_t bytes,
177 bool complete) {
173 if (error == base::File::FILE_OK) { 178 if (error == base::File::FILE_OK) {
174 bytes_written_ += bytes; 179 bytes_written_ += bytes;
175 if (!complete) 180 if (!complete)
176 return; 181 return;
177 } 182 }
178 completion_callback.Run(error == base::File::FILE_OK ? 183 completion_callback.Run(error == base::File::FILE_OK
179 bytes_written_ : static_cast<int64>(error)); 184 ? bytes_written_
185 : static_cast<int64_t>(error));
180 } 186 }
181 187
182 private: 188 private:
183 int64 bytes_written_; 189 int64_t bytes_written_;
184 scoped_ptr<MockBlobURLRequestContext> request_context_; 190 scoped_ptr<MockBlobURLRequestContext> request_context_;
185 scoped_ptr<ScopedTextBlob> blob_data_; 191 scoped_ptr<ScopedTextBlob> blob_data_;
186 192
187 DISALLOW_COPY_AND_ASSIGN(WriteHelper); 193 DISALLOW_COPY_AND_ASSIGN(WriteHelper);
188 }; 194 };
189 195
190 void DidGetUsageAndQuota(const storage::StatusCallback& callback, 196 void DidGetUsageAndQuota(const storage::StatusCallback& callback,
191 int64* usage_out, 197 int64_t* usage_out,
192 int64* quota_out, 198 int64_t* quota_out,
193 storage::QuotaStatusCode status, 199 storage::QuotaStatusCode status,
194 int64 usage, 200 int64_t usage,
195 int64 quota) { 201 int64_t quota) {
196 *usage_out = usage; 202 *usage_out = usage;
197 *quota_out = quota; 203 *quota_out = quota;
198 callback.Run(status); 204 callback.Run(status);
199 } 205 }
200 206
201 void EnsureLastTaskRuns(base::SingleThreadTaskRunner* runner) { 207 void EnsureLastTaskRuns(base::SingleThreadTaskRunner* runner) {
202 base::RunLoop run_loop; 208 base::RunLoop run_loop;
203 runner->PostTaskAndReply( 209 runner->PostTaskAndReply(
204 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure()); 210 FROM_HERE, base::Bind(&base::DoNothing), run_loop.QuitClosure());
205 run_loop.Run(); 211 run_loop.Run();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 File::Error CannedSyncableFileSystem::Move( 372 File::Error CannedSyncableFileSystem::Move(
367 const FileSystemURL& src_url, const FileSystemURL& dest_url) { 373 const FileSystemURL& src_url, const FileSystemURL& dest_url) {
368 return RunOnThread<File::Error>(io_task_runner_.get(), 374 return RunOnThread<File::Error>(io_task_runner_.get(),
369 FROM_HERE, 375 FROM_HERE,
370 base::Bind(&CannedSyncableFileSystem::DoMove, 376 base::Bind(&CannedSyncableFileSystem::DoMove,
371 base::Unretained(this), 377 base::Unretained(this),
372 src_url, 378 src_url,
373 dest_url)); 379 dest_url));
374 } 380 }
375 381
376 File::Error CannedSyncableFileSystem::TruncateFile( 382 File::Error CannedSyncableFileSystem::TruncateFile(const FileSystemURL& url,
377 const FileSystemURL& url, int64 size) { 383 int64_t size) {
378 return RunOnThread<File::Error>( 384 return RunOnThread<File::Error>(
379 io_task_runner_.get(), 385 io_task_runner_.get(),
380 FROM_HERE, 386 FROM_HERE,
381 base::Bind(&CannedSyncableFileSystem::DoTruncateFile, 387 base::Bind(&CannedSyncableFileSystem::DoTruncateFile,
382 base::Unretained(this), 388 base::Unretained(this),
383 url, 389 url,
384 size)); 390 size));
385 } 391 }
386 392
387 File::Error CannedSyncableFileSystem::TouchFile( 393 File::Error CannedSyncableFileSystem::TouchFile(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 FileEntryList* entries) { 466 FileEntryList* entries) {
461 return RunOnThread<File::Error>( 467 return RunOnThread<File::Error>(
462 io_task_runner_.get(), 468 io_task_runner_.get(),
463 FROM_HERE, 469 FROM_HERE,
464 base::Bind(&CannedSyncableFileSystem::DoReadDirectory, 470 base::Bind(&CannedSyncableFileSystem::DoReadDirectory,
465 base::Unretained(this), 471 base::Unretained(this),
466 url, 472 url,
467 entries)); 473 entries));
468 } 474 }
469 475
470 int64 CannedSyncableFileSystem::Write( 476 int64_t CannedSyncableFileSystem::Write(
471 net::URLRequestContext* url_request_context, 477 net::URLRequestContext* url_request_context,
472 const FileSystemURL& url, 478 const FileSystemURL& url,
473 scoped_ptr<storage::BlobDataHandle> blob_data_handle) { 479 scoped_ptr<storage::BlobDataHandle> blob_data_handle) {
474 return RunOnThread<int64>(io_task_runner_.get(), 480 return RunOnThread<int64_t>(
475 FROM_HERE, 481 io_task_runner_.get(), FROM_HERE,
476 base::Bind(&CannedSyncableFileSystem::DoWrite, 482 base::Bind(&CannedSyncableFileSystem::DoWrite, base::Unretained(this),
477 base::Unretained(this), 483 url_request_context, url, base::Passed(&blob_data_handle)));
478 url_request_context,
479 url,
480 base::Passed(&blob_data_handle)));
481 } 484 }
482 485
483 int64 CannedSyncableFileSystem::WriteString( 486 int64_t CannedSyncableFileSystem::WriteString(const FileSystemURL& url,
484 const FileSystemURL& url, const std::string& data) { 487 const std::string& data) {
485 return RunOnThread<int64>(io_task_runner_.get(), 488 return RunOnThread<int64_t>(
486 FROM_HERE, 489 io_task_runner_.get(), FROM_HERE,
487 base::Bind(&CannedSyncableFileSystem::DoWriteString, 490 base::Bind(&CannedSyncableFileSystem::DoWriteString,
488 base::Unretained(this), 491 base::Unretained(this), url, data));
489 url,
490 data));
491 } 492 }
492 493
493 File::Error CannedSyncableFileSystem::DeleteFileSystem() { 494 File::Error CannedSyncableFileSystem::DeleteFileSystem() {
494 EXPECT_TRUE(is_filesystem_set_up_); 495 EXPECT_TRUE(is_filesystem_set_up_);
495 return RunOnThread<File::Error>( 496 return RunOnThread<File::Error>(
496 io_task_runner_.get(), 497 io_task_runner_.get(),
497 FROM_HERE, 498 FROM_HERE,
498 base::Bind(&FileSystemContext::DeleteFileSystem, 499 base::Bind(&FileSystemContext::DeleteFileSystem,
499 file_system_context_, 500 file_system_context_,
500 origin_, 501 origin_,
501 type_)); 502 type_));
502 } 503 }
503 504
504 storage::QuotaStatusCode CannedSyncableFileSystem::GetUsageAndQuota( 505 storage::QuotaStatusCode CannedSyncableFileSystem::GetUsageAndQuota(
505 int64* usage, 506 int64_t* usage,
506 int64* quota) { 507 int64_t* quota) {
507 return RunOnThread<storage::QuotaStatusCode>( 508 return RunOnThread<storage::QuotaStatusCode>(
508 io_task_runner_.get(), 509 io_task_runner_.get(),
509 FROM_HERE, 510 FROM_HERE,
510 base::Bind(&CannedSyncableFileSystem::DoGetUsageAndQuota, 511 base::Bind(&CannedSyncableFileSystem::DoGetUsageAndQuota,
511 base::Unretained(this), 512 base::Unretained(this),
512 usage, 513 usage,
513 quota)); 514 quota));
514 } 515 }
515 516
516 void CannedSyncableFileSystem::GetChangedURLsInTracker( 517 void CannedSyncableFileSystem::GetChangedURLsInTracker(
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 void CannedSyncableFileSystem::DoMove( 604 void CannedSyncableFileSystem::DoMove(
604 const FileSystemURL& src_url, 605 const FileSystemURL& src_url,
605 const FileSystemURL& dest_url, 606 const FileSystemURL& dest_url,
606 const StatusCallback& callback) { 607 const StatusCallback& callback) {
607 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); 608 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread());
608 EXPECT_TRUE(is_filesystem_opened_); 609 EXPECT_TRUE(is_filesystem_opened_);
609 operation_runner()->Move( 610 operation_runner()->Move(
610 src_url, dest_url, storage::FileSystemOperation::OPTION_NONE, callback); 611 src_url, dest_url, storage::FileSystemOperation::OPTION_NONE, callback);
611 } 612 }
612 613
613 void CannedSyncableFileSystem::DoTruncateFile( 614 void CannedSyncableFileSystem::DoTruncateFile(const FileSystemURL& url,
614 const FileSystemURL& url, int64 size, 615 int64_t size,
615 const StatusCallback& callback) { 616 const StatusCallback& callback) {
616 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); 617 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread());
617 EXPECT_TRUE(is_filesystem_opened_); 618 EXPECT_TRUE(is_filesystem_opened_);
618 operation_runner()->Truncate(url, size, callback); 619 operation_runner()->Truncate(url, size, callback);
619 } 620 }
620 621
621 void CannedSyncableFileSystem::DoTouchFile( 622 void CannedSyncableFileSystem::DoTouchFile(
622 const FileSystemURL& url, 623 const FileSystemURL& url,
623 const base::Time& last_access_time, 624 const base::Time& last_access_time,
624 const base::Time& last_modified_time, 625 const base::Time& last_modified_time,
625 const StatusCallback& callback) { 626 const StatusCallback& callback) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 MockBlobURLRequestContext* url_request_context( 707 MockBlobURLRequestContext* url_request_context(
707 new MockBlobURLRequestContext(file_system_context_.get())); 708 new MockBlobURLRequestContext(file_system_context_.get()));
708 WriteHelper* helper = new WriteHelper(url_request_context, data); 709 WriteHelper* helper = new WriteHelper(url_request_context, data);
709 operation_runner()->Write(url_request_context, url, 710 operation_runner()->Write(url_request_context, url,
710 helper->scoped_text_blob()->GetBlobDataHandle(), 0, 711 helper->scoped_text_blob()->GetBlobDataHandle(), 0,
711 base::Bind(&WriteHelper::DidWrite, 712 base::Bind(&WriteHelper::DidWrite,
712 base::Owned(helper), callback)); 713 base::Owned(helper), callback));
713 } 714 }
714 715
715 void CannedSyncableFileSystem::DoGetUsageAndQuota( 716 void CannedSyncableFileSystem::DoGetUsageAndQuota(
716 int64* usage, 717 int64_t* usage,
717 int64* quota, 718 int64_t* quota,
718 const storage::StatusCallback& callback) { 719 const storage::StatusCallback& callback) {
719 // crbug.com/349708 720 // crbug.com/349708
720 TRACE_EVENT0("io", "CannedSyncableFileSystem::DoGetUsageAndQuota"); 721 TRACE_EVENT0("io", "CannedSyncableFileSystem::DoGetUsageAndQuota");
721 722
722 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); 723 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread());
723 EXPECT_TRUE(is_filesystem_opened_); 724 EXPECT_TRUE(is_filesystem_opened_);
724 DCHECK(quota_manager_.get()); 725 DCHECK(quota_manager_.get());
725 quota_manager_->GetUsageAndQuota( 726 quota_manager_->GetUsageAndQuota(
726 origin_, storage_type(), 727 origin_, storage_type(),
727 base::Bind(&DidGetUsageAndQuota, callback, usage, quota)); 728 base::Bind(&DidGetUsageAndQuota, callback, usage, quota));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 sync_status_ = status; 760 sync_status_ = status;
760 quit_closure.Run(); 761 quit_closure.Run();
761 } 762 }
762 763
763 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { 764 void CannedSyncableFileSystem::InitializeSyncStatusObserver() {
764 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); 765 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread());
765 backend()->sync_context()->sync_status()->AddObserver(this); 766 backend()->sync_context()->sync_status()->AddObserver(this);
766 } 767 }
767 768
768 } // namespace sync_file_system 769 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698