| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gdata/gdata_cache.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_cache.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/chromeos/chromeos_version.h" | 9 #include "base/chromeos/chromeos_version.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 | 925 |
| 926 if (!cache_entry.get()) { // Entry does not exist in cache. | 926 if (!cache_entry.get()) { // Entry does not exist in cache. |
| 927 // Set both |dest_path| and |source_path| to /dev/null, so that: | 927 // Set both |dest_path| and |source_path| to /dev/null, so that: |
| 928 // 1) ModifyCacheState won't move files when |source_path| and |dest_path| | 928 // 1) ModifyCacheState won't move files when |source_path| and |dest_path| |
| 929 // are the same. | 929 // are the same. |
| 930 // 2) symlinks to /dev/null will be picked up by GDataSyncClient to download | 930 // 2) symlinks to /dev/null will be picked up by GDataSyncClient to download |
| 931 // pinned files that don't exist in cache. | 931 // pinned files that don't exist in cache. |
| 932 dest_path = FilePath::FromUTF8Unsafe(util::kSymLinkToDevNull); | 932 dest_path = FilePath::FromUTF8Unsafe(util::kSymLinkToDevNull); |
| 933 source_path = dest_path; | 933 source_path = dest_path; |
| 934 | 934 |
| 935 // Set sub_dir_type to PINNED to indicate that the file doesn't exist. | 935 // Set sub_dir_type to TMP. The file will be first downloaded in 'tmp', |
| 936 // When the file is finally downloaded and StoreToCache called, it will be | 936 // then moved to 'persistent'. |
| 937 // moved to persistent directory. | 937 sub_dir_type = CACHE_TYPE_TMP; |
| 938 sub_dir_type = CACHE_TYPE_PINNED; | |
| 939 } else { // File exists in cache, determines destination path. | 938 } else { // File exists in cache, determines destination path. |
| 940 cache_state |= cache_entry->cache_state; | 939 cache_state |= cache_entry->cache_state; |
| 941 | 940 |
| 942 // Determine source and destination paths. | 941 // Determine source and destination paths. |
| 943 | 942 |
| 944 // If file is dirty or mounted, don't move it, so determine |dest_path| and | 943 // If file is dirty or mounted, don't move it, so determine |dest_path| and |
| 945 // set |source_path| the same, because ModifyCacheState only moves files if | 944 // set |source_path| the same, because ModifyCacheState only moves files if |
| 946 // source and destination are different. | 945 // source and destination are different. |
| 947 if (cache_entry->IsDirty() || cache_entry->IsMounted()) { | 946 if (cache_entry->IsDirty() || cache_entry->IsMounted()) { |
| 948 DCHECK_EQ(CACHE_TYPE_PERSISTENT, cache_entry->sub_dir_type); | 947 DCHECK_EQ(CACHE_TYPE_PERSISTENT, cache_entry->sub_dir_type); |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 } | 1560 } |
| 1562 return success; | 1561 return success; |
| 1563 } | 1562 } |
| 1564 | 1563 |
| 1565 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { | 1564 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { |
| 1566 delete global_free_disk_getter_for_testing; // Safe to delete NULL; | 1565 delete global_free_disk_getter_for_testing; // Safe to delete NULL; |
| 1567 global_free_disk_getter_for_testing = getter; | 1566 global_free_disk_getter_for_testing = getter; |
| 1568 } | 1567 } |
| 1569 | 1568 |
| 1570 } // namespace gdata | 1569 } // namespace gdata |
| OLD | NEW |