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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/drive_backend_sync_unittest.cc

Issue 322813002: [SyncFS] Drop test only un-thread-safe getters from SyncEngine (4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/sync_engine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 #include <stack> 6 #include <stack>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "chrome/browser/drive/drive_uploader.h" 11 #include "chrome/browser/drive/drive_uploader.h"
12 #include "chrome/browser/drive/fake_drive_service.h" 12 #include "chrome/browser/drive/fake_drive_service.h"
13 #include "chrome/browser/drive/test_util.h" 13 #include "chrome/browser/drive/test_util.h"
14 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h" 14 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h"
15 #include "chrome/browser/sync_file_system/drive_backend/fake_drive_service_helpe r.h" 15 #include "chrome/browser/sync_file_system/drive_backend/fake_drive_service_helpe r.h"
16 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" 16 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
17 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" 17 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
18 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h" 18 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h"
19 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h"
19 #include "chrome/browser/sync_file_system/drive_backend/sync_worker.h" 20 #include "chrome/browser/sync_file_system/drive_backend/sync_worker.h"
20 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" 21 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h"
21 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" 22 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h"
22 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h" 23 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h"
23 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" 24 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
24 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" 25 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
25 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" 26 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
26 #include "chrome/test/base/testing_profile.h" 27 #include "chrome/test/base/testing_profile.h"
27 #include "content/public/test/test_browser_thread.h" 28 #include "content/public/test/test_browser_thread.h"
28 #include "content/public/test/test_browser_thread_bundle.h" 29 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 base::Bind(&MetadataDatabase::CountFileTracker, 554 base::Bind(&MetadataDatabase::CountFileTracker,
554 base::Unretained(metadata_database())), 555 base::Unretained(metadata_database())),
555 base::Bind(&SetValueAndCallClosure<size_t>, 556 base::Bind(&SetValueAndCallClosure<size_t>,
556 run_loop.QuitClosure(), &count)); 557 run_loop.QuitClosure(), &count));
557 run_loop.Run(); 558 run_loop.Run();
558 return count; 559 return count;
559 } 560 }
560 561
561 drive::FakeDriveService* fake_drive_service() { 562 drive::FakeDriveService* fake_drive_service() {
562 return static_cast<drive::FakeDriveService*>( 563 return static_cast<drive::FakeDriveService*>(
563 remote_sync_service_->GetDriveService()); 564 remote_sync_service_->drive_service_.get());
564 } 565 }
565 566
566 FakeDriveServiceHelper* fake_drive_service_helper() { 567 FakeDriveServiceHelper* fake_drive_service_helper() {
567 return fake_drive_service_helper_.get(); 568 return fake_drive_service_helper_.get();
568 } 569 }
569 570
570 private: 571 private:
571 // NOTE: Member functions of MetadataDatabase class must not be called 572 // SyncEngineContext is normally used on the worker thread.
572 // directly through this method. Call them via PostTask. 573 // Use this only when there is no task running on the worker.
574 SyncEngineContext* context() {
peria 2014/06/10 03:18:15 This method is used only in metadata_database(). W
tzik 2014/06/10 03:53:22 Done.
575 return remote_sync_service_->sync_worker_->context_.get();
576 }
577
578 // MetadataDatabase is normally used on the worker thread.
579 // Use this only when there is no task running on the worker.
573 MetadataDatabase* metadata_database() { 580 MetadataDatabase* metadata_database() {
peria 2014/06/10 03:18:15 This change seems to be independent from the objec
tzik 2014/06/10 03:53:23 Done.
574 return remote_sync_service_->sync_worker_->GetMetadataDatabase(); 581 return context()->metadata_database_.get();
575 } 582 }
576 583
577 content::TestBrowserThreadBundle thread_bundle_; 584 content::TestBrowserThreadBundle thread_bundle_;
578 585
579 base::ScopedTempDir base_dir_; 586 base::ScopedTempDir base_dir_;
580 scoped_ptr<leveldb::Env> in_memory_env_; 587 scoped_ptr<leveldb::Env> in_memory_env_;
581 TestingProfile profile_; 588 TestingProfile profile_;
582 589
583 scoped_ptr<SyncEngine> remote_sync_service_; 590 scoped_ptr<SyncEngine> remote_sync_service_;
584 scoped_ptr<LocalFileSyncService> local_sync_service_; 591 scoped_ptr<LocalFileSyncService> local_sync_service_;
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 1683
1677 EXPECT_EQ(1u, CountApp()); 1684 EXPECT_EQ(1u, CountApp());
1678 EXPECT_EQ(1u, CountLocalFile(app_id)); 1685 EXPECT_EQ(1u, CountLocalFile(app_id));
1679 1686
1680 EXPECT_EQ(2u, CountMetadata()); 1687 EXPECT_EQ(2u, CountMetadata());
1681 EXPECT_EQ(2u, CountTracker()); 1688 EXPECT_EQ(2u, CountTracker());
1682 } 1689 }
1683 1690
1684 } // namespace drive_backend 1691 } // namespace drive_backend
1685 } // namespace sync_file_system 1692 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/sync_engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698