| 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/drive/file_cache.h" | 5 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 LOG(ERROR) << "Failed to store: " | 174 LOG(ERROR) << "Failed to store: " |
| 175 << "source_path = " << source_path.value() << ", " | 175 << "source_path = " << source_path.value() << ", " |
| 176 << "dest_path = " << dest_path.value() << ", " | 176 << "dest_path = " << dest_path.value() << ", " |
| 177 << "file_operation_type = " << file_operation_type; | 177 << "file_operation_type = " << file_operation_type; |
| 178 return FILE_ERROR_FAILED; | 178 return FILE_ERROR_FAILED; |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Now that file operations have completed, update metadata. | 181 // Now that file operations have completed, update metadata. |
| 182 cache_entry.set_md5(md5); | 182 cache_entry.set_md5(md5); |
| 183 cache_entry.set_is_present(true); | 183 cache_entry.set_is_present(true); |
| 184 cache_entry.set_is_dirty(false); | 184 if (md5.empty()) |
| 185 cache_entry.set_is_dirty(true); |
| 185 return storage_->PutCacheEntry(id, cache_entry) ? | 186 return storage_->PutCacheEntry(id, cache_entry) ? |
| 186 FILE_ERROR_OK : FILE_ERROR_FAILED; | 187 FILE_ERROR_OK : FILE_ERROR_FAILED; |
| 187 } | 188 } |
| 188 | 189 |
| 189 FileError FileCache::Pin(const std::string& id) { | 190 FileError FileCache::Pin(const std::string& id) { |
| 190 AssertOnSequencedWorkerPool(); | 191 AssertOnSequencedWorkerPool(); |
| 191 | 192 |
| 192 FileCacheEntry cache_entry; | 193 FileCacheEntry cache_entry; |
| 193 storage_->GetCacheEntry(id, &cache_entry); | 194 storage_->GetCacheEntry(id, &cache_entry); |
| 194 cache_entry.set_is_pinned(true); | 195 cache_entry.set_is_pinned(true); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 return; | 571 return; |
| 571 | 572 |
| 572 DCHECK_LT(0, it->second); | 573 DCHECK_LT(0, it->second); |
| 573 --it->second; | 574 --it->second; |
| 574 if (it->second == 0) | 575 if (it->second == 0) |
| 575 write_opened_files_.erase(it); | 576 write_opened_files_.erase(it); |
| 576 } | 577 } |
| 577 | 578 |
| 578 } // namespace internal | 579 } // namespace internal |
| 579 } // namespace drive | 580 } // namespace drive |
| OLD | NEW |