| 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 "chrome/browser/sync_file_system/local/local_file_change_tracker.h" | 5 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <deque> | 9 #include <deque> |
| 8 #include <set> | 10 #include <set> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 14 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 15 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
| 16 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" | 18 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" |
| 17 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 19 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
| 18 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 20 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
| 19 #include "chrome/browser/sync_file_system/sync_status_code.h" | 21 #include "chrome/browser/sync_file_system/sync_status_code.h" |
| 20 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 22 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
| 21 #include "content/public/test/mock_blob_url_request_context.h" | 23 #include "content/public/test/mock_blob_url_request_context.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 EXPECT_EQ(base::File::FILE_OK, | 289 EXPECT_EQ(base::File::FILE_OK, |
| 288 file_system_.CreateDirectory(URL(kPath1))); // Creates a dir. | 290 file_system_.CreateDirectory(URL(kPath1))); // Creates a dir. |
| 289 EXPECT_EQ(base::File::FILE_OK, | 291 EXPECT_EQ(base::File::FILE_OK, |
| 290 file_system_.CreateDirectory(URL(kPath2))); // Creates another dir. | 292 file_system_.CreateDirectory(URL(kPath2))); // Creates another dir. |
| 291 EXPECT_EQ(base::File::FILE_OK, | 293 EXPECT_EQ(base::File::FILE_OK, |
| 292 file_system_.CreateFile(URL(kPath3))); // Creates a file. | 294 file_system_.CreateFile(URL(kPath3))); // Creates a file. |
| 293 EXPECT_EQ(base::File::FILE_OK, | 295 EXPECT_EQ(base::File::FILE_OK, |
| 294 file_system_.TruncateFile(URL(kPath3), 1)); // Modifies the file. | 296 file_system_.TruncateFile(URL(kPath3), 1)); // Modifies the file. |
| 295 EXPECT_EQ(base::File::FILE_OK, | 297 EXPECT_EQ(base::File::FILE_OK, |
| 296 file_system_.CreateFile(URL(kPath4))); // Creates another file. | 298 file_system_.CreateFile(URL(kPath4))); // Creates another file. |
| 297 EXPECT_EQ(static_cast<int64>(kData.size()), // Modifies the file. | 299 EXPECT_EQ(static_cast<int64_t>(kData.size()), // Modifies the file. |
| 298 file_system_.Write(&url_request_context, | 300 file_system_.Write(&url_request_context, URL(kPath4), |
| 299 URL(kPath4), blob.GetBlobDataHandle())); | 301 blob.GetBlobDataHandle())); |
| 300 | 302 |
| 301 // Verify the changes. | 303 // Verify the changes. |
| 302 file_system_.GetChangedURLsInTracker(&urls); | 304 file_system_.GetChangedURLsInTracker(&urls); |
| 303 EXPECT_EQ(5U, urls.size()); | 305 EXPECT_EQ(5U, urls.size()); |
| 304 | 306 |
| 305 // Reset the changes in in-memory tracker. | 307 // Reset the changes in in-memory tracker. |
| 306 DropChangesInTracker(); | 308 DropChangesInTracker(); |
| 307 | 309 |
| 308 // Make sure we have no in-memory changes in the tracker. | 310 // Make sure we have no in-memory changes in the tracker. |
| 309 file_system_.GetChangedURLsInTracker(&urls); | 311 file_system_.GetChangedURLsInTracker(&urls); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 EXPECT_EQ(base::File::FILE_OK, | 440 EXPECT_EQ(base::File::FILE_OK, |
| 439 file_system_.CreateDirectory(URL(kPath1))); // Creates a dir. | 441 file_system_.CreateDirectory(URL(kPath1))); // Creates a dir. |
| 440 EXPECT_EQ(base::File::FILE_OK, | 442 EXPECT_EQ(base::File::FILE_OK, |
| 441 file_system_.CreateDirectory(URL(kPath2))); // Creates another dir. | 443 file_system_.CreateDirectory(URL(kPath2))); // Creates another dir. |
| 442 EXPECT_EQ(base::File::FILE_OK, | 444 EXPECT_EQ(base::File::FILE_OK, |
| 443 file_system_.CreateFile(URL(kPath3))); // Creates a file. | 445 file_system_.CreateFile(URL(kPath3))); // Creates a file. |
| 444 EXPECT_EQ(base::File::FILE_OK, | 446 EXPECT_EQ(base::File::FILE_OK, |
| 445 file_system_.TruncateFile(URL(kPath3), 1)); // Modifies the file. | 447 file_system_.TruncateFile(URL(kPath3), 1)); // Modifies the file. |
| 446 EXPECT_EQ(base::File::FILE_OK, | 448 EXPECT_EQ(base::File::FILE_OK, |
| 447 file_system_.CreateFile(URL(kPath4))); // Creates another file. | 449 file_system_.CreateFile(URL(kPath4))); // Creates another file. |
| 448 EXPECT_EQ(static_cast<int64>(kData.size()), | 450 EXPECT_EQ(static_cast<int64_t>(kData.size()), |
| 449 file_system_.Write(&url_request_context, // Modifies the file. | 451 file_system_.Write(&url_request_context, // Modifies the file. |
| 450 URL(kPath4), blob.GetBlobDataHandle())); | 452 URL(kPath4), blob.GetBlobDataHandle())); |
| 451 | 453 |
| 452 // Verify we have 5 changes for preparation. | 454 // Verify we have 5 changes for preparation. |
| 453 file_system_.GetChangedURLsInTracker(&urls); | 455 file_system_.GetChangedURLsInTracker(&urls); |
| 454 EXPECT_EQ(5U, urls.size()); | 456 EXPECT_EQ(5U, urls.size()); |
| 455 change_tracker()->ClearChangesForURL(URL(kPath0)); | 457 change_tracker()->ClearChangesForURL(URL(kPath0)); |
| 456 change_tracker()->ClearChangesForURL(URL(kPath1)); | 458 change_tracker()->ClearChangesForURL(URL(kPath1)); |
| 457 change_tracker()->ClearChangesForURL(URL(kPath2)); | 459 change_tracker()->ClearChangesForURL(URL(kPath2)); |
| 458 change_tracker()->ClearChangesForURL(URL(kPath3)); | 460 change_tracker()->ClearChangesForURL(URL(kPath3)); |
| 459 change_tracker()->ClearChangesForURL(URL(kPath4)); | 461 change_tracker()->ClearChangesForURL(URL(kPath4)); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 | 707 |
| 706 // Make sure they're gone from the database too. | 708 // Make sure they're gone from the database too. |
| 707 DropChangesInTracker(); | 709 DropChangesInTracker(); |
| 708 RestoreChangesFromTrackerDB(); | 710 RestoreChangesFromTrackerDB(); |
| 709 | 711 |
| 710 GetAllChangedURLs(&urls); | 712 GetAllChangedURLs(&urls); |
| 711 EXPECT_TRUE(urls.empty()); | 713 EXPECT_TRUE(urls.empty()); |
| 712 } | 714 } |
| 713 | 715 |
| 714 } // namespace sync_file_system | 716 } // namespace sync_file_system |
| OLD | NEW |