| 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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } | 690 } |
| 691 | 691 |
| 692 void GDataCache::RequestInitializeOnUIThread() { | 692 void GDataCache::RequestInitializeOnUIThread() { |
| 693 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 693 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 694 | 694 |
| 695 blocking_task_runner_->PostTask( | 695 blocking_task_runner_->PostTask( |
| 696 FROM_HERE, | 696 FROM_HERE, |
| 697 base::Bind(&GDataCache::Initialize, base::Unretained(this))); | 697 base::Bind(&GDataCache::Initialize, base::Unretained(this))); |
| 698 } | 698 } |
| 699 | 699 |
| 700 void GDataCache::RequestInitializeOnUIThreadForTesting() { |
| 701 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 702 |
| 703 blocking_task_runner_->PostTask( |
| 704 FROM_HERE, |
| 705 base::Bind(&GDataCache::InitializeForTesting, base::Unretained(this))); |
| 706 } |
| 707 |
| 700 void GDataCache::ForceRescanOnUIThreadForTesting() { | 708 void GDataCache::ForceRescanOnUIThreadForTesting() { |
| 701 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 709 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 702 | 710 |
| 703 blocking_task_runner_->PostTask( | 711 blocking_task_runner_->PostTask( |
| 704 FROM_HERE, | 712 FROM_HERE, |
| 705 base::Bind(&GDataCache::ForceRescanForTesting, base::Unretained(this))); | 713 base::Bind(&GDataCache::ForceRescanForTesting, base::Unretained(this))); |
| 706 } | 714 } |
| 707 | 715 |
| 708 bool GDataCache::GetCacheEntry(const std::string& resource_id, | 716 bool GDataCache::GetCacheEntry(const std::string& resource_id, |
| 709 const std::string& md5, | 717 const std::string& md5, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 736 | 744 |
| 737 void GDataCache::Initialize() { | 745 void GDataCache::Initialize() { |
| 738 AssertOnSequencedWorkerPool(); | 746 AssertOnSequencedWorkerPool(); |
| 739 | 747 |
| 740 InitCachePaths(cache_paths_); | 748 InitCachePaths(cache_paths_); |
| 741 metadata_ = GDataCacheMetadata::CreateGDataCacheMetadata( | 749 metadata_ = GDataCacheMetadata::CreateGDataCacheMetadata( |
| 742 blocking_task_runner_).Pass(); | 750 blocking_task_runner_).Pass(); |
| 743 metadata_->Initialize(cache_paths_); | 751 metadata_->Initialize(cache_paths_); |
| 744 } | 752 } |
| 745 | 753 |
| 754 void GDataCache::InitializeForTesting() { |
| 755 AssertOnSequencedWorkerPool(); |
| 756 |
| 757 InitCachePaths(cache_paths_); |
| 758 metadata_ = GDataCacheMetadata::CreateGDataCacheMetadataForTesting( |
| 759 blocking_task_runner_).Pass(); |
| 760 metadata_->Initialize(cache_paths_); |
| 761 } |
| 762 |
| 746 void GDataCache::Destroy() { | 763 void GDataCache::Destroy() { |
| 747 AssertOnSequencedWorkerPool(); | 764 AssertOnSequencedWorkerPool(); |
| 748 delete this; | 765 delete this; |
| 749 } | 766 } |
| 750 | 767 |
| 751 void GDataCache::ForceRescanForTesting() { | 768 void GDataCache::ForceRescanForTesting() { |
| 752 AssertOnSequencedWorkerPool(); | 769 AssertOnSequencedWorkerPool(); |
| 753 metadata_->ForceRescanForTesting(cache_paths_); | 770 metadata_->ForceRescanForTesting(cache_paths_); |
| 754 } | 771 } |
| 755 | 772 |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 const GDataCacheEntry& cache_entry) { | 1581 const GDataCacheEntry& cache_entry) { |
| 1565 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; | 1582 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; |
| 1566 } | 1583 } |
| 1567 | 1584 |
| 1568 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { | 1585 void SetFreeDiskSpaceGetterForTesting(FreeDiskSpaceGetterInterface* getter) { |
| 1569 delete global_free_disk_getter_for_testing; // Safe to delete NULL; | 1586 delete global_free_disk_getter_for_testing; // Safe to delete NULL; |
| 1570 global_free_disk_getter_for_testing = getter; | 1587 global_free_disk_getter_for_testing = getter; |
| 1571 } | 1588 } |
| 1572 | 1589 |
| 1573 } // namespace gdata | 1590 } // namespace gdata |
| OLD | NEW |