OLD | NEW |
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 "chrome/browser/chromeos/drive/directory_loader.h" | 5 #include "chrome/browser/chromeos/drive/directory_loader.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 389 |
390 int64 remote_changestamp = about_resource->largest_change_id(); | 390 int64 remote_changestamp = about_resource->largest_change_id(); |
391 | 391 |
392 // Start loading the directory. | 392 // Start loading the directory. |
393 int64 directory_changestamp = std::max( | 393 int64 directory_changestamp = std::max( |
394 entry->directory_specific_info().changestamp(), *local_changestamp); | 394 entry->directory_specific_info().changestamp(), *local_changestamp); |
395 | 395 |
396 DirectoryFetchInfo directory_fetch_info( | 396 DirectoryFetchInfo directory_fetch_info( |
397 local_id, entry->resource_id(), remote_changestamp); | 397 local_id, entry->resource_id(), remote_changestamp); |
398 | 398 |
399 // If the directory's changestamp is new enough, just schedule to run the | 399 // If the directory's changestamp is up-to-date or the global changestamp of |
400 // callback, as there is no need to fetch the directory. | 400 // the metadata DB is new enough (which means the normal changelist loading |
401 if (directory_changestamp + kMinimumChangestampGap > remote_changestamp) { | 401 // should finish very soon), just schedule to run the callback, as there is no |
| 402 // need to fetch the directory. |
| 403 if (directory_changestamp >= remote_changestamp || |
| 404 *local_changestamp + kMinimumChangestampGap > remote_changestamp) { |
402 OnDirectoryLoadComplete(local_id, FILE_ERROR_OK); | 405 OnDirectoryLoadComplete(local_id, FILE_ERROR_OK); |
403 } else { | 406 } else { |
404 // Start fetching the directory content, and mark it with the changestamp | 407 // Start fetching the directory content, and mark it with the changestamp |
405 // |remote_changestamp|. | 408 // |remote_changestamp|. |
406 LoadDirectoryFromServer(directory_fetch_info); | 409 LoadDirectoryFromServer(directory_fetch_info); |
407 } | 410 } |
408 } | 411 } |
409 | 412 |
410 void DirectoryLoader::OnDirectoryLoadComplete(const std::string& local_id, | 413 void DirectoryLoader::OnDirectoryLoadComplete(const std::string& local_id, |
411 FileError error) { | 414 FileError error) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 // Also notify the observers. | 564 // Also notify the observers. |
562 if (error == FILE_ERROR_OK && !directory_path->empty()) { | 565 if (error == FILE_ERROR_OK && !directory_path->empty()) { |
563 FOR_EACH_OBSERVER(ChangeListLoaderObserver, | 566 FOR_EACH_OBSERVER(ChangeListLoaderObserver, |
564 observers_, | 567 observers_, |
565 OnDirectoryReloaded(*directory_path)); | 568 OnDirectoryReloaded(*directory_path)); |
566 } | 569 } |
567 } | 570 } |
568 | 571 |
569 } // namespace internal | 572 } // namespace internal |
570 } // namespace drive | 573 } // namespace drive |
OLD | NEW |