| 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/file_util.h" | 9 #include "base/file_util.h" | 
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" | 
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 809   return (free_space >= num_bytes); | 809   return (free_space >= num_bytes); | 
| 810 } | 810 } | 
| 811 | 811 | 
| 812 bool FileCache::ImportOldDB(const base::FilePath& old_db_path) { | 812 bool FileCache::ImportOldDB(const base::FilePath& old_db_path) { | 
| 813   if (!file_util::PathExists(old_db_path))  // Old DB is not there, do nothing. | 813   if (!file_util::PathExists(old_db_path))  // Old DB is not there, do nothing. | 
| 814     return false; | 814     return false; | 
| 815 | 815 | 
| 816   // Copy all entries stored in the old DB. | 816   // Copy all entries stored in the old DB. | 
| 817   bool imported = false; | 817   bool imported = false; | 
| 818   { | 818   { | 
| 819     FileCacheMetadata old_data(blocking_task_runner_); | 819     FileCacheMetadata old_data(blocking_task_runner_.get()); | 
| 820     if (old_data.Initialize(old_db_path) == | 820     if (old_data.Initialize(old_db_path) == | 
| 821         FileCacheMetadata::INITIALIZE_OPENED) { | 821         FileCacheMetadata::INITIALIZE_OPENED) { | 
| 822       scoped_ptr<FileCacheMetadata::Iterator> it = old_data.GetIterator(); | 822       scoped_ptr<FileCacheMetadata::Iterator> it = old_data.GetIterator(); | 
| 823       for (; !it->IsAtEnd(); it->Advance()) { | 823       for (; !it->IsAtEnd(); it->Advance()) { | 
| 824         FileCacheEntry entry; | 824         FileCacheEntry entry; | 
| 825         if (storage_->GetCacheEntry(it->GetKey(), &entry)) | 825         if (storage_->GetCacheEntry(it->GetKey(), &entry)) | 
| 826           continue;  // Do not overwrite. | 826           continue;  // Do not overwrite. | 
| 827 | 827 | 
| 828         storage_->PutCacheEntry(it->GetKey(), it->GetValue()); | 828         storage_->PutCacheEntry(it->GetKey(), it->GetValue()); | 
| 829       } | 829       } | 
| 830       imported = true; | 830       imported = true; | 
| 831     } | 831     } | 
| 832   } | 832   } | 
| 833 | 833 | 
| 834   // Delete old DB. | 834   // Delete old DB. | 
| 835   base::Delete(old_db_path, true /* recursive */ ); | 835   base::Delete(old_db_path, true /* recursive */ ); | 
| 836   return imported; | 836   return imported; | 
| 837 } | 837 } | 
| 838 | 838 | 
| 839 }  // namespace internal | 839 }  // namespace internal | 
| 840 }  // namespace drive | 840 }  // namespace drive | 
| OLD | NEW | 
|---|