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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h>
6 #include <stdint.h>
7
5 #include <algorithm> 8 #include <algorithm>
6 #include <stack> 9 #include <stack>
7 10
8 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 14 #include "base/run_loop.h"
11 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
12 #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h" 16 #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h"
13 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h" 17 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h"
14 #include "chrome/browser/sync_file_system/drive_backend/fake_drive_service_helpe r.h" 18 #include "chrome/browser/sync_file_system/drive_backend/fake_drive_service_helpe r.h"
15 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" 19 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
16 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" 20 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
17 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h" 21 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h"
18 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h" 22 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 local_sync_service_->Shutdown(); 153 local_sync_service_->Shutdown();
150 154
151 fake_drive_service_helper_.reset(); 155 fake_drive_service_helper_.reset();
152 local_sync_service_.reset(); 156 local_sync_service_.reset();
153 remote_sync_service_.reset(); 157 remote_sync_service_.reset();
154 158
155 content::RunAllBlockingPoolTasksUntilIdle(); 159 content::RunAllBlockingPoolTasksUntilIdle();
156 RevokeSyncableFileSystem(); 160 RevokeSyncableFileSystem();
157 } 161 }
158 162
159 void OnRemoteChangeQueueUpdated(int64 pending_changes_hint) override { 163 void OnRemoteChangeQueueUpdated(int64_t pending_changes_hint) override {
160 pending_remote_changes_ = pending_changes_hint; 164 pending_remote_changes_ = pending_changes_hint;
161 } 165 }
162 166
163 void OnLocalChangeAvailable(int64 pending_changes_hint) override { 167 void OnLocalChangeAvailable(int64_t pending_changes_hint) override {
164 pending_local_changes_ = pending_changes_hint; 168 pending_local_changes_ = pending_changes_hint;
165 } 169 }
166 170
167 protected: 171 protected:
168 storage::FileSystemURL CreateURL(const std::string& app_id, 172 storage::FileSystemURL CreateURL(const std::string& app_id,
169 const base::FilePath::StringType& path) { 173 const base::FilePath::StringType& path) {
170 return CreateURL(app_id, base::FilePath(path)); 174 return CreateURL(app_id, base::FilePath(path));
171 } 175 }
172 176
173 storage::FileSystemURL CreateURL(const std::string& app_id, 177 storage::FileSystemURL CreateURL(const std::string& app_id,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 file_systems_[app_id]->CreateDirectory( 271 file_systems_[app_id]->CreateDirectory(
268 CreateURL(app_id, path))); 272 CreateURL(app_id, path)));
269 } 273 }
270 274
271 void AddOrUpdateLocalFile(const std::string& app_id, 275 void AddOrUpdateLocalFile(const std::string& app_id,
272 const base::FilePath::StringType& path, 276 const base::FilePath::StringType& path,
273 const std::string& content) { 277 const std::string& content) {
274 storage::FileSystemURL url(CreateURL(app_id, path)); 278 storage::FileSystemURL url(CreateURL(app_id, path));
275 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); 279 ASSERT_TRUE(ContainsKey(file_systems_, app_id));
276 EXPECT_EQ(base::File::FILE_OK, file_systems_[app_id]->CreateFile(url)); 280 EXPECT_EQ(base::File::FILE_OK, file_systems_[app_id]->CreateFile(url));
277 int64 bytes_written = file_systems_[app_id]->WriteString(url, content); 281 int64_t bytes_written = file_systems_[app_id]->WriteString(url, content);
278 EXPECT_EQ(static_cast<int64>(content.size()), bytes_written); 282 EXPECT_EQ(static_cast<int64_t>(content.size()), bytes_written);
279 base::RunLoop().RunUntilIdle(); 283 base::RunLoop().RunUntilIdle();
280 } 284 }
281 285
282 void UpdateLocalFile(const std::string& app_id, 286 void UpdateLocalFile(const std::string& app_id,
283 const base::FilePath::StringType& path, 287 const base::FilePath::StringType& path,
284 const std::string& content) { 288 const std::string& content) {
285 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); 289 ASSERT_TRUE(ContainsKey(file_systems_, app_id));
286 int64 bytes_written = file_systems_[app_id]->WriteString( 290 int64_t bytes_written =
287 CreateURL(app_id, path), content); 291 file_systems_[app_id]->WriteString(CreateURL(app_id, path), content);
288 EXPECT_EQ(static_cast<int64>(content.size()), bytes_written); 292 EXPECT_EQ(static_cast<int64_t>(content.size()), bytes_written);
289 base::RunLoop().RunUntilIdle(); 293 base::RunLoop().RunUntilIdle();
290 } 294 }
291 295
292 void RemoveLocal(const std::string& app_id, 296 void RemoveLocal(const std::string& app_id,
293 const base::FilePath::StringType& path) { 297 const base::FilePath::StringType& path) {
294 ASSERT_TRUE(ContainsKey(file_systems_, app_id)); 298 ASSERT_TRUE(ContainsKey(file_systems_, app_id));
295 EXPECT_EQ(base::File::FILE_OK, 299 EXPECT_EQ(base::File::FILE_OK,
296 file_systems_[app_id]->Remove( 300 file_systems_[app_id]->Remove(
297 CreateURL(app_id, path), 301 CreateURL(app_id, path),
298 true /* recursive */)); 302 true /* recursive */));
(...skipping 13 matching lines...) Expand all
312 SyncStatusCode ProcessRemoteChange() { 316 SyncStatusCode ProcessRemoteChange() {
313 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 317 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
314 storage::FileSystemURL url; 318 storage::FileSystemURL url;
315 base::RunLoop run_loop; 319 base::RunLoop run_loop;
316 remote_sync_service_->ProcessRemoteChange(base::Bind( 320 remote_sync_service_->ProcessRemoteChange(base::Bind(
317 &SetSyncStatusAndUrl, run_loop.QuitClosure(), &status, &url)); 321 &SetSyncStatusAndUrl, run_loop.QuitClosure(), &status, &url));
318 run_loop.Run(); 322 run_loop.Run();
319 return status; 323 return status;
320 } 324 }
321 325
322 int64 GetLargestChangeID() { 326 int64_t GetLargestChangeID() {
323 scoped_ptr<google_apis::AboutResource> about_resource; 327 scoped_ptr<google_apis::AboutResource> about_resource;
324 EXPECT_EQ(google_apis::HTTP_SUCCESS, 328 EXPECT_EQ(google_apis::HTTP_SUCCESS,
325 fake_drive_service_helper()->GetAboutResource(&about_resource)); 329 fake_drive_service_helper()->GetAboutResource(&about_resource));
326 if (!about_resource) 330 if (!about_resource)
327 return 0; 331 return 0;
328 return about_resource->largest_change_id(); 332 return about_resource->largest_change_id();
329 } 333 }
330 334
331 void FetchRemoteChanges() { 335 void FetchRemoteChanges() {
332 remote_sync_service_->OnNotificationReceived(); 336 remote_sync_service_->OnNotificationReceived();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 { 371 {
368 base::RunLoop run_loop; 372 base::RunLoop run_loop;
369 local_sync_service_->PromoteDemotedChanges(run_loop.QuitClosure()); 373 local_sync_service_->PromoteDemotedChanges(run_loop.QuitClosure());
370 run_loop.Run(); 374 run_loop.Run();
371 } 375 }
372 376
373 if (pending_remote_changes_ || pending_local_changes_) 377 if (pending_remote_changes_ || pending_local_changes_)
374 continue; 378 continue;
375 379
376 base::RunLoop run_loop; 380 base::RunLoop run_loop;
377 int64 largest_fetched_change_id = -1; 381 int64_t largest_fetched_change_id = -1;
378 PostTaskAndReplyWithResult( 382 PostTaskAndReplyWithResult(
379 worker_task_runner_.get(), 383 worker_task_runner_.get(), FROM_HERE,
380 FROM_HERE,
381 base::Bind(&MetadataDatabase::GetLargestFetchedChangeID, 384 base::Bind(&MetadataDatabase::GetLargestFetchedChangeID,
382 base::Unretained(metadata_database())), 385 base::Unretained(metadata_database())),
383 base::Bind(&SetValueAndCallClosure<int64>, 386 base::Bind(&SetValueAndCallClosure<int64_t>, run_loop.QuitClosure(),
384 run_loop.QuitClosure(),
385 &largest_fetched_change_id)); 387 &largest_fetched_change_id));
386 run_loop.Run(); 388 run_loop.Run();
387 if (largest_fetched_change_id != GetLargestChangeID()) { 389 if (largest_fetched_change_id != GetLargestChangeID()) {
388 FetchRemoteChanges(); 390 FetchRemoteChanges();
389 continue; 391 continue;
390 } 392 }
391 break; 393 break;
392 } 394 }
393 } 395 }
394 return SYNC_STATUS_OK; 396 return SYNC_STATUS_OK;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 622
621 content::TestBrowserThreadBundle thread_bundle_; 623 content::TestBrowserThreadBundle thread_bundle_;
622 624
623 base::ScopedTempDir base_dir_; 625 base::ScopedTempDir base_dir_;
624 scoped_ptr<leveldb::Env> in_memory_env_; 626 scoped_ptr<leveldb::Env> in_memory_env_;
625 TestingProfile profile_; 627 TestingProfile profile_;
626 628
627 scoped_ptr<SyncEngine> remote_sync_service_; 629 scoped_ptr<SyncEngine> remote_sync_service_;
628 scoped_ptr<LocalFileSyncService> local_sync_service_; 630 scoped_ptr<LocalFileSyncService> local_sync_service_;
629 631
630 int64 pending_remote_changes_; 632 int64_t pending_remote_changes_;
631 int64 pending_local_changes_; 633 int64_t pending_local_changes_;
632 634
633 scoped_ptr<FakeDriveServiceHelper> fake_drive_service_helper_; 635 scoped_ptr<FakeDriveServiceHelper> fake_drive_service_helper_;
634 std::map<std::string, CannedSyncableFileSystem*> file_systems_; 636 std::map<std::string, CannedSyncableFileSystem*> file_systems_;
635 637
636 638
637 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 639 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
638 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; 640 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
639 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 641 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
640 642
641 DISALLOW_COPY_AND_ASSIGN(DriveBackendSyncTest); 643 DISALLOW_COPY_AND_ASSIGN(DriveBackendSyncTest);
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 1723
1722 EXPECT_EQ(1u, CountApp()); 1724 EXPECT_EQ(1u, CountApp());
1723 EXPECT_EQ(1u, CountLocalFile(app_id)); 1725 EXPECT_EQ(1u, CountLocalFile(app_id));
1724 1726
1725 EXPECT_EQ(2u, CountMetadata()); 1727 EXPECT_EQ(2u, CountMetadata());
1726 EXPECT_EQ(2u, CountTracker()); 1728 EXPECT_EQ(2u, CountTracker());
1727 } 1729 }
1728 1730
1729 } // namespace drive_backend 1731 } // namespace drive_backend
1730 } // namespace sync_file_system 1732 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698