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 <stdint.h> |
| 6 |
5 #include <vector> | 7 #include <vector> |
6 | 8 |
7 #include "base/basictypes.h" | |
8 #include "base/bind.h" | 9 #include "base/bind.h" |
9 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
10 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" |
11 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
12 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
13 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
14 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "build/build_config.h" |
15 #include "chrome/browser/sync_file_system/file_change.h" | 18 #include "chrome/browser/sync_file_system/file_change.h" |
16 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" | 19 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" |
17 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" | 20 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
18 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 21 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
19 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h" | 22 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h" |
20 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h" | 23 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h" |
21 #include "chrome/browser/sync_file_system/local/mock_sync_status_observer.h" | 24 #include "chrome/browser/sync_file_system/local/mock_sync_status_observer.h" |
22 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 25 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
23 #include "chrome/browser/sync_file_system/mock_local_change_processor.h" | 26 #include "chrome/browser/sync_file_system/mock_local_change_processor.h" |
24 #include "chrome/browser/sync_file_system/sync_file_metadata.h" | 27 #include "chrome/browser/sync_file_system/sync_file_metadata.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 144 |
142 void TearDown() override { | 145 void TearDown() override { |
143 local_service_->Shutdown(); | 146 local_service_->Shutdown(); |
144 file_system_->TearDown(); | 147 file_system_->TearDown(); |
145 RevokeSyncableFileSystem(); | 148 RevokeSyncableFileSystem(); |
146 content::RunAllPendingInMessageLoop(BrowserThread::FILE); | 149 content::RunAllPendingInMessageLoop(BrowserThread::FILE); |
147 content::RunAllPendingInMessageLoop(BrowserThread::IO); | 150 content::RunAllPendingInMessageLoop(BrowserThread::IO); |
148 } | 151 } |
149 | 152 |
150 // LocalChangeObserver overrides. | 153 // LocalChangeObserver overrides. |
151 void OnLocalChangeAvailable(int64 num_changes) override { | 154 void OnLocalChangeAvailable(int64_t num_changes) override { |
152 num_changes_ = num_changes; | 155 num_changes_ = num_changes; |
153 } | 156 } |
154 | 157 |
155 void PrepareForProcessRemoteChange( | 158 void PrepareForProcessRemoteChange( |
156 const FileSystemURL& url, | 159 const FileSystemURL& url, |
157 const tracked_objects::Location& where, | 160 const tracked_objects::Location& where, |
158 SyncStatusCode expected_status, | 161 SyncStatusCode expected_status, |
159 const SyncFileMetadata& expected_metadata) { | 162 const SyncFileMetadata& expected_metadata) { |
160 base::RunLoop run_loop; | 163 base::RunLoop run_loop; |
161 local_service_->PrepareForProcessRemoteChange( | 164 local_service_->PrepareForProcessRemoteChange( |
(...skipping 21 matching lines...) Expand all Loading... |
183 base::RunLoop run_loop; | 186 base::RunLoop run_loop; |
184 local_service_->FinalizeRemoteSync( | 187 local_service_->FinalizeRemoteSync( |
185 url, | 188 url, |
186 sync_status == SYNC_STATUS_OK, | 189 sync_status == SYNC_STATUS_OK, |
187 run_loop.QuitClosure()); | 190 run_loop.QuitClosure()); |
188 run_loop.Run(); | 191 run_loop.Run(); |
189 } | 192 } |
190 return sync_status; | 193 return sync_status; |
191 } | 194 } |
192 | 195 |
193 int64 GetNumChangesInTracker() const { | 196 int64_t GetNumChangesInTracker() const { |
194 return file_system_->backend()->change_tracker()->num_changes(); | 197 return file_system_->backend()->change_tracker()->num_changes(); |
195 } | 198 } |
196 | 199 |
197 content::TestBrowserThreadBundle thread_bundle_; | 200 content::TestBrowserThreadBundle thread_bundle_; |
198 | 201 |
199 base::ScopedTempDir temp_dir_; | 202 base::ScopedTempDir temp_dir_; |
200 scoped_ptr<leveldb::Env> in_memory_env_; | 203 scoped_ptr<leveldb::Env> in_memory_env_; |
201 TestingProfile profile_; | 204 TestingProfile profile_; |
202 | 205 |
203 scoped_ptr<CannedSyncableFileSystem> file_system_; | 206 scoped_ptr<CannedSyncableFileSystem> file_system_; |
204 scoped_ptr<LocalFileSyncService> local_service_; | 207 scoped_ptr<LocalFileSyncService> local_service_; |
205 | 208 |
206 int64 num_changes_; | 209 int64_t num_changes_; |
207 }; | 210 }; |
208 | 211 |
209 // More complete tests for PrepareForProcessRemoteChange and ApplyRemoteChange | 212 // More complete tests for PrepareForProcessRemoteChange and ApplyRemoteChange |
210 // are also in content_unittest:LocalFileSyncContextTest. | 213 // are also in content_unittest:LocalFileSyncContextTest. |
211 TEST_F(LocalFileSyncServiceTest, RemoteSyncStepsSimple) { | 214 TEST_F(LocalFileSyncServiceTest, RemoteSyncStepsSimple) { |
212 const FileSystemURL kFile(file_system_->URL("file")); | 215 const FileSystemURL kFile(file_system_->URL("file")); |
213 const FileSystemURL kDir(file_system_->URL("dir")); | 216 const FileSystemURL kDir(file_system_->URL("dir")); |
214 const char kTestFileData[] = "0123456789"; | 217 const char kTestFileData[] = "0123456789"; |
215 const int kTestFileDataSize = static_cast<int>(arraysize(kTestFileData) - 1); | 218 const int kTestFileDataSize = static_cast<int>(arraysize(kTestFileData) - 1); |
216 | 219 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 | 593 |
591 class OriginChangeMapTest : public testing::Test { | 594 class OriginChangeMapTest : public testing::Test { |
592 protected: | 595 protected: |
593 OriginChangeMapTest() {} | 596 OriginChangeMapTest() {} |
594 ~OriginChangeMapTest() override {} | 597 ~OriginChangeMapTest() override {} |
595 | 598 |
596 bool NextOriginToProcess(GURL* origin) { | 599 bool NextOriginToProcess(GURL* origin) { |
597 return map_.NextOriginToProcess(origin); | 600 return map_.NextOriginToProcess(origin); |
598 } | 601 } |
599 | 602 |
600 int64 GetTotalChangeCount() const { | 603 int64_t GetTotalChangeCount() const { return map_.GetTotalChangeCount(); } |
601 return map_.GetTotalChangeCount(); | |
602 } | |
603 | 604 |
604 void SetOriginChangeCount(const GURL& origin, int64 changes) { | 605 void SetOriginChangeCount(const GURL& origin, int64_t changes) { |
605 map_.SetOriginChangeCount(origin, changes); | 606 map_.SetOriginChangeCount(origin, changes); |
606 } | 607 } |
607 | 608 |
608 void SetOriginEnabled(const GURL& origin, bool enabled) { | 609 void SetOriginEnabled(const GURL& origin, bool enabled) { |
609 map_.SetOriginEnabled(origin, enabled); | 610 map_.SetOriginEnabled(origin, enabled); |
610 } | 611 } |
611 | 612 |
612 LocalFileSyncService::OriginChangeMap map_; | 613 LocalFileSyncService::OriginChangeMap map_; |
613 }; | 614 }; |
614 | 615 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 all_origins.insert(kOrigin2); | 727 all_origins.insert(kOrigin2); |
727 all_origins.insert(kOrigin3); | 728 all_origins.insert(kOrigin3); |
728 while (!all_origins.empty()) { | 729 while (!all_origins.empty()) { |
729 ASSERT_TRUE(NextOriginToProcess(&origin)); | 730 ASSERT_TRUE(NextOriginToProcess(&origin)); |
730 ASSERT_TRUE(ContainsKey(all_origins, origin)); | 731 ASSERT_TRUE(ContainsKey(all_origins, origin)); |
731 all_origins.erase(origin); | 732 all_origins.erase(origin); |
732 } | 733 } |
733 } | 734 } |
734 | 735 |
735 } // namespace sync_file_system | 736 } // namespace sync_file_system |
OLD | NEW |